shape_tools.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 *
00003 *  Copyright (c) 2011, Willow Garage, Inc.
00004 *  All rights reserved.
00005 *
00006 *  Redistribution and use in source and binary forms, with or without
00007 *  modification, are permitted provided that the following conditions
00008 *  are met:
00009 *
00010 *   * Redistributions of source code must retain the above copyright
00011 *     notice, this list of conditions and the following disclaimer.
00012 *   * Redistributions in binary form must reproduce the above
00013 *     copyright notice, this list of conditions and the following
00014 *     disclaimer in the documentation and/or other materials provided
00015 *     with the distribution.
00016 *   * Neither the name of the Willow Garage nor the names of its
00017 *     contributors may be used to endorse or promote products derived
00018 *     from this software without specific prior written permission.
00019 *
00020 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031 *  POSSIBILITY OF SUCH DAMAGE.
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 } // namespace shapes
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 } // namespace object_manipulator
00191 
00192 #endif


object_manipulator
Author(s): Matei Ciocarlie and Kaijen Hsiao
autogenerated on Mon Oct 6 2014 02:59:50