|
6 | 6 | #include <math.h> |
7 | 7 | #include <visualization_msgs/MarkerArray.h> |
8 | 8 | #include "geometry_utils.h" |
| 9 | +#include <geometry_msgs/TransformStamped.h> |
9 | 10 |
|
10 | 11 |
|
11 | 12 | geometry_msgs::Vector3 fromCvVector(cv::Vec3d cv_vector){ |
@@ -43,7 +44,8 @@ EOD_ROS::EOD_ROS(ros::NodeHandle nh, ros::NodeHandle nh_p){ |
43 | 44 | nh_p_.param("publish_image_output", publish_image_output, false); |
44 | 45 | nh_p_.param("use_actual_time", use_actual_time, false); |
45 | 46 | nh_p_.param("publish_markers", publish_markers, false); |
46 | | - |
| 47 | + nh_p_.param("broadcast_tf", broadcast_tf, false); |
| 48 | + |
47 | 49 | std::string object_base_path; |
48 | 50 | nh_p_.getParam("object_base",object_base_path); |
49 | 51 |
|
@@ -259,6 +261,33 @@ void EOD_ROS::detect(const eod::InfoImage& rgb, const eod::InfoImage& depth, std |
259 | 261 | complex_objects_pub_.publish(complex_msg); |
260 | 262 | #endif |
261 | 263 |
|
| 264 | + if(broadcast_tf){ |
| 265 | + geometry_msgs::TransformStamped trsfrm; |
| 266 | + trsfrm.header = header; |
| 267 | + int id = 0; |
| 268 | + std::string prev_name = ""; |
| 269 | + for( auto& bo : simples_msg.objects){ |
| 270 | + if( prev_name != bo.type_name) |
| 271 | + id = 0; |
| 272 | + trsfrm.child_frame_id = bo.type_name + "_" + std::to_string(id); |
| 273 | + trsfrm.transform = bo.transform; |
| 274 | + transform_broadcaster_.sendTransform(trsfrm); |
| 275 | + id++; |
| 276 | + prev_name = bo.type_name; |
| 277 | + } |
| 278 | +#ifdef USE_IGRAPH |
| 279 | + for( auto& cbo : complex_msg.objects){ |
| 280 | + if( prev_name != cbo.complex_object.type_name) |
| 281 | + id = 0; |
| 282 | + trsfrm.child_frame_id = cbo.complex_object.type_name + "_" + std::to_string(id); |
| 283 | + trsfrm.transform = cbo.complex_object.transform; |
| 284 | + transform_broadcaster_.sendTransform(trsfrm); |
| 285 | + id++; |
| 286 | + prev_name = cbo.complex_object.type_name; |
| 287 | + } |
| 288 | +#endif |
| 289 | + } |
| 290 | + |
262 | 291 | if(publish_markers){ |
263 | 292 | visualization_msgs::MarkerArray mrk_array_msg; |
264 | 293 | int id_cnt = 0; |
@@ -293,7 +322,6 @@ void EOD_ROS::detect(const eod::InfoImage& rgb, const eod::InfoImage& depth, std |
293 | 322 | frame_sequence++; |
294 | 323 | } |
295 | 324 |
|
296 | | - |
297 | 325 | extended_object_detection::BaseObject EOD_ROS::eoi_to_base_object( std::string name, int id, eod::ExtendedObjectInfo* eoi, const cv::Mat& K){ |
298 | 326 | //ROS_INFO("Forming..."); |
299 | 327 | extended_object_detection::BaseObject bo; |
|
0 commit comments