transformable_object.h
Go to the documentation of this file.
00001 #ifndef __TRANSFORMABLE_OBJECT_H__
00002 #define __TRANSFORMABLE_OBJECT_H__
00003 
00004 #include <ros/ros.h>
00005 #include <visualization_msgs/Marker.h>
00006 #include <visualization_msgs/InteractiveMarker.h>
00007 #include <visualization_msgs/InteractiveMarkerControl.h>
00008 #include <std_msgs/Float32.h>
00009 #include <std_msgs/ColorRGBA.h>
00010 #include <tf/transform_broadcaster.h>
00011 #include <tf/transform_datatypes.h>
00012 #include <geometry_msgs/Point.h>
00013 #include <jsk_rviz_plugins/RequestMarkerOperate.h>
00014 #include <vector>
00015 #include <algorithm>
00016 #include <jsk_interactive_marker/InteractiveSettingConfig.h>
00017 
00018 namespace jsk_interactive_marker {
00019   class TransformableObject{
00020   public:
00021     TransformableObject();
00022 
00023     std::vector<visualization_msgs::InteractiveMarkerControl> makeRotateTransFixControl(unsigned int orientation_mode = visualization_msgs::InteractiveMarkerControl::FIXED);
00024 
00025     tf::TransformBroadcaster br;
00026     visualization_msgs::InteractiveMarker getInteractiveMarker();
00027     virtual visualization_msgs::Marker getVisualizationMsgMarker(){};
00028     void addMarker(visualization_msgs::InteractiveMarker &int_marker, bool always_visible = true, unsigned int interaction_mode = visualization_msgs::InteractiveMarkerControl::MOVE_3D);
00029     void addControl(visualization_msgs::InteractiveMarker &int_marker);
00030 
00031     visualization_msgs::Marker marker_;
00032     geometry_msgs::Pose pose_;
00033     geometry_msgs::Pose control_offset_pose_;
00034     std::string name_;
00035     std::string frame_id_;
00036     std::string description_;
00037     int type_;
00038     bool display_interactive_manipulator_;
00039     bool display_description_;
00040     int interactive_manipulator_orientation_;
00041     unsigned int interaction_mode_;
00042     
00043     void setPose(geometry_msgs::Pose pose, bool for_interactive_control=false);
00044     void addPose(geometry_msgs::Pose msg, bool relative=false);
00045     void publishTF();
00046     std::string getFrameId() { return frame_id_; }
00047     geometry_msgs::Pose getPose(bool for_interactive_control=false);
00048     void setDisplayInteractiveManipulator(bool v);
00049     void setDisplayDescription(bool v);
00050     void setInteractiveMarkerSetting(const InteractiveSettingConfig& config);
00051     virtual bool setRadius(std_msgs::Float32 recieve_val){return false;};
00052     virtual bool setSmallRadius(std_msgs::Float32 recieve_val){return false;};
00053     virtual bool setHeight(std_msgs::Float32 recieve_val){return false;};
00054     virtual bool setX(std_msgs::Float32 recieve_val){return false;};
00055     virtual bool setY(std_msgs::Float32 recieve_val){return false;};
00056     virtual bool setZ(std_msgs::Float32 recieve_val){return false;};
00057     virtual void setRGBA(float r , float g, float b, float a){};
00058     virtual void getRGBA(float &r , float &g, float &b, float &a){};
00059     virtual void setXYZ(float x , float y, float z){};
00060     virtual void getXYZ(float &x, float &y, float&z){};
00061     virtual void setRSR(float r , float sr){};
00062     virtual void getRSR(float &r , float &sr){};
00063     virtual void setRZ(float r , float z){};
00064     virtual void getRZ(float &r , float &z){};
00065 
00066     int getType() { return type_; };
00067     void setType(int type) { type_ = type; return; };
00068 
00069     virtual float getInteractiveMarkerScale(){};
00070   };
00071 };
00072 
00073 namespace jsk_interactive_marker
00074 {
00075   class TransformableBox: public TransformableObject
00076   {
00077   public:
00078     TransformableBox( float length , float r, float g, float b, float a, std::string frame, std::string name, std::string description);
00079 
00080     TransformableBox( float x, float y, float z, float r, float g, float b, float a, std::string frame, std::string name, std::string description);
00081 
00082     visualization_msgs::Marker getVisualizationMsgMarker();
00083     void setRGBA( float r , float g, float b, float a){box_r_=r;box_g_=g;box_b_=b;box_a_=a;};
00084     void getRGBA(float &r , float &g, float &b, float &a){r=box_r_;g=box_g_;b=box_b_;a=box_a_;}
00085     void setXYZ( float x , float y, float z){box_x_=x;box_y_=y;box_z_=z;};
00086     void getXYZ(float &x, float &y, float&z){x=box_x_;y=box_y_;z=box_z_;};
00087 
00088     bool setX(std_msgs::Float32 x){box_x_=x.data;return true;};
00089     bool setY(std_msgs::Float32 y){box_y_=y.data;return true;};
00090     bool setZ(std_msgs::Float32 z){box_z_=z.data;return true;};
00091 
00092     float getInteractiveMarkerScale(){return 1.25*std::max(std::max(box_x_, box_y_),box_z_);};
00093 
00094     float box_x_;
00095     float box_y_;
00096     float box_z_;
00097     float box_r_;
00098     float box_g_;
00099     float box_b_;
00100     float box_a_;
00101   };
00102 };
00103 
00104 namespace jsk_interactive_marker
00105 {
00106   class TransformableMesh: public TransformableObject
00107   {
00108   public:
00109     TransformableMesh(std::string frame, std::string name, std::string description, std::string mesh_resource, bool mesh_use_embedded_materials);
00110     visualization_msgs::Marker getVisualizationMsgMarker();
00111     void setRGBA( float r , float g, float b, float a){mesh_r_=r;mesh_g_=g;mesh_b_=b;mesh_a_=a;};
00112     void getRGBA(float &r , float &g, float &b, float &a){r=mesh_r_;g=mesh_g_;b=mesh_b_;a=mesh_a_;};
00113     void setXYZ( float x , float y, float z){marker_scale_=x; return;};
00114     void getXYZ(float &x, float &y, float&z){return;};
00115     bool setX(std_msgs::Float32 x){marker_scale_=x.data; return true;};
00116     bool setY(std_msgs::Float32 y){return true;};
00117     bool setZ(std_msgs::Float32 z){return true;};
00118     float getInteractiveMarkerScale(){return marker_scale_;};
00119     float marker_scale_;
00120     std::string mesh_resource_;
00121     bool mesh_use_embedded_materials_;
00122     float mesh_r_;
00123     float mesh_g_;
00124     float mesh_b_;
00125     float mesh_a_;
00126   };
00127 };
00128 
00129 namespace jsk_interactive_marker
00130 {
00131   class TransformableTorus: public TransformableObject
00132   {
00133   public:
00134     TransformableTorus( float radius, float small_radius, int u_div, int v_div, float r, float g, float b, float a, std::string frame, std::string name, std::string description);
00135 
00136     visualization_msgs::Marker getVisualizationMsgMarker();
00137     void setRGBA( float r , float g, float b, float a){torus_r_=r;torus_g_=g;torus_b_=b;torus_a_=a;};
00138     void getRGBA(float &r , float &g, float &b, float &a){r=torus_r_;g=torus_g_;b=torus_b_;a=torus_a_;}
00139     void setRSR( float r , float sr){torus_radius_=r; torus_small_radius_=sr;};
00140     void getRSR(float &r , float &sr){r=torus_radius_; sr=torus_small_radius_;};
00141 
00142     bool setRadius(std_msgs::Float32 r){torus_radius_=r.data;return true;};
00143     bool setSmallRadius(std_msgs::Float32 sr){torus_small_radius_=sr.data;return true;};
00144 
00145     std::vector<geometry_msgs::Point > calcurateTriangleMesh();
00146 
00147     float getInteractiveMarkerScale(){return (torus_radius_+torus_small_radius_+1);};
00148 
00149     float torus_radius_;
00150     float torus_small_radius_;
00151     float torus_r_;
00152     float torus_g_;
00153     float torus_b_;
00154     float torus_a_;
00155 
00156     int u_division_num_;
00157     int v_division_num_;
00158   };
00159 };
00160 
00161 namespace jsk_interactive_marker
00162 {
00163   class TransformableCylinder: public TransformableObject
00164   {
00165   public:
00166     TransformableCylinder( float radius, float z, float r, float g, float b, float a, std::string frame, std::string name, std::string description);
00167 
00168     visualization_msgs::Marker getVisualizationMsgMarker();
00169     void setRGBA( float r , float g, float b, float a){cylinder_r_=r;cylinder_g_=g;cylinder_b_=b;cylinder_a_=a;};
00170     void getRGBA(float &r , float &g, float &b, float &a){r=cylinder_r_;g=cylinder_g_;b=cylinder_b_;a=cylinder_a_;}
00171     void setRZ( float r , float z){cylinder_radius_=r; cylinder_z_=z;};
00172     void getRZ(float &r , float &z){r=cylinder_radius_; z=cylinder_z_;};
00173 
00174     bool setRadius(std_msgs::Float32 r){cylinder_radius_=r.data;return true;};
00175     bool setZ(std_msgs::Float32 z){cylinder_z_=z.data;return true;};
00176 
00177     float getInteractiveMarkerScale(){return 1.25*std::max(cylinder_radius_, cylinder_z_);};
00178 
00179     float cylinder_radius_;
00180     float cylinder_z_;
00181     float cylinder_r_;
00182     float cylinder_g_;
00183     float cylinder_b_;
00184     float cylinder_a_;
00185   };
00186 };
00187 
00188 #endif


jsk_interactive_marker
Author(s): furuta
autogenerated on Wed May 1 2019 02:40:31