$search
00001 /* 00002 * Copyright (c) 2008, Willow Garage, Inc. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Neither the name of the Willow Garage, Inc. nor the names of its 00014 * contributors may be used to endorse or promote products derived from 00015 * this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00030 00031 #ifndef RVIZ_POSE_DISPLAY_H_ 00032 #define RVIZ_POSE_DISPLAY_H_ 00033 00034 #include "rviz/display.h" 00035 #include "rviz/helpers/color.h" 00036 #include "rviz/properties/forwards.h" 00037 #include "rviz/selection/forwards.h" 00038 00039 #include <geometry_msgs/PoseStamped.h> 00040 00041 #include <boost/shared_ptr.hpp> 00042 #include <boost/thread/mutex.hpp> 00043 00044 #include <message_filters/subscriber.h> 00045 #include <tf/message_filter.h> 00046 00047 namespace ogre_tools 00048 { 00049 class Arrow; 00050 class Axes; 00051 class Shape; 00052 } 00053 00054 namespace Ogre 00055 { 00056 class SceneNode; 00057 } 00058 00059 namespace rviz 00060 { 00061 00062 class PoseDisplaySelectionHandler; 00063 typedef boost::shared_ptr<PoseDisplaySelectionHandler> PoseDisplaySelectionHandlerPtr; 00064 00069 class PoseDisplay : public Display 00070 { 00071 public: 00072 enum Shape 00073 { 00074 Arrow, 00075 Axes, 00076 }; 00077 00078 PoseDisplay( const std::string& name, VisualizationManager* manager ); 00079 virtual ~PoseDisplay(); 00080 00081 void setTopic( const std::string& topic ); 00082 const std::string& getTopic() { return topic_; } 00083 00084 void setColor( const Color& color ); 00085 const Color& getColor() { return color_; } 00086 00087 void setShape(int shape); 00088 int getShape() { return current_shape_; } 00089 00090 void setAlpha(float a); 00091 float getAlpha() { return alpha_; } 00092 00093 // arrow-specific setters/getters 00094 void setHeadRadius(float r); 00095 float getHeadRadius() { return head_radius_; } 00096 void setHeadLength(float l); 00097 float getHeadLength() { return head_length_; } 00098 void setShaftRadius(float r); 00099 float getShaftRadius() { return shaft_radius_; } 00100 void setShaftLength(float l); 00101 float getShaftLength() { return shaft_length_; } 00102 00103 // axes-specific setters/getters 00104 void setAxesRadius(float r); 00105 float getAxesRadius() { return axes_radius_; } 00106 void setAxesLength(float l); 00107 float getAxesLength() { return axes_length_; } 00108 00109 // Overrides from Display 00110 virtual void targetFrameChanged(); 00111 virtual void fixedFrameChanged(); 00112 virtual void createProperties(); 00113 virtual void update(float wall_dt, float ros_dt); 00114 virtual void reset(); 00115 00116 protected: 00117 void subscribe(); 00118 void unsubscribe(); 00119 void clear(); 00120 00121 void createShapeProperties(); 00122 void setVisibility(); 00123 00124 void incomingMessage( const geometry_msgs::PoseStamped::ConstPtr& message ); 00125 00126 // overrides from Display 00127 virtual void onEnable(); 00128 virtual void onDisable(); 00129 00130 std::string topic_; 00131 Color color_; 00132 float alpha_; 00133 Shape current_shape_; 00134 00135 // arrow-specific values 00136 float head_radius_; 00137 float head_length_; 00138 float shaft_radius_; 00139 float shaft_length_; 00140 00141 // axes-specific values 00142 float axes_length_; 00143 float axes_radius_; 00144 00145 ogre_tools::Arrow* arrow_; 00146 ogre_tools::Axes* axes_; 00147 CollObjectHandle coll_; 00148 PoseDisplaySelectionHandlerPtr coll_handler_; 00149 00150 uint32_t messages_received_; 00151 00152 Ogre::SceneNode* scene_node_; 00153 00154 message_filters::Subscriber<geometry_msgs::PoseStamped> sub_; 00155 tf::MessageFilter<geometry_msgs::PoseStamped> tf_filter_; 00156 geometry_msgs::PoseStampedConstPtr latest_message_; 00157 00158 ROSTopicStringPropertyWPtr topic_property_; 00159 EnumPropertyWPtr shape_property_; 00160 CategoryPropertyWPtr shape_category_; 00161 00162 ColorPropertyWPtr color_property_; 00163 FloatPropertyWPtr alpha_property_; 00164 00165 FloatPropertyWPtr head_radius_property_; 00166 FloatPropertyWPtr head_length_property_; 00167 FloatPropertyWPtr shaft_radius_property_; 00168 FloatPropertyWPtr shaft_length_property_; 00169 00170 FloatPropertyWPtr axes_length_property_; 00171 FloatPropertyWPtr axes_radius_property_; 00172 }; 00173 00174 } // namespace rviz 00175 00176 #endif /* RVIZ_POSE_DISPLAY_H_ */