-
Notifications
You must be signed in to change notification settings - Fork 189
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
base: ros2
Are you sure you want to change the base?
Marking coordinator #2446
Changes from all commits
8b1aa38
ef5bc01
74e7956
a5487ae
dfe621e
01e4436
6301a5b
c85f542
e83d402
b501fe6
ded69ac
20b41d0
787f99b
32f8860
64ef7d4
15f1b61
267f9bd
30e54f6
86e538a
c740b5e
68ce933
245cfd4
1d6c90d
a6c207a
b653fd7
5477bf5
e2b8c4e
f070f8a
2f1354a
ac18cc7
a53480b
3914d60
3073ef6
9207a0c
d916b5a
8de5768
0ce1e25
e79fb8e
1fc4831
22d0b1b
88daaec
7b1c468
498f016
dd5a402
5e2cc4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,7 @@ | |
| #include <rj_msgs/action/robot_move.hpp> | ||
|
|
||
| #include "rj_strategy/agent/position.hpp" | ||
| #include "rj_strategy/agent/position/marker.hpp" | ||
| #include "rj_strategy/agent/position/waller.hpp" | ||
|
|
||
| namespace strategy { | ||
|
|
||
| /* | ||
|
|
@@ -44,9 +42,8 @@ class Defense : public Position { | |
| void revive() override; | ||
|
|
||
| private: | ||
| // static constexpr int kMaxWallers{6}; | ||
| static constexpr int kMaxWallers{ | ||
| static_cast<int>(kNumShells)}; // This effectively turns off marking | ||
| static constexpr int kMaxWallers{2}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this be changed into a constant |
||
| static constexpr RJ::Seconds kMarkingGroupJoinTimeout{2.0}; | ||
|
|
||
| /** | ||
| * @brief The derived_get_task method returns the task for the defensive robot | ||
|
|
@@ -120,8 +117,10 @@ class Defense : public Position { | |
| int get_waller_id(); | ||
| State current_state_ = JOINING_WALL; | ||
|
|
||
| int get_marker_target_id(); | ||
| Marker marker_; | ||
| bool sent_join_marking_group_request_ = false; | ||
| RJ::Time request_time_; | ||
|
|
||
| bool pending_marking_state_ = false; | ||
| }; | ||
|
|
||
| } // namespace strategy | ||
This file was deleted.
| 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; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe some more info on what each param is? |
||
| 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 | ||
| 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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update these docstrings |
||
| * | ||
| * 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 | ||
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.
can you remove these changes from the commit (same for
install/setup.zsh)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.
I don't think anything got changed here. Looks like just removed then added the line back.