-
Notifications
You must be signed in to change notification settings - Fork 13
Added Bt LED node #122
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
Open
Rishav-N
wants to merge
4
commits into
umdloop:main
Choose a base branch
from
Rishav-N:bt-led-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Added Bt LED node #122
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
16 changes: 10 additions & 6 deletions
16
src/subsystems/navigation/athena_planner/behavior_trees/gnss_navigation.xml
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 |
|---|---|---|
| @@ -1,10 +1,14 @@ | ||
| <root> | ||
| <BehaviorTree ID="GNSSNavigation"> | ||
| <PipelineSequence name="NavigateWithReplanning"> | ||
| <RateController hz="5.0"> | ||
| <ComputePathToPose goal="{goal}" path="{path}" planner_id="GridBased"/> | ||
| </RateController> | ||
| <FollowPath path="{path}" controller_id="FollowPath"/> | ||
| </PipelineSequence> | ||
| <Sequence> | ||
| <PipelineSequence name="NavigateWithReplanning"> | ||
| <RateController hz="5.0"> | ||
| <ComputePathToPose goal="{goal}" path="{path}" planner_id="GridBased"/> | ||
| </RateController> | ||
| <FollowPath path="{path}" controller_id="FollowPath"/> | ||
| </PipelineSequence> | ||
|
|
||
| <LedStatus color="green" topic_name="/led_status" /> | ||
| </Sequence> | ||
| </BehaviorTree> | ||
| </root> |
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
41 changes: 41 additions & 0 deletions
41
src/subsystems/navigation/athena_planner/include/athena_planner/led_status_node.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,41 @@ | ||
| #ifndef ATHENA_PLANNER__LED_STATUS_NODE_HPP_ | ||
| #define ATHENA_PLANNER__LED_STATUS_NODE_HPP_ | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "behaviortree_cpp_v3/action_node.h" | ||
| #include "rclcpp/rclcpp.hpp" | ||
|
|
||
| // Change this include if your msg package name is different | ||
| #include "msgs/msg/led_status.hpp" | ||
|
|
||
| namespace bt_nodes | ||
| { | ||
|
|
||
| class LedStatusNode : public BT::SyncActionNode | ||
| { | ||
| public: | ||
| LedStatusNode( | ||
| const std::string & name, | ||
| const BT::NodeConfiguration & conf); | ||
|
|
||
| BT::NodeStatus tick() override; | ||
|
|
||
| static BT::PortsList providedPorts() | ||
| { | ||
| return { | ||
| BT::InputPort<std::string>("color"), | ||
| BT::InputPort<std::string>("topic_name", "/led_status") | ||
| }; | ||
| } | ||
|
|
||
| private: | ||
| rclcpp::Node::SharedPtr node_; | ||
| rclcpp::Publisher<msgs::msg::LedStatus>::SharedPtr led_pub_; | ||
|
|
||
| std::string topic_name_; | ||
| }; | ||
|
|
||
| } // namespace bt_nodes | ||
|
|
||
| #endif // ATHENA_PLANNER__LED_STATUS_NODE_HPP_ |
67 changes: 67 additions & 0 deletions
67
src/subsystems/navigation/athena_planner/plugins/led_status_node.cpp
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,67 @@ | ||
| #include "athena_planner/led_status_node.hpp" | ||
|
|
||
| namespace bt_nodes | ||
| { | ||
|
|
||
| LedStatusNode::LedStatusNode( | ||
| const std::string & name, | ||
| const BT::NodeConfiguration & conf) | ||
| : BT::SyncActionNode(name, conf) | ||
| { | ||
| node_ = config().blackboard->get<rclcpp::Node::SharedPtr>("node"); | ||
|
|
||
| topic_name_ = "/led_status"; | ||
| getInput("topic_name", topic_name_); | ||
|
|
||
| led_pub_ = node_->create_publisher<msgs::msg::LedStatus>( | ||
| topic_name_, | ||
| 10); | ||
| } | ||
|
|
||
| BT::NodeStatus LedStatusNode::tick() | ||
| { | ||
| std::string color; | ||
| if (!getInput("color", color)) { | ||
| RCLCPP_ERROR(node_->get_logger(), "LedStatusNode missing required input port [color]"); | ||
| return BT::NodeStatus::FAILURE; | ||
| } | ||
|
|
||
| msgs::msg::LedStatus msg; | ||
| msg.cmd = msgs::msg::LedStatus::CMD_SOLID; | ||
| msg.r = 0; | ||
| msg.g = 0; | ||
| msg.b = 0; | ||
| msg.param = 0; | ||
|
|
||
| if (color == "red" || color == "RED") { | ||
| msg.cmd = msgs::msg::LedStatus::CMD_SOLID; | ||
| msg.r = 255; | ||
| msg.g = 0; | ||
| msg.b = 0; | ||
| } else if (color == "green" || color == "GREEN") { | ||
| msg.cmd = msgs::msg::LedStatus::CMD_FLASH; | ||
| msg.r = 0; | ||
| msg.g = 255; | ||
| msg.b = 0; | ||
| } else { | ||
| RCLCPP_ERROR( | ||
| node_->get_logger(), | ||
| "Invalid LED color [%s]. Expected red or green.", | ||
| color.c_str()); | ||
| return BT::NodeStatus::FAILURE; | ||
| } | ||
|
|
||
| led_pub_->publish(msg); | ||
|
|
||
| RCLCPP_INFO( | ||
| node_->get_logger(), | ||
| "Published LED status: color=%s rgb=[%u, %u, %u]", | ||
| color.c_str(), | ||
| msg.r, | ||
| msg.g, | ||
| msg.b); | ||
|
|
||
| return BT::NodeStatus::SUCCESS; | ||
| } | ||
|
|
||
| } // namespace bt_nodes |
Submodule nav2_config
updated
from 000000 to 890800
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.
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.
Your branch must be out of date or soemthing, we already have this file.