Skip to content

Conversation

@agich073
Copy link
Contributor

概要

  • world_modelとtacticから評価関数等を抜き出した
  • evaluationとperceptionディレクトリを作成した
    • evaluation: 評価により計算等が発生するもの
    • perception: 客観的な事実を見ているworld_modelと違い、主観的な事実を見ているもの

関連チケット

変更内容

  • tactickはなるべく戦術の実行だけをまとめた
  • kick_target_model.pyはkick_target_evaluation.pyとして移植

動作確認内容

  • ビルドが通ること
  • 手動での動作確認(該当箇所の実行結果など)

確認したReferee Command

  • HALT
  • STOP
  • FORCE_START
  • OUR_FREEKICK
  • THEIR_FREEKICK
  • OUR KICKOFF
  • THEIR KICKOFF
  • OUR_PENALTY
  • THEIR_PENALTY
  • OUR_TIMEOUT
  • THEIR_TIMEOUT

影響範囲

  • たくさん
        new file:   consai_game/consai_game/evaluation/__init__.py
        new file:   consai_game/consai_game/evaluation/ball_evaluation.py
        new file:   consai_game/consai_game/evaluation/evaluation.py
        new file:   consai_game/consai_game/evaluation/evaluation_meta_data.py
        new file:   consai_game/consai_game/evaluation/evaluation_provider_node.py
        new file:   consai_game/consai_game/evaluation/kick_target_evaluation.py
        new file:   consai_game/consai_game/evaluation/robot_evaluation.py
        modified:   consai_game/consai_game/main.py
        new file:   consai_game/consai_game/perception/__init__.py
        new file:   consai_game/consai_game/perception/ball_perception.py
        new file:   consai_game/consai_game/perception/robot_perception.py
        modified:   consai_game/consai_game/tactic/composite/composite_defense.py
        modified:   consai_game/consai_game/tactic/composite/composite_offense.py
        modified:   consai_game/consai_game/tactic/dribble.py
        modified:   consai_game/consai_game/tactic/kick.py
        modified:   consai_game/consai_game/visualization/visualize_msg_publisher_node.py
        modified:   consai_game/consai_game/world_model/ball_activity_model.py
        modified:   consai_game/consai_game/world_model/kick_target_model.py
        modified:   consai_game/consai_game/world_model/world_model.py
        modified:   consai_game/consai_game/world_model/world_model_provider_node.py

補足

  • PR作成時点でevaluationをtacticのrun()の引数に設定する方法がわからず、場当たり的にevaluationを使っている

@github-actions
Copy link

test_scenario_kickoff.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16904335626/artifacts/3742959644
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_penalty.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16904335626/artifacts/3742962204
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_kickoff.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16904335626/artifacts/3745297432
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_penalty.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16904335626/artifacts/3745299398
How to replay the logs: README_play_logfile

@ShotaAk
Copy link
Contributor

ShotaAk commented Aug 12, 2025

キックオフとペナルティのシナリオで失敗しているので、何が起きてるのか確認お願いします!

ログファイルの確認方法も上のリンク先に書いてあります

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.

コメントしました。

evaluationの実装方針を変えたほうが良いですね 👀

Comment on lines 18 to 23
"""
WorldModelProviderNode モジュール.
このモジュールは ROS2 ノードとして動作する.
Referee メッセージや TrackedFrame を受け取り, ワールドモデルをリアルタイムに更新する.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

コメント修正お願いします!

Comment on lines 88 to 92
"""
タイマーにより定期的に呼び出され、WorldModelの状態を更新する.
ロボットのアクティビティやボール位置を再計算する.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

こちらも修正お願いします

Copy link
Contributor

Choose a reason for hiding this comment

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

ball_evaluationは使ってないので このPRから削除お願いします。

(中身もBallPositionModelになってます)

Copy link
Contributor

Choose a reason for hiding this comment

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

巨大なファイルになっているので分割しましょう。

1関数/1ファイルになっても良いです。

Comment on lines 117 to 122
@dataclass
class Threat:
score: int # 0以上
robot_id: int # 相手のロボットID

class ThreatsModel:
Copy link
Contributor

Choose a reason for hiding this comment

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

threat_model.pyに抽出しましょう



# kick_target_model.py
def _obstacle_exists(target: State2D, ball: BallModel, robots: dict[int, Robot], tolerance) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

obstacle_exists.pyに抽出しましょう。
関数名も、アンダーバーをつけずにobstacle_exists にしてください。

return True
return False

def _is_robot_inside_pass_area(ball: BallModel, robot: Robot, _half_width: Field) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

is_robot_inside_pass_area.pyに抽出しましょう。

関数名もアンダーバーを外してください。

Comment on lines 236 to 267
# robot_activity_model.py
"""未完了."""
@dataclass
class ReceiveScore:
"""ボールをどれだけ受け取りやすいかを保持するデータクラス."""

robot_id: int = 0
intercept_time: float = float("inf") # あと何秒後にボールを受け取れるか

def calc_ball_receive_score_list(
robots: dict[int, Robot], ball: BallModel, ball_activity: BallActivityModel, game_config: GameConfigModel
) -> list[ReceiveScore]:
"""ロボットごとにボールを受け取れるスコアを計算する."""

# ボールが動いていない場合は、スコアをデフォルト値にする
if not ball_activity.ball_is_moving:
return [ReceiveScore(robot_id=robot.robot_id) for robot in robots.values()]

score_list = []
for robot in robots.values():
score_list.append(
ReceiveScore(
robot_id=robot.robot_id,
intercept_time=calc_intercept_time(robot, ball, game_config),
)
)

# intercept_timeが小さい順にソート
score_list.sort(key=lambda x: x.intercept_time)
return score_list

def calc_intercept_time(robot: Robot, ball: BallModel, game_config: GameConfigModel) -> float:
Copy link
Contributor

Choose a reason for hiding this comment

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

未完了コードはPRから外しましょう〜。

また、依存関係によってはrobot_evaluationに入れずに、他の関数と同様に独立させてもいいと思います。

self.very_close_to_ball_threshold = 0.3
self.do_receive = do_receive

self.evaluation: Evaluation = Evaluation()
Copy link
Contributor

Choose a reason for hiding this comment

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

evaluationをメンバに持ってますが、
evaluationを更新する仕組みが用意されてないので期待通りに動かないと思います。

最初はworld_modelのメンバにevaluationを追加する、という仕組みにしてみてほしいです。

Comment on lines 92 to 94
# dribble.py
def ball_is_front(ball_pos: State2D, robot_pos: State2D, target_pos: State2D) -> bool:
"""ボールがロボットの前にあるかどうかを判定する."""
Copy link
Contributor

Choose a reason for hiding this comment

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

ballの関数なので別ファイルに抽出しましょう。

ball_is_front.py にしても良いです。

@github-actions
Copy link

test_scenario_force_start.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16928602572/artifacts/3751843279
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_free_kick.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16928602572/artifacts/3751844120
How to replay the logs: README_play_logfile

@github-actions
Copy link

yellow_invert/test_scenario_yellow_invert_kickoff.py failed. Failure logs:
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_kickoff.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16928602572/artifacts/3751845988
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_ball_placement2.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16928602572/artifacts/3751850707
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_ball_placement.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16928602572/artifacts/3751850820
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_obstacle_avoidance.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16928602572/artifacts/3751851364
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_penalty.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16928926600/artifacts/3751942475
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_kickoff.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16930057125/artifacts/3752283786
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_penalty.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16930057125/artifacts/3752284986
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_kickoff.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16930057125/artifacts/3752423742
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_penalty.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16930057125/artifacts/3752424521
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_kickoff.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16930057125/artifacts/3760574650
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_penalty.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16930057125/artifacts/3760575613
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_penalty.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16930057125/artifacts/3760600600
How to replay the logs: README_play_logfile

@ShotaAk ShotaAk self-requested a review August 14, 2025 13:46
@github-actions
Copy link

test_scenario_force_start.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16986324251/artifacts/3772490311
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_obstacle_avoidance.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16986324251/artifacts/3772491484
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_free_kick.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16986324251/artifacts/3772491741
How to replay the logs: README_play_logfile

@github-actions
Copy link

yellow_invert/test_scenario_yellow_invert_kickoff.py failed. Failure logs:
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_kickoff.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16986324251/artifacts/3772493188
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_penalty.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16986324251/artifacts/3772496028
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_ball_placement2.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16986324251/artifacts/3772498240
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_ball_placement.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16986324251/artifacts/3772498588
How to replay the logs: README_play_logfile

@github-actions
Copy link

test_scenario_obstacle_avoidance.py failed. Failure logs: https://github.com/SSL-Roots/consai_ros2/actions/runs/16986436278/artifacts/3772527868
How to replay the logs: README_play_logfile

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.

リファクタリングの方針良いと思います。
気になるところをコメントしました!

self.last_ball_pos_to_detect_moving: Optional[State2D] = None

# ボールの予測クラスのインスタンスを生成
self.ball_prediction = BallPrediction()
Copy link
Contributor

Choose a reason for hiding this comment

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

ここでpredictionのインスタンスが存在しているのが気になります。
world_model、evaluation、perceptionは並列の関係(親子関係じゃない)のはずなので、
インスタンスをメンバとして持たないほうがいいと思いました。

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.

4 participants