Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/msgs/CMakeLists.txt
Copy link
Copy Markdown
Collaborator

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.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rosidl_generate_interfaces(${PROJECT_NAME}
"msg/JointStatus.msg"
"msg/SystemInfo.msg"
"msg/Heading.msg"
"msg/LedStatus.msg"
"srv/SetController.srv"
"srv/StatusReq.srv"
"srv/MaintenanceReq.srv"
Expand Down
3 changes: 3 additions & 0 deletions src/subsystems/navigation/athena_planner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ find_package(nav_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(vision_msgs REQUIRED)
find_package(msgs REQUIRED)

add_library(bt_nodes SHARED
plugins/nav_selector_node.cpp
plugins/aruco_detected_node.cpp
plugins/get_aruco_pose_node.cpp
plugins/spiral_coverage_action_node.cpp
plugins/object_detected_node.cpp
plugins/led_status_node.cpp
)

target_compile_definitions(bt_nodes PRIVATE BT_PLUGIN_EXPORT)
Expand All @@ -42,6 +44,7 @@ ament_target_dependencies(bt_nodes
tf2
tf2_geometry_msgs
vision_msgs
msgs
)

install(TARGETS bt_nodes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</Sequence>
</ReactiveFallback>
</RecoveryNode>
<LedStatus color="green" topic_name="/led_status" />
</Sequence>

<!-- ArUco NOT detected - execute spiral coverage search -->
Expand Down
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>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

<NavSelector topic_name="/nav_mode" default_nav_mode="GNSS" nav_mode="{nav_mode}" />

<LedStatus color="red" topic_name="/led_status" />

<ReactiveFallback name="SelectMode">

<BlackboardCheckString value_A="{nav_mode}" value_B="GNSS" return_on_mismatch="FAILURE">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<!-- Sequence 1: Check if object is detected -->
<Sequence name="ObjectDetectedSequence">
<ObjectDetected object_topic="/yolo/target_found" timeout="1.0" />
<LedStatus color="green" topic_name="/led_status" />
</Sequence>

<!-- Sequence 2: If not detected, perform spiral search -->
Expand Down
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_
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
Loading