Skip to content

Conversation

@Yamam0t0
Copy link
Contributor

変更点

  • shoot tacticの追加
  • robot_model.pyにおいてdartaclassのRobotクラスで定義しているposとvelをfieldで初期化するように変更
  • force startで0版のロボットがボールに向かって行き、ゴールに向かってシュートします

試したこと

  • force start状態でボールを適当に配置し、ゴールに向かってシュートするかを確認
  • 状態遷移が行われているかを出力して確認

確認事項

状態遷移が行われているかを確認するためにprintデバッグしたコードが残ってます。消すかログとして見れるようにしますか?

@github-actions
Copy link

test_scenario_force_start.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/14425330716/artifacts/2934050950

@github-actions
Copy link

test_scenario_kickoff.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/14425646250/artifacts/2934120909

@Yamam0t0 Yamam0t0 requested a review from ShotaAk April 13, 2025 03:32
Copy link
Contributor

@ShotaAk ShotaAk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ボールも蹴れてるし、新しいライブラリも使えてて良いと思います!

気になるところコメントしたので修正お願いします〜〜

Comment on lines 48 to 50
self.machine = Machine(
model=self, states=states, transitions=transitions, initial="chasing"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Machineを継承しているので、親クラスの初期化関数をsuper()で呼んでください

super().__init__(model=self, ....

class Shoot(TacticBase):
"""指定した位置にシュートするTactic."""

def __init__(self, target_x=6.0, target_y=0.0):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

シュート位置を自動生成する、賢いShoot Tacticが欲しくなるね。今後のタスクにしよう

self.target_pos.y = target_y
self.move_pos = State2D()

self.robot = ShootStateMachine("robot")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state machineだとわかるような変数名にしてください。
robotだと、robot_modelの情報と混同しちゃいそう〜

self.machine`でいいと思う

Comment on lines 94 to 96
if self.robot.state == "chasing" and dist_to_ball <= BALL_NEAR_THRESHOLD:
# ボールが近く、状態がchasingの場合、シュートの準備をする
self.robot.ball_near()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tactic側で状態遷移を処理しているのが気になります。
状態遷移の責務はMachineに渡しちゃいましょう。

ShootStateMachineに、update()関数とdist_to_ball, shoot_angleメンバーを追加すれば、状態遷移を完全に移植できます

Suggested change
if self.robot.state == "chasing" and dist_to_ball <= BALL_NEAR_THRESHOLD:
# ボールが近く、状態がchasingの場合、シュートの準備をする
self.robot.ball_near()
self.robot.dist_to_ball = tool.get_distance(ball_pos, robot_pos)
self.robot.shoot_angle = tool.get_angle(ball_pos, self.target_pos)
self.robot.update()
if self.robot.state == "chasing":
# ボールが近く、状態がchasingの場合、シュートの準備をする

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tacticでやることは、状態に対する"行動" だけにしましょう〜

Comment on lines 24 to 25
BALL_NEAR_THRESHOLD = 0.5 # ボールが近いとみなす距離の閾値[m]
SHOOT_ANGLE_THRESHOLD = 10 # シュート角度の閾値[degree]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これはTactic内でしか使われてないので、Tacticの中で宣言してください〜

Comment on lines 52 to 60
def on_enter_chasing(self):
print(f"{self.name} is now chasing the ball.")

def on_enter_aiming(self):
print(f"{self.name} is now aiming at the ball.")

def on_enter_shooting(self):
print(f"{self.name} is shooting!")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここは今使ってないから一旦削除しよう〜

@ShotaAk ShotaAk self-requested a review April 13, 2025 06:13
@github-actions
Copy link

test_scenario_force_start.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/14427514082/artifacts/2934623678

Copy link
Contributor

@ShotaAk ShotaAk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ShotaAk ShotaAk merged commit 6294b2d into main Apr 13, 2025
12 of 13 checks passed
@ShotaAk ShotaAk deleted the add_shoot_tactic branch April 13, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants