Go to the documentation of this file.00001
00060 #ifndef COB_VISION_UTILS_ROS_MSG_CONVERSIONS_H__
00061 #define COB_VISION_UTILS_ROS_MSG_CONVERSIONS_H__
00062
00063 #include <cob_object_detection_msgs/Detection.h>
00064 #include <visualization_msgs/Marker.h>
00065
00066 #include <Eigen/Geometry>
00067
00068 namespace cob_perception_common
00069 {
00070
00071
00072 inline void EigenToROSMsg(const Eigen::Vector3f& pt_eigen, geometry_msgs::Point& pt_msg)
00073 { pt_msg.x=pt_eigen[0]; pt_msg.y=pt_eigen[1]; pt_msg.z=pt_eigen[2]; }
00074
00075 inline void EigenToROSMsg(const Eigen::Quaternion<float>& q_eigen, geometry_msgs::Quaternion& q_msg)
00076 { q_msg.x=q_eigen.x(); q_msg.y=q_eigen.y(); q_msg.z=q_eigen.z(); q_msg.w=q_eigen.w(); }
00077
00078 inline void EigenToROSMsg(const Eigen::Vector3f& pt, const Eigen::Quaternion<float>& rot, geometry_msgs::Pose& pose)
00079 { EigenToROSMsg(pt, pose.position); EigenToROSMsg(rot, pose.orientation); }
00080
00081
00082
00083 inline void ROSMsgToEigen(const geometry_msgs::Point& pt_msg, Eigen::Vector3f& pt_eigen)
00084 { pt_eigen[0]=pt_msg.x; pt_eigen[1]=pt_msg.y; pt_eigen[2]=pt_msg.z; }
00085
00086 inline void ROSMsgToEigen(const geometry_msgs::Quaternion& q_msg, Eigen::Quaternion<float>& q_eigen)
00087 { q_eigen.x()=q_msg.x; q_eigen.y()=q_msg.y; q_eigen.z()=q_msg.z; q_eigen.w()=q_msg.w; }
00088
00089 inline void ROSMsgToEigen(const geometry_msgs::Pose& pose, Eigen::Vector3f& pt, Eigen::Quaternion<float>& rot)
00090 { ROSMsgToEigen(pose.position, pt); ROSMsgToEigen(pose.orientation, rot); }
00091
00092
00093
00094
00095 void boundingBoxToMarker(const cob_object_detection_msgs::Detection& bb, visualization_msgs::Marker& marker)
00096 {
00097 marker.action = visualization_msgs::Marker::ADD;
00098 marker.type = visualization_msgs::Marker::LINE_LIST;
00099 geometry_msgs::Point pt;
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 marker.points.resize(24);
00123 pt.x = bb.bounding_box_lwh.x;
00124 pt.y = bb.bounding_box_lwh.y;
00125 pt.z = 0;
00126
00127 marker.points[0]=marker.points[7]=marker.points[8] = pt;
00128
00129 pt.x = -bb.bounding_box_lwh.x;
00130 marker.points[1]=marker.points[2]=marker.points[10] = pt;
00131
00132 pt.y = -bb.bounding_box_lwh.y;
00133 marker.points[3]=marker.points[4]=marker.points[12] = pt;
00134
00135 pt.x = bb.bounding_box_lwh.x;
00136 marker.points[5]=marker.points[6]=marker.points[14] = pt;
00137
00138
00139 pt.y = bb.bounding_box_lwh.y;
00140 pt.z = bb.bounding_box_lwh.z;
00141
00142 marker.points[9]=marker.points[16]=marker.points[23] = pt;
00143
00144 pt.x = -bb.bounding_box_lwh.x;
00145 marker.points[11]=marker.points[17]=marker.points[18] = pt;
00146
00147 pt.y = -bb.bounding_box_lwh.y;
00148 marker.points[13]=marker.points[19]=marker.points[20] = pt;
00149
00150 pt.x = bb.bounding_box_lwh.x;
00151 marker.points[15]=marker.points[21]=marker.points[22] = pt;
00152
00153 marker.pose = bb.pose.pose;
00154
00155 marker.scale.x = 0.01;
00156 marker.color.r = 0;
00157 marker.color.g = 1;
00158 marker.color.b = 0;
00159 marker.color.a = 1.0;
00160 }
00161 }
00162
00163 #endif // COB_VISION_UTILS_ROS_MSG_CONVERSIONS_H__