Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/y250ht/behavior_ros2
Based on the behavior tree, the warehouse has written a general implementation of some common instructions in Ros2 humble in the behavior tree. Including ros2 run, ros2 topic, etc., the purpose is to integrate it into the behavior tree to achieve multi-function orchestration in the behavior tree.
https://github.com/y250ht/behavior_ros2
behavior-tree navigation ros2-humble usbcamera
Last synced: about 1 month ago
JSON representation
Based on the behavior tree, the warehouse has written a general implementation of some common instructions in Ros2 humble in the behavior tree. Including ros2 run, ros2 topic, etc., the purpose is to integrate it into the behavior tree to achieve multi-function orchestration in the behavior tree.
- Host: GitHub
- URL: https://github.com/y250ht/behavior_ros2
- Owner: Y250HT
- Created: 2024-10-29T07:33:55.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-09T01:59:40.000Z (about 1 month ago)
- Last Synced: 2024-11-09T02:33:22.016Z (about 1 month ago)
- Topics: behavior-tree, navigation, ros2-humble, usbcamera
- Language: C++
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Behavior_Ros2_Humble
Based on the behavior tree, the repository has written a general implementation of some common instructions in Ros2 Humble in the behavior tree. Including ros2 run, ros2 topic, etc., the purpose is to integrate it into the behavior tree to achieve multi-function orchestration in the behavior tree.| 功能 | 描述 | 文件 |
|----------|--------------------|--------|
| autodock_client | Apriltag码定位 | autodock_client.hpp |
| interrupt_event | 中断 | interrupt_event.hpp |
| nav2_client | 导航 | nav2_client.hpp |
| publish_topic | 发布某一话题 | publish_topic.hpp |
| send_goal | 发布目标点 | send_goal.cpp |
| snapshot_client | 相机拍照 | snapshot_client.hpp |
| start_run_command | 执行ros2 run | start_run_command.hpp |
| start_usb_cam | 执行usb相机拍照 | start_usb_cam.hpp |
| teleop_event | cmd_vel控制速度 | teleop_event.hpp |
| wait_node | 睡眠阻塞 | wait_node.hpp |## Build Behavior_ros2:
```bash
$ cd ~/Behavior_ros2/
$ source /opt/ros/humble/setup.bash
$ colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
```
## Nake self node:
If you want to customize some other behavior tree nodes, please write an hpp or cpp file, and then register it in bt_ros2.cpp, I have shown the example.Step 1. Make .hpp file.
```cpp
#pragma once
#include
#include
#include
#include
class PublishTopic : public BT::SyncActionNode
{
public:
PublishTopic(const std::string& name, const BT::NodeConfiguration& config)
: BT::SyncActionNode(name, config)
{
node_ = rclcpp::Node::make_shared("lift_control");
command_ = "ros2 topic pub /lift_control std_msgs/msg/Int32 \"{data: 1}\" --rate 10 --times 20";
}
static BT::PortsList providedPorts()
{
return { BT::InputPort("command") };
}
virtual BT::NodeStatus tick() override
{
std::string custom_command;
if (getInput("command", custom_command)) {
command_ = custom_command;
}
RCLCPP_INFO(node_->get_logger(), "Executing command: %s", command_.c_str());
int result = std::system(command_.c_str());
if (result == 0) {
RCLCPP_INFO(node_->get_logger(), "publish topic started successfully.");
std::this_thread::sleep_for(std::chrono::seconds(3));
return BT::NodeStatus::SUCCESS;
} else {
RCLCPP_ERROR(node_->get_logger(), "Failed to start publish topic: %s", command_.c_str());
return BT::NodeStatus::FAILURE;
}
}
private:
rclcpp::Node::SharedPtr node_;
std::string command_;
};
```Step 2. Registers the behavior tree node.
```cpp
#include "publish_topic.hpp"
factory.registerNodeType("PublishTopic");
```Step 3. Write execution flow.
```xml
```