-
Notifications
You must be signed in to change notification settings - Fork 1
Add shoot tactic #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add shoot tactic #336
Conversation
|
test_scenario_force_start.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/14425330716/artifacts/2934050950 |
|
test_scenario_kickoff.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/14425646250/artifacts/2934120909 |
ShotaAk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ボールも蹴れてるし、新しいライブラリも使えてて良いと思います!
気になるところコメントしたので修正お願いします〜〜
| self.machine = Machine( | ||
| model=self, states=states, transitions=transitions, initial="chasing" | ||
| ) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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`でいいと思う
| if self.robot.state == "chasing" and dist_to_ball <= BALL_NEAR_THRESHOLD: | ||
| # ボールが近く、状態がchasingの場合、シュートの準備をする | ||
| self.robot.ball_near() |
There was a problem hiding this comment.
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メンバーを追加すれば、状態遷移を完全に移植できます
| 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の場合、シュートの準備をする |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tacticでやることは、状態に対する"行動" だけにしましょう〜
| BALL_NEAR_THRESHOLD = 0.5 # ボールが近いとみなす距離の閾値[m] | ||
| SHOOT_ANGLE_THRESHOLD = 10 # シュート角度の閾値[degree] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これはTactic内でしか使われてないので、Tacticの中で宣言してください〜
| 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!") | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここは今使ってないから一旦削除しよう〜
|
test_scenario_force_start.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/14427514082/artifacts/2934623678 |
ShotaAk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
変更点
試したこと
確認事項
状態遷移が行われているかを確認するためにprintデバッグしたコードが残ってます。消すかログとして見れるようにしますか?