Conversation
changes
…hine. Still some issues with it actually going to mark, because it seems to idle
| public: | ||
| FreeKicker(int r_id); | ||
| FreeKicker(int r_id, std::shared_ptr<ClientHandles> clientHandles); | ||
| FreeKicker(const Position& other, std::shared_ptr<ClientHandles> clientHandles); |
There was a problem hiding this comment.
Should we consider making clientHandles part of Position instead of adding to every specific position? If we are doing it this way, would it make sense to only pass the clients it actually needs rather than a struct with all of them?
There was a problem hiding this comment.
I tried doing this in the past and remember encountering a lot of weird errors. I think there are a lot of places that end up expecting to have some definition of clienthandles (b/c included in position) but it's hard to pass one in. I tried again just now and still getting a lot of weird errors. I can try to debug but I think it would just take a long time and this approach already works so I would prefer to move on.
There was a problem hiding this comment.
Just got a fix for this working, i can either add it to this PR or just make a new one after this gets merged, up to you @petergarud
There was a problem hiding this comment.
All that is left for this PR is rebasing based off Waller Coordinator once that is merged in
| // Position&) | ||
| current_position_->die(); | ||
| current_position_ = std::make_unique<Pos>(*current_position_); | ||
| current_position_ = std::make_unique<Pos>(*current_position_, clientHandles_); |
There was a problem hiding this comment.
If you wanted to do conditional passing of handles based on position, you could use template specializations here, but I personally think client handles should just be added to Position itself
|
Pretty much everything should be resolved aside from potentially adding clientHandles to Position which does not feel necessary right now. |
automated style fixes Co-authored-by: petergarud <petergarud@users.noreply.github.com>
sanatd33
left a comment
There was a problem hiding this comment.
looks good for now, i have some ideas on how to simplify the client_handles_ thing but i think that can be done after this is merged?
| @@ -45,8 +45,7 @@ class Defense : public Position { | |||
|
|
|||
| private: | |||
| // static constexpr int kMaxWallers{6}; | |||
There was a problem hiding this comment.
Remove this out-of-date comment with kMaxWallers = 6
| Marker marker_; | ||
| bool sent_join_marking_group_request_ = false; | ||
| RJ::Time request_time_; | ||
| RJ::Seconds kMarkingGroupJoinTimeout{2.0}; |
There was a problem hiding this comment.
Make kMarkingGroupJoinTimeout static constexpr
|
|
||
| std::array<uint8_t, kNumShells> marking_list_{}; | ||
| std::array<double, kNumShells> danger_score_{}; | ||
| std::array<uint8_t, kNumShells> enemey_to_friends_{}; |
There was a problem hiding this comment.
I think we noticed that and left it because it's kind of funny but we can change that if necessary and if it could cause future issues
Just changed it to enemy to prevent future headaches
| std::array<uint8_t, kNumShells> marking_list_{}; | ||
| std::array<double, kNumShells> danger_score_{}; | ||
| std::array<uint8_t, kNumShells> enemey_to_friends_{}; | ||
| std::vector<uint8_t> queue_; |
There was a problem hiding this comment.
Nit: Can we use a more descriptive name for the queue (ie. available_markers)?
There was a problem hiding this comment.
Changed to unassigned_markers_queue to be more descriptive. Kept the queue in there so people know it's a queue.
| struct Result { | ||
| bool am_i_member{false}; // Whether this robot is currently a member of the kicker group. | ||
| std::optional<bool> am_i_marking{false}; | ||
| std::optional<uint8_t> who_i_am_marking{kInvalidRobotId}; // ID of Kicker id |
There was a problem hiding this comment.
Is there a reason to make these optional variables? Seems like we never set them to nullopt anywhere
Update: Looking at this more closely, can we just remove this struct altogether and pass a single bool?
There was a problem hiding this comment.
I think we still need to know if we are marking someone along with if we are member. Removed am_i_marking and just kept who_am_i_marking (changed variable name for consistency). This is an optional now (got rid of the default value) and if it is set then we treat it as they are marking someone, if it is empty they are not marking someone.
| uint8_t most_dangerous = kInvalidRobotId; | ||
| double min = std::numeric_limits<double>::infinity(); | ||
| for (size_t i = 0; i < danger_score_.size(); ++i) { | ||
| // don't include marked robots or the guy with the ball in most dangerous calculation |
There was a problem hiding this comment.
Pretty sure this logic is repeated elsewhere in the file. Probably should make this a helper function. In general, some refactoring might be nice here considering these functions are pretty long
There was a problem hiding this comment.
Made helper function to find most dangerous robot
| onOurSide = robot.pose.position().y() > field_center.y(); | ||
| } | ||
|
|
||
| if (onOurSide) { |
There was a problem hiding this comment.
Use our_half constant instead of this. Shapes have a .contains() method
| static constexpr int kMaxMarkers = 2; | ||
| // this is the threshold value for switching | ||
| // you can play with these constants if the current results aren't good enough | ||
| static constexpr double kSuperDangerSub = 3.1415926535; |
There was a problem hiding this comment.
Don't we have a PI constant?
There was a problem hiding this comment.
Technically this is just a random number and not pi, but I'll change it to 3.2 so no one else gets confused
|
|
||
| // for (size_t i = 0; i < 6; ++i) { | ||
| // SPDLOG_INFO("Robot {} has danger score {}", i, danger_score_[i]); | ||
| // } |
There was a problem hiding this comment.
I kept that one in because it's really easy to uncomment for debugging purposes but can remove if it is clutter
automated style fixes Co-authored-by: sanatd33 <sanatd33@users.noreply.github.com>
Squid5678
left a comment
There was a problem hiding this comment.
Logic makes sense to me, though this PR requires changing a significant number of our classes to incorporate this functionality. While they are minor changes, I do think it's worth documenting somewhere what these changes are and why we made them for future reference.
| // static constexpr int kMaxWallers{6}; | ||
| static constexpr int kMaxWallers{ | ||
| static_cast<int>(kNumShells)}; // This effectively turns off marking | ||
| static constexpr int kMaxWallers{2}; |
There was a problem hiding this comment.
can this be changed into a constant
| Marker marker_; | ||
| bool sent_join_marking_group_request_ = false; | ||
| RJ::Time request_time_; | ||
| RJ::Seconds kMarkingGroupJoinTimeout{2.0}; // 2 seconds |
There was a problem hiding this comment.
make this a constant as well in case needs to be tuned later
| class Defense : public Position { | ||
| public: | ||
| Defense(int r_id); | ||
| Defense(int r_id, std::shared_ptr<ClientHandles> clientHandles); |
There was a problem hiding this comment.
ClientHandles seems to play a very large part in the implementation of coordinators going forward. I'm in agreement with Sanat here that we could find a solution in the future, but I am also on the side that if this works, we should not change it and finish off the coordinator design.
It would be nice if we could have a doc created on the purpose of these ClientHandles. Nothing too crazy, just explaining the purpose and where they should be used.
| danger_score_[i] = danger_score; | ||
| } | ||
|
|
||
| // for (size_t i = 0; i < 6; ++i) { |
There was a problem hiding this comment.
Remove comments; in the future if you want to include something for debugging purposes, just add to clickup description, easier for everyone to access.
| [this](const rj_msgs::msg::Marking::SharedPtr msg) { // callback=std::move(callback) | ||
| selected_robot_marking_id_ = msg->mark_robot_ids[robot_id_]; | ||
| am_i_marking_ = (selected_robot_marking_id_ != kInvalidRobotId); | ||
| // callback(Result{true, selected_robot_marking_id_}); |
automated style fixes Co-authored-by: shourikb <shourikb@users.noreply.github.com>
…robocup-software into marking-coordinator
automated style fixes Co-authored-by: petergarud <petergarud@users.noreply.github.com>
sanatd33
left a comment
There was a problem hiding this comment.
nothing blocking but if you need to make changes anyway go fix all the small stuff me and rishi commented on
| static constexpr int kMaxMarkers = 2; | ||
| // this is the threshold value for switching | ||
| // you can play with these constants if the current results aren't good enough | ||
| static constexpr double kSuperDangerSub = 3.2; |
There was a problem hiding this comment.
maybe some more info on what each param is?
Allows marking with multiple robots by coordinating who to mark using a danger score calculation