File tree Expand file tree Collapse file tree 3 files changed +30
-5
lines changed
crane_sessions/include/crane_sessions Expand file tree Collapse file tree 3 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,23 @@ class BallPlacementAvoidanceSession : public SessionBase
3333 {
3434 }
3535
36+ auto getRobotSuitabilityFunc () const
37+ -> std::function<double(const std::shared_ptr<RobotInfo> &)> override
38+ {
39+ auto wm = world_model;
40+ return [wm](const std::shared_ptr<RobotInfo> & robot) {
41+ // ゴールキーパーは除外
42+ if (robot->id == wm->getOurGoalieId ()) {
43+ return 10000.0 ;
44+ }
45+ // ボール配置エリアへの距離(近いほど優先)
46+ if (auto placement_area = wm->getBallPlacementArea (); placement_area) {
47+ return bg::distance (robot->pose .pos , placement_area.value ());
48+ }
49+ return 0.0 ;
50+ };
51+ }
52+
3653 auto calculatePositionCommand (const std::vector<RobotIdentifier> & robots)
3754 -> std::pair<Status, std::vector<crane_msgs::msg::PositionCommand>> override
3855 {
Original file line number Diff line number Diff line change @@ -174,11 +174,7 @@ class SessionBase
174174 * @return ロボット適性評価関数
175175 */
176176 virtual auto getRobotSuitabilityFunc () const
177- -> std::function<double(const std::shared_ptr<RobotInfo> &)>
178- {
179- // デフォルト実装: すべてのロボットを等価とみなす(コスト0)
180- return [](const std::shared_ptr<RobotInfo> &) { return 0.0 ; };
181- }
177+ -> std::function<double(const std::shared_ptr<RobotInfo> &)> = 0;
182178
183179 /* *
184180 * @brief ハード制約Tacticかどうかを返す
Original file line number Diff line number Diff line change @@ -30,6 +30,18 @@ class TestSession : public SessionBase
3030 COMPOSITION_PUBLIC explicit TestSession (
3131 WorldModelWrapper::SharedPtr & world_model, rclcpp::Node & node);
3232
33+ auto getRobotSuitabilityFunc () const
34+ -> std::function<double(const std::shared_ptr<RobotInfo> &)> override
35+ {
36+ uint8_t target_id = target_robot_id;
37+ return [target_id](const std::shared_ptr<RobotInfo> & robot) {
38+ if (robot->id == target_id) {
39+ return 0.0 ;
40+ }
41+ return 1000.0 ;
42+ };
43+ }
44+
3345 std::pair<Status, std::vector<crane_msgs::msg::PositionCommand>> calculatePositionCommand (
3446 const std::vector<RobotIdentifier> & robots) override ;
3547
You can’t perform that action at this time.
0 commit comments