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 Arrow
00122 {
00123 public:
00124 Arrow(){ }
00125
00126 Arrow(const tf::Pose &frame_in, const tf::Vector3 &dims_in) : frame(frame_in), dims(dims_in) {}
00127
00128 Arrow(const tf::Vector3 &dims_in) : 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 tf::Pose frame;
00134 tf::Vector3 dims;
00135 };
00136
00143 class Mesh
00144 {
00145 public:
00146 Mesh(){ }
00147
00148 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) {}
00149
00150 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) {}
00151
00152 inline void transform(const tf::Transform &T) { frame = T * frame; }
00153
00154 std_msgs::Header header;
00155 std::string mesh_resource;
00156 bool use_embedded_materials;
00157 tf::Pose frame;
00158 tf::Vector3 dims;
00159
00160 };
00161
00162 }
00163
00164
00165 void drawCylinder(ros::Publisher &pub, const shapes::Cylinder &shape, const char *ns = "cylinder",
00166 int id = 0, const ros::Duration lifetime = ros::Duration(),
00167 const std_msgs::ColorRGBA color = msg::createColorMsg(0.5, 0.5, 0.5, 0.5),
00168 bool destroy = false, bool frame_locked = false);
00169
00170 void drawBox(ros::Publisher &pub, const shapes::Box &shape, const char *ns = "box",
00171 int id = 0, const ros::Duration lifetime = ros::Duration(),
00172 const std_msgs::ColorRGBA color = msg::createColorMsg(0.5, 0.5, 0.5, 0.5),
00173 bool destroy = false, bool frame_locked = false);
00174
00175 void drawSphere(ros::Publisher &pub, const shapes::Sphere &shape, const char *ns = "sphere",
00176 int id = 0, const ros::Duration lifetime = ros::Duration(),
00177 const std_msgs::ColorRGBA color = msg::createColorMsg(0.5, 0.5, 0.5, 0.5),
00178 bool destroy = false, bool frame_locked = false);
00179
00180 void drawArrow(ros::Publisher &pub, const shapes::Arrow &shape, const char *ns = "arrow",
00181 int id = 0, const ros::Duration lifetime = ros::Duration(),
00182 const std_msgs::ColorRGBA color = msg::createColorMsg(0.5, 0.5, 0.5, 0.5),
00183 bool destroy = false, bool frame_locked = false);
00184
00185 void drawMesh (ros::Publisher &pub, const shapes::Mesh &shape, const char *ns = "mesh",
00186 int id = 0, const ros::Duration lifetime = ros::Duration(),
00187 const std_msgs::ColorRGBA color = msg::createColorMsg(0.5, 0.5, 0.5, 0.5),
00188 bool destroy = false, bool frame_locked = false);
00189
00190 }
00191
00192 #endif