-
Notifications
You must be signed in to change notification settings - Fork 190
Marking coordinator #2446
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
Closed
Closed
Marking coordinator #2446
Changes from 45 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
8b1aa38
first steps
shourikb ef5bc01
added required messages for marking
shourikb 74e7956
more setup
shourikb a5487ae
fixed some stuff
shourikb dfe621e
added a dangerous score array to keep track of valid targets
shourikb 01e4436
made some progress
shourikb 6301a5b
danger score calcs
Squid5678 c85f542
more marking stuff
Squid5678 e83d402
update naming
Squid5678 b501fe6
can leave marking
Squid5678 ded69ac
fixed linker error
Squid5678 20b41d0
started client
Squid5678 787f99b
marking client should be done
Squid5678 32f8860
started on danger score calculation
petergarud 64ef7d4
marking coordaintor should be done'
petergarud 15f1b61
Struct of coordinators: compiles but fails to run at all
petergarud 267f9bd
Fix issue with not running
petergarud 30e54f6
starting implementing coordaintor with defense
petergarud 86e538a
added some more stuff to implement marking into the defense state mac…
shourikb c740b5e
some debugging done. marks now, but sim crashes
shourikb 68ce933
stuff
petergarud 245cfd4
fixed it so it compiles
shourikb 1d6c90d
Stuff
petergarud a6c207a
rebase to ros2 to have colcon
sanatd33 b653fd7
stuff
petergarud 5477bf5
New danger score parameters
petergarud e2b8c4e
Merge from ros2
petergarud f070f8a
Danger angle change
petergarud 2f1354a
doesn't mark the guy with the ball anymore
shourikb ac18cc7
completed marking coordinator
shourikb a53480b
cleaned up a little
shourikb 3914d60
Fix Code Style On marking-coordinator (#2447)
github-actions[bot] 3073ef6
Resolve merge comments
petergarud 9207a0c
Resolve comments
petergarud d916b5a
Fix Code Style On marking-coordinator (#2452)
github-actions[bot] 8de5768
fix client handles
sanatd33 0ce1e25
Fix Code Style On marking-coordinator (#2454)
github-actions[bot] e79fb8e
addressed most comments but still missing some callback stuff (check …
shourikb 1fc4831
Fix Code Style On marking-coordinator (#2457)
github-actions[bot] 22d0b1b
fixed some more comments
shourikb 88daaec
Merge branch 'marking-coordinator' of https://github.com/RoboJackets/…
shourikb 7b1c468
More fixes
shourikb 498f016
addressed all comments
shourikb dd5a402
Add client handles implementation
petergarud 5e2cc4d
Fix Code Style On marking-coordinator (#2472)
github-actions[bot] 7c729e4
last few fixes
shourikb 4d7e53a
minor bug fix
shourikb edf7e17
Fix Code Style On marking-coordinator (#2485)
github-actions[bot] 9fbfb5c
Merge branch 'ros2' into marking-coordinator
petergarud 5c32854
Fix Code Style On marking-coordinator (#2488)
github-actions[bot] b5e8c63
CMake issues
petergarud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # This is a message to pick a robot to mark | ||
| uint8[16] mark_robot_ids # ID of the robot to mark on the opposing team |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Request a robot to be added to or removed from the marking group | ||
| uint8 robot_id # ID of the robot (0 to kNumShells-1) | ||
| bool join | ||
| --- | ||
| bool success # Always true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
src/rj_strategy/include/rj_strategy/agent/position/marker.hpp
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
src/rj_strategy/include/rj_strategy/coordinator/marking.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #pragma once | ||
|
|
||
| #include <algorithm> | ||
| #include <array> | ||
| #include <limits> | ||
|
|
||
| #include <rclcpp/rclcpp.hpp> | ||
|
|
||
| #include <rj_common/field_dimensions.hpp> | ||
| #include <rj_common/world_state.hpp> | ||
| #include <rj_constants/constants.hpp> | ||
| #include <rj_constants/topic_names.hpp> | ||
| #include <rj_convert/ros_convert.hpp> | ||
| #include <rj_msgs/msg/marking.hpp> | ||
| #include <rj_msgs/msg/world_state.hpp> | ||
| #include <rj_msgs/srv/marking.hpp> | ||
|
|
||
| #include "rj_strategy/coordinator.hpp" | ||
|
|
||
| namespace strategy { | ||
|
|
||
| class Marking : public Coordinator<Marking, rj_msgs::srv::Marking, rj_msgs::msg::Marking> { | ||
| public: | ||
| static constexpr uint8_t kInvalidRobotId = kNumShells; | ||
|
|
||
| Marking(); | ||
| ~Marking() override = default; | ||
| Marking(const Marking&) = delete; | ||
| Marking& operator=(const Marking&) = delete; | ||
| Marking(Marking&&) = delete; | ||
| Marking& operator=(Marking&&) = delete; | ||
|
|
||
| void service_callback(RequestPtr request, ResponsePtr response); | ||
|
|
||
| private: | ||
| void publish_marking_list(); | ||
| void update_danger_scores(); | ||
| uint8_t find_their_robot_in_possession(); | ||
| uint8_t most_dangerous_robot(uint8_t robotInPossession); | ||
|
|
||
| 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; | ||
petergarud marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| static constexpr double kDangerDistToBall = 3.0; | ||
| static constexpr double kDangerDistToGoal = 5.0; | ||
| static constexpr double kDangerDistToOurRobots = 3.0; | ||
| static constexpr double kDangerAngle = 2.0; | ||
| static constexpr double kPossessionThreshold = 0.3; | ||
| int num_markers_; | ||
|
|
||
| std::array<uint8_t, kNumShells> marking_list_{}; | ||
| std::array<double, kNumShells> danger_score_{}; | ||
| std::array<uint8_t, kNumShells> enemy_to_friends_{}; | ||
| std::unordered_set<uint8_t> unassigned_markers_queue_; | ||
| WorldState last_world_state_; | ||
| FieldDimensions field_dimensions_ = FieldDimensions::kDefaultDimensions; | ||
| rclcpp::Subscription<rj_msgs::msg::WorldState>::SharedPtr world_state_sub_; | ||
| }; | ||
|
|
||
| } // namespace strategy | ||
72 changes: 72 additions & 0 deletions
72
src/rj_strategy/include/rj_strategy/coordinator/marking_client.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #pragma once | ||
|
|
||
| #include <functional> | ||
|
|
||
| #include <rclcpp/rclcpp.hpp> | ||
| #include <spdlog/spdlog.h> | ||
|
|
||
| #include <rj_msgs/msg/marking.hpp> | ||
| #include <rj_msgs/srv/marking.hpp> | ||
|
|
||
| #include "rj_constants/constants.hpp" | ||
|
|
||
| namespace strategy { | ||
|
|
||
| /** | ||
| * @brief Client for interacting with the KickerPicker coordinator. | ||
petergarud marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * Manages membership in the kicker group and tracks the currently selected kicker. | ||
| */ | ||
| class MarkingClient { | ||
| public: | ||
| static constexpr uint8_t kInvalidRobotId = kNumShells; | ||
|
|
||
| using StatusCallback = std::function<void(bool)>; | ||
|
|
||
| explicit MarkingClient(rclcpp::Node::SharedPtr node, uint8_t robot_id); | ||
| ~MarkingClient() = default; | ||
| MarkingClient(const MarkingClient&) = delete; | ||
| MarkingClient& operator=(const MarkingClient&) = delete; | ||
| MarkingClient(MarkingClient&&) = delete; | ||
| MarkingClient& operator=(MarkingClient&&) = delete; | ||
|
|
||
| /** | ||
| * @brief Join the marking group. | ||
| * @param callback Called with current membership status after attempt to join. | ||
| */ | ||
| void join_group(StatusCallback callback = nullptr); | ||
|
|
||
| /** | ||
| * @brief Leave the marking group. | ||
| * @param callback Called with current membership status after attempt to leave. | ||
| */ | ||
| void leave_group(StatusCallback callback = nullptr); | ||
|
|
||
| /** | ||
| * @brief Check if this robot is a member of the marker group. | ||
| */ | ||
| [[nodiscard]] bool am_i_member() const; | ||
|
|
||
| /** | ||
| * @brief Get the currently selected enemey robot id marking. | ||
| * @return robot ID of selected robot, or kInvalidRobotId if none selected. | ||
| */ | ||
| [[nodiscard]] uint8_t who_am_i_marking() const; | ||
|
|
||
| /** | ||
| * @brief Check if this robot is currently marking. | ||
| */ | ||
| [[nodiscard]] bool am_i_marking() const; | ||
rishiso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private: | ||
| rclcpp::Node::SharedPtr node_; | ||
| const uint8_t robot_id_; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members) -- class | ||
| // isn't move/copy-able anyway | ||
| rclcpp::Client<rj_msgs::srv::Marking>::SharedPtr client_; | ||
| rclcpp::Subscription<rj_msgs::msg::Marking>::SharedPtr subscription_; | ||
| bool am_i_member_{false}; | ||
| bool am_i_marking_{false}; | ||
| uint8_t selected_robot_marking_id_{kInvalidRobotId}; | ||
| }; | ||
|
|
||
| } // namespace strategy | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.