From b3ea552cfb50f62f1e45f27b4fc30612d9dd4eaf Mon Sep 17 00:00:00 2001
From: Pimpest <82343504+pimpest@users.noreply.github.com>
Date: Fri, 17 Apr 2026 12:42:39 +0200
Subject: [PATCH] Strategy blue part 1
---
toid_bt/behavior_trees/behavior1.xml | 113 +++++++++++++++++-
.../toid_bt/plugins/translate_x_action.hpp | 17 ++-
toid_bt/src/bt_executor.cpp | 2 +-
3 files changed, 126 insertions(+), 6 deletions(-)
diff --git a/toid_bt/behavior_trees/behavior1.xml b/toid_bt/behavior_trees/behavior1.xml
index 868ff06..d9b071a 100644
--- a/toid_bt/behavior_trees/behavior1.xml
+++ b/toid_bt/behavior_trees/behavior1.xml
@@ -1,5 +1,9 @@
+
+
+
+
@@ -48,6 +52,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -116,10 +197,40 @@
Service name
+
+ Y position in meters
+ Heading in degrees
+ Reference frame
+ X position in meters
+ Topic name
+
+
+
+
+ Action server name
+
+
+ Action server name
+
Service name
-
\ No newline at end of file
+
diff --git a/toid_bt/include/toid_bt/plugins/translate_x_action.hpp b/toid_bt/include/toid_bt/plugins/translate_x_action.hpp
index 8ec9f6c..fe41c10 100644
--- a/toid_bt/include/toid_bt/plugins/translate_x_action.hpp
+++ b/toid_bt/include/toid_bt/plugins/translate_x_action.hpp
@@ -5,18 +5,18 @@
#include "tf2/utils.hpp"
#include "tf2_geometry_msgs/tf2_geometry_msgs.hpp"
#include "toid_bt/plugin.hpp"
-#include "toid_msgs/action/simple_translate_x.hpp"
+#include "toid_msgs/action/simple_move_coords.hpp"
namespace toid
{
-class TranslateXNode : public BT::RosActionNode
+class TranslateXNode : public BT::RosActionNode
{
public:
TranslateXNode(
const std::string & name, const BT::NodeConfig & conf, const BT::RosNodeParams & params,
PoseFunc pose)
- : BT::RosActionNode(name, conf, params), get_pose(pose)
+ : BT::RosActionNode(name, conf, params), get_pose(pose)
{
}
@@ -34,7 +34,16 @@ public:
auto x_goal = getInput("x").value();
auto max_speed = getInput("max_speed").value();
- goal.distance = x_goal;
+ geometry_msgs::msg::PoseStamped pose;
+ get_pose(pose);
+
+ double yaw = tf2::getYaw(pose.pose.orientation);
+
+ goal.x = pose.pose.position.x + cos(yaw) * x_goal;
+ goal.y = pose.pose.position.y + sin(yaw) * x_goal;
+ goal.theta = yaw;
+ goal.backwards = x_goal < 0;
+ goal.mode = 1;
goal.max_speed = max_speed;
return true;
diff --git a/toid_bt/src/bt_executor.cpp b/toid_bt/src/bt_executor.cpp
index ff50348..a52ee36 100644
--- a/toid_bt/src/bt_executor.cpp
+++ b/toid_bt/src/bt_executor.cpp
@@ -75,7 +75,7 @@ void TreeExecutor::registerNodesIntoFactory(BT::BehaviorTreeFactory & factory)
"RotateTowards", BT::RosNodeParams(nh, "/rotate"), get_pose);
factory.registerNodeType(
- "TranslateX", BT::RosNodeParams(nh, "/translateX"), get_pose);
+ "TranslateX", BT::RosNodeParams(nh, "/moveCoords"), get_pose);
factory.registerNodeType(
"SetWidth", BT::RosNodeParams(nh, "/set_width"), get_pose);