23
23
#include " rclcpp/node.hpp"
24
24
#include " behaviortree_cpp/behavior_tree.h"
25
25
#include " geometry_msgs/msg/point.hpp"
26
- #include " geometry_msgs/msg/quaternion.hpp"
27
26
#include " geometry_msgs/msg/pose_stamped.hpp"
27
+ #include " geometry_msgs/msg/pose_stamped_array.hpp"
28
+ #include " geometry_msgs/msg/quaternion.hpp"
28
29
#include " nav_msgs/msg/path.hpp"
29
30
30
31
namespace BT
@@ -112,7 +113,6 @@ inline geometry_msgs::msg::PoseStamped convertFromString(const StringView key)
112
113
template <>
113
114
inline std::vector<geometry_msgs::msg::PoseStamped> convertFromString (const StringView key)
114
115
{
115
- // 9 real numbers separated by semicolons
116
116
auto parts = BT::splitString (key, ' ;' );
117
117
if (parts.size () % 9 != 0 ) {
118
118
throw std::runtime_error (" invalid number of fields for std::vector<PoseStamped> attribute)" );
@@ -135,6 +135,38 @@ inline std::vector<geometry_msgs::msg::PoseStamped> convertFromString(const Stri
135
135
}
136
136
}
137
137
138
+ /* *
139
+ * @brief Parse XML string to geometry_msgs::msg::PoseStampedArray
140
+ * @param key XML string
141
+ * @return geometry_msgs::msg::PoseStampedArray
142
+ */
143
+ template <>
144
+ inline geometry_msgs::msg::PoseStampedArray convertFromString (const StringView key)
145
+ {
146
+ auto parts = BT::splitString (key, ' ;' );
147
+ if ((parts.size () - 2 ) % 9 != 0 ) {
148
+ throw std::runtime_error (" invalid number of fields for PoseStampedArray attribute)" );
149
+ } else {
150
+ geometry_msgs::msg::PoseStampedArray pose_stamped_array;
151
+ pose_stamped_array.header .stamp = rclcpp::Time (BT::convertFromString<int64_t >(parts[0 ]));
152
+ pose_stamped_array.header .frame_id = BT::convertFromString<std::string>(parts[1 ]);
153
+ for (size_t i = 2 ; i < parts.size (); i += 9 ) {
154
+ geometry_msgs::msg::PoseStamped pose_stamped;
155
+ pose_stamped.header .stamp = rclcpp::Time (BT::convertFromString<int64_t >(parts[i]));
156
+ pose_stamped.header .frame_id = BT::convertFromString<std::string>(parts[i + 1 ]);
157
+ pose_stamped.pose .position .x = BT::convertFromString<double >(parts[i + 2 ]);
158
+ pose_stamped.pose .position .y = BT::convertFromString<double >(parts[i + 3 ]);
159
+ pose_stamped.pose .position .z = BT::convertFromString<double >(parts[i + 4 ]);
160
+ pose_stamped.pose .orientation .x = BT::convertFromString<double >(parts[i + 5 ]);
161
+ pose_stamped.pose .orientation .y = BT::convertFromString<double >(parts[i + 6 ]);
162
+ pose_stamped.pose .orientation .z = BT::convertFromString<double >(parts[i + 7 ]);
163
+ pose_stamped.pose .orientation .w = BT::convertFromString<double >(parts[i + 8 ]);
164
+ pose_stamped_array.poses .push_back (pose_stamped);
165
+ }
166
+ return pose_stamped_array;
167
+ }
168
+ }
169
+
138
170
/* *
139
171
* @brief Parse XML string to nav_msgs::msg::Path
140
172
* @param key XML string
@@ -143,7 +175,6 @@ inline std::vector<geometry_msgs::msg::PoseStamped> convertFromString(const Stri
143
175
template <>
144
176
inline nav_msgs::msg::Path convertFromString (const StringView key)
145
177
{
146
- // 9 real numbers separated by semicolons
147
178
auto parts = BT::splitString (key, ' ;' );
148
179
if ((parts.size () - 2 ) % 9 != 0 ) {
149
180
throw std::runtime_error (" invalid number of fields for Path attribute)" );
0 commit comments