@@ -14,6 +14,7 @@ target_link_libraries(ground_plane_segmentation ${catkin_LIBRARIES})
1414
1515#include < ros/ros.h>
1616#include " object_detection/boost.h"
17+ #include < visualization_msgs/Marker.h>
1718
1819// TF includes
1920#include < tf/tf.h>
@@ -57,6 +58,7 @@ ros::Publisher coef_pub;
5758ros::Publisher bbox_pub;
5859ros::Publisher template_pub;
5960ros::Publisher pose_pub;
61+ ros::Publisher marker_pub;
6062
6163// Globals
6264bool invert;
@@ -75,7 +77,7 @@ sensor_msgs::PointCloud2 template_msg;
7577tf::TransformListener *listener;
7678geometry_msgs::Pose pose_msg;
7779Eigen::Affine3d pose_transform;
78- double dimensions[3 ] ;
80+ double dimensions[] = { 0.1 , 0.02 , 0.02 } ;
7981double icp_fitness_score;
8082pcl::PCLPointCloud2::Ptr input_pcl (new pcl::PCLPointCloud2);
8183
@@ -90,6 +92,48 @@ bool ICP_SUCCESS = false;
9092bool FIRST = true ;
9193bool POSE_FLAG = false ;
9294
95+ void publish_grasp_marker (geometry_msgs::Pose& p)
96+ {
97+ visualization_msgs::Marker marker;
98+ // Set the frame ID and timestamp. See the TF tutorials for information on these.
99+ marker.header .frame_id = " camera_depth_optical_frame" ;
100+ marker.header .stamp = ros::Time::now ();
101+
102+ // Set the namespace and id for this marker
103+ marker.ns = " grasp_pose" ;
104+ marker.id = 0 ;
105+
106+ // Set the marker type. Initially this is CUBE, and cycles between that and SPHERE, ARROW, and CYLINDER
107+ marker.type = visualization_msgs::Marker::CUBE;
108+
109+ // Set the marker action. Options are ADD, DELETE, and new in ROS Indigo: 3 (DELETEALL)
110+ marker.action = visualization_msgs::Marker::ADD;
111+
112+ // Set the pose of the marker. This is a full 6DOF pose relative to the frame/time specified in the header
113+ marker.pose .position .x = p.position .x ;
114+ marker.pose .position .y = p.position .y ;
115+ marker.pose .position .z = p.position .z ;
116+ marker.pose .orientation .x = p.orientation .x ;
117+ marker.pose .orientation .y = p.orientation .y ;
118+ marker.pose .orientation .z = p.orientation .z ;
119+ marker.pose .orientation .w = p.orientation .w ;
120+
121+ // Set the scale of the marker -- 1x1x1 here means 1m on a side
122+ marker.scale .x = dimensions[0 ];
123+ marker.scale .y = dimensions[1 ];
124+ marker.scale .z = dimensions[2 ];
125+
126+ // Set the color -- be sure to set alpha to something non-zero!
127+ marker.color .r = 1 .0f ;
128+ marker.color .g = 0 .0f ;
129+ marker.color .b = 0 .0f ;
130+ marker.color .a = 0 .5f ;
131+
132+ // Publish the marker
133+ marker.lifetime = ros::Duration ();
134+ marker_pub.publish (marker);
135+ }
136+
93137void publish_pose (Eigen::Matrix4d H)
94138{
95139 // Set translation
@@ -119,6 +163,9 @@ void publish_pose(Eigen::Matrix4d H)
119163 p.orientation .z = quaternion.z ();
120164 p.orientation .w = quaternion.w ();
121165
166+ // Publish visualization marker
167+ publish_grasp_marker (p);
168+
122169 // Broadcast the transforms
123170 static tf::TransformBroadcaster br;
124171 br.sendTransform (tf::StampedTransform (transform, ros::Time::now (), " camera_depth_optical_frame" , " object_frame" ));
@@ -211,7 +258,7 @@ void pcl_callback(const sensor_msgs::PointCloud2ConstPtr& input)
211258 icp_pub.publish (output_msg);
212259 template_msg.header .frame_id = " camera_depth_optical_frame" ;
213260 template_pub.publish (template_msg);
214- publish_bounding_box (icp_transform);
261+ // publish_bounding_box(icp_transform);
215262 publish_pose (icp_transform);
216263 }
217264}
@@ -415,6 +462,7 @@ int main(int argc, char** argv)
415462 bbox_pub = nh.advertise <sensor_msgs::PointCloud2>(" /icp/bbox_points" , 1 );
416463 template_pub = nh.advertise <sensor_msgs::PointCloud2>(" /icp/template" , 1 );
417464 pose_pub = nh.advertise <geometry_msgs::Pose>(" /icp/pose" , 1 );
465+ marker_pub = nh.advertise <visualization_msgs::Marker>(" object_pose_detection/grasp_pose" , 1 );
418466
419467 // Spin
420468 ros::spin ();
0 commit comments