00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef _SHAPE_TOOLS_H_
00035 #define _SHAPE_TOOLS_H_
00036
00037 #include <ros/ros.h>
00038 #include <tf/tf.h>
00039
00040 #include "object_manipulator/tools/msg_helpers.h"
00041
00042
00043 namespace object_manipulator
00044 {
00045
00046 namespace shapes
00047 {
00048
00055 class Box
00056 {
00057 public:
00058 Box(){ }
00059
00060 Box(const tf::Pose &frame_in, const tf::Vector3 &dims_in) : frame(frame_in), dims(dims_in) {}
00061
00062 Box(const tf::Vector3 &dims_in) : frame(tf::Pose(tf::Quaternion(0,0,0,1), tf::Vector3(0,0,0))), dims(dims_in) {}
00063
00064 inline void transform(const tf::Transform &T) { frame = T * frame; }
00065
00066 std_msgs::Header header;
00067 tf::Pose frame;
00068 tf::Vector3 dims;
00069 };
00070
00077 class Cylinder
00078 {
00079 public:
00080 Cylinder(){ }
00081
00082 Cylinder(const tf::Pose &frame_in, const tf::Vector3 &dims_in) : frame(frame_in), dims(dims_in) {}
00083
00084 Cylinder(const tf::Vector3 &dims_in) : frame(tf::Pose(tf::Quaternion(0,0,0,1), tf::Vector3(0,0,0))), dims(dims_in) {}
00085
00086 inline void transform(const tf::Transform &T) { frame = T * frame; }
00087
00088 std_msgs::Header header;
00089 tf::Pose frame;
00090 tf::Vector3 dims;
00091 };
00092
00099 class Sphere
00100 {
00101 public:
00102 Sphere(){ }
00103
00104 Sphere(const tf::Pose &frame_in, const tf::Vector3 &dims_in) : frame(frame_in), dims(dims_in) {}
00105
00106 Sphere(const tf::Vector3 &dims_in) : frame(tf::Pose(tf::Quaternion(0,0,0,1), tf::Vector3(0,0,0))), dims(dims_in) {}
00107
00108 inline void transform(const tf::Transform &T) { frame = T * frame; }
00109
00110 std_msgs::Header header;
00111 tf::Pose frame;
00112 tf::Vector3 dims;
00113 };
00114
00121 class Mesh
00122 {
00123 public:
00124 Mesh(){ }
00125
00126 Mesh(const char * mesh_source, const tf::Pose &frame_in, const tf::Vector3 &dims_in) : mesh_resource(mesh_source), frame(frame_in), dims(dims_in) {}
00127
00128 Mesh(const char * mesh_source, const tf::Vector3 &dims_in) : mesh_resource(mesh_source), frame(tf::Pose(tf::Quaternion(0,0,0,1), tf::Vector3(0,0,0))), dims(dims_in) {}
00129
00130 inline void transform(const tf::Transform &T) { frame = T * frame; }
00131
00132 std_msgs::Header header;
00133 std::string mesh_resource;
00134 bool use_embedded_materials;
00135 tf::Pose frame;
00136 tf::Vector3 dims;
00137
00138 };
00139
00140 }
00141
00142
00143 void drawCylinder(ros::Publisher &pub, const shapes::Cylinder &shape, const char *ns = "cylinder",
00144 int id = 0, const ros::Duration lifetime = ros::Duration(),
00145 const std_msgs::ColorRGBA color = msg::createColorMsg(0.5, 0.5, 0.5, 0.5),
00146 bool destroy = false, bool frame_locked = false);
00147
00148 void drawBox(ros::Publisher &pub, const shapes::Box &shape, const char *ns = "box",
00149 int id = 0, const ros::Duration lifetime = ros::Duration(),
00150 const std_msgs::ColorRGBA color = msg::createColorMsg(0.5, 0.5, 0.5, 0.5),
00151 bool destroy = false, bool frame_locked = false);
00152
00153 void drawSphere(ros::Publisher &pub, const shapes::Sphere &shape, const char *ns = "sphere",
00154 int id = 0, const ros::Duration lifetime = ros::Duration(),
00155 const std_msgs::ColorRGBA color = msg::createColorMsg(0.5, 0.5, 0.5, 0.5),
00156 bool destroy = false, bool frame_locked = false);
00157
00158 void drawMesh (ros::Publisher &pub, const shapes::Mesh &shape, const char *ns = "mesh",
00159 int id = 0, const ros::Duration lifetime = ros::Duration(),
00160 const std_msgs::ColorRGBA color = msg::createColorMsg(0.5, 0.5, 0.5, 0.5),
00161 bool destroy = false, bool frame_locked = false);
00162
00163 }
00164
00165 #endif