-
Notifications
You must be signed in to change notification settings - Fork 189
Waller Coordinator #2467
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
Merged
Merged
Waller Coordinator #2467
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7443687
initial waller coordinator
sanatd33 f54f23f
temp waller
sanatd33 fdff555
working waller coord
sanatd33 2c4ffa9
Fix Code Style On waller-coordinator (#2468)
github-actions[bot] a495dc0
fix comments, break up big function
sanatd33 2586b92
Fix Code Style On waller-coordinator (#2471)
github-actions[bot] 870b37e
fixed pr comments
sanatd33 5734e41
Fix Code Style On waller-coordinator (#2486)
github-actions[bot] 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # This is a message for the waller coordinator | ||
| uint8[16] wall_list # Sorted IDs of robots on the wall | ||
| uint8 wall_size # Number of robots on the wall |
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 waller selection group | ||
| uint8 robot_id # ID of the robot (0 to kNumShells-1) | ||
| bool joining # True to add robot to waller group, false to remove it | ||
| --- | ||
| bool success # True if the ACTION succeded (True for joining means successfully joined, for leaving means successfully left) |
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
49 changes: 0 additions & 49 deletions
49
src/rj_strategy/include/rj_strategy/agent/position/waller.hpp
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
src/rj_strategy/include/rj_strategy/coordinator/waller.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,39 @@ | ||
| #pragma once | ||
|
|
||
| #include <algorithm> | ||
| #include <array> | ||
|
|
||
| #include <rclcpp/rclcpp.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/waller.hpp> | ||
| #include <rj_msgs/msg/world_state.hpp> | ||
| #include <rj_msgs/srv/waller.hpp> | ||
|
|
||
| #include "rj_strategy/coordinator.hpp" | ||
|
|
||
| namespace strategy { | ||
|
|
||
| class Waller : public Coordinator<Waller, rj_msgs::srv::Waller, rj_msgs::msg::Waller> { | ||
| public: | ||
| Waller(); | ||
| ~Waller() override = default; | ||
| Waller(const Waller&) = delete; | ||
| Waller& operator=(const Waller&) = delete; | ||
| Waller(Waller&&) = delete; | ||
| Waller& operator=(Waller&&) = delete; | ||
|
|
||
| void service_callback(RequestPtr request, ResponsePtr response); | ||
|
|
||
| private: | ||
| std::array<uint8_t, kNumShells> walling_robots_; | ||
| uint8_t num_wallers_ = 0; | ||
| static constexpr int kMaxWallers = 4; | ||
|
|
||
| void update_wallers(); | ||
| }; | ||
|
|
||
| } // namespace strategy | ||
92 changes: 92 additions & 0 deletions
92
src/rj_strategy/include/rj_strategy/coordinator/waller_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,92 @@ | ||
| #pragma once | ||
|
|
||
| #include <cmath> | ||
|
|
||
| #include <rclcpp/rclcpp.hpp> | ||
| #include <spdlog/spdlog.h> | ||
|
|
||
| #include <rj_common/field_dimensions.hpp> | ||
| #include <rj_msgs/msg/waller.hpp> | ||
| #include <rj_msgs/srv/waller.hpp> | ||
|
|
||
| #include "rj_strategy/coordinator/waller.hpp" | ||
|
|
||
| namespace strategy { | ||
|
|
||
| /** | ||
| * @brief Client for interacting with the Waller coordinator. | ||
| * | ||
| * Manages membership in the waller group and tracks the currently waller list. | ||
| */ | ||
| class WallerClient { | ||
| public: | ||
| struct Result { | ||
| bool success{false}; | ||
shourikb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| using StatusCallback = std::function<void(Result)>; | ||
rishiso marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| explicit WallerClient(rclcpp::Node::SharedPtr node, uint8_t robot_id); | ||
| ~WallerClient() = default; | ||
| WallerClient(const WallerClient&) = delete; | ||
| WallerClient& operator=(const WallerClient&) = delete; | ||
| WallerClient(WallerClient&&) = delete; | ||
| WallerClient& operator=(WallerClient&&) = delete; | ||
|
|
||
| /** | ||
| * @brief Join the waller group. | ||
| * @param callback Called with current membership status after attempt to join. | ||
| */ | ||
| void join_group(StatusCallback callback = nullptr); | ||
|
|
||
| /** | ||
| * @brief Leave the waller 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 waller group. | ||
| */ | ||
| [[nodiscard]] bool am_i_member() const; | ||
|
|
||
| /** | ||
| * @brief Get the target walling point | ||
| * @return target walling point of this robot. | ||
| */ | ||
| [[nodiscard]] std::optional<rj_geometry::Point> get_walling_point( | ||
| const WorldState* world_state, FieldDimensions field_dimensions) const; | ||
|
|
||
| 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::Waller>::SharedPtr client_; | ||
| rclcpp::Subscription<rj_msgs::msg::Waller>::SharedPtr subscription_; | ||
|
|
||
| bool am_i_member_ = false; | ||
| bool request_pending_ = false; | ||
| std::array<uint8_t, kNumShells> walling_robots_; | ||
| int num_wallers_ = 0; | ||
|
|
||
| static constexpr double kRobotDiameterMultiplier = 1.5; | ||
|
|
||
| struct WallerGeometry { | ||
| double min_wall_radius; | ||
| double wall_spacing; | ||
| rj_geometry::Point goal_pos; | ||
| rj_geometry::Point ball_pos; | ||
| rj_geometry::Point robot_pos; | ||
| }; | ||
|
|
||
| WallerGeometry calculate_wall_geometry(const WorldState* world_state, | ||
| FieldDimensions dimensions) const; | ||
| rj_geometry::Point get_target_position(WallerGeometry& waller_geometry, long waller_pos) const; | ||
| std::optional<uint8_t> get_parent_id(WallerGeometry& waller_geometry, | ||
| rj_geometry::Point target_point, long waller_pos) const; | ||
| rj_geometry::Point get_target_position_with_parent(WallerGeometry& waller_geometry, | ||
| rj_geometry::Point target_point, | ||
| rj_geometry::Point parent_point) const; | ||
| }; | ||
|
|
||
| } // 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.