point_display.h
Go to the documentation of this file.
00001 #ifndef POINT_DISPLAY_H
00002 #define POINT_DISPLAY_H
00003 
00004 #include <message_filters/subscriber.h>
00005 #include <geometry_msgs/PointStamped.h>
00006 #include <rviz/display.h>
00007 
00008 namespace Ogre
00009 {
00010     class SceneNode;
00011 }
00012 
00013 namespace jsk_rviz_plugin
00014 {
00015 
00016     class PointStampedDisplay: public rviz::Display
00017     {
00018     public:
00019         // Constructor.  pluginlib::ClassLoader creates instances by calling
00020         // the default constructor, so make sure you have one.
00021         PointStampedDisplay();
00022         virtual ~PointStampedDisplay();
00023 
00024         // Overrides of public virtual functions from the Display class.
00025         virtual void onInitialize();
00026         virtual void fixedFrameChanged();
00027         virtual void reset();
00028         virtual void createProperties();
00029 
00030         // Setter and getter functions for user-editable properties.
00031         void setTopic(const std::string& topic);
00032         const std::string& getTopic() { return topic_; }
00033 
00034         void setColor( const rviz::Color& color );
00035         const rviz::Color& getColor() { return color_; }
00036 
00037         void setAlpha( float alpha );
00038         float getAlpha() { return alpha_; }
00039 
00040         void setRadius( float radius );
00041         float getRadius() { return radius_; }
00042 
00043         void setHistoryLength( int history_length );
00044         int getHistoryLength() const { return history_length_; }
00045 
00046         // Overrides of protected virtual functions from Display.  As much
00047         // as possible, when Displays are not enabled, they should not be
00048         // subscribed to incoming data and should not show anything in the
00049         // 3D view.  These functions are where these connections are made
00050         // and broken.
00051     protected:
00052         virtual void onEnable();
00053         virtual void onDisable();
00054 
00055         // Function to handle an incoming ROS message.
00056     private:
00057         void incomingMessage( const geometry_msgs::PointStamped::ConstPtr& msg );
00058 
00059         // Internal helpers which do the work of subscribing and
00060         // unsubscribing from the ROS topic.
00061         void subscribe();
00062         void unsubscribe();
00063 
00064         // A helper to clear this display back to the initial state.
00065         void clear();
00066 
00067         // Helper function to apply color and alpha to all visuals.
00068         void updateColorAndAlpha();
00069 
00070         // Storage for the list of visuals par each joint intem
00071         typedef std::vector<PointStampedVisual*> MapPointStampedVisual;
00072         MapPointStampedVisual visuals_;
00073 
00074         // A node in the Ogre scene tree to be the parent of all our visuals.
00075         Ogre::SceneNode* scene_node_;
00076 
00077         // Data input: Subscriber and tf message filter.
00078         message_filters::Subscriber<geometry_msgs::PointStamped> sub_;
00079         tf::MessageFilter<geometry_msgs::PointStamped>* tf_filter_;
00080         int messages_received_;
00081 
00082         // User-editable property variables.
00083         rviz::Color color_;
00084         std::string topic_;
00085         float alpha_, radius_;
00086         int history_length_;
00087 
00088         // Property objects for user-editable properties.
00089         rviz::ColorPropertyWPtr color_property_;
00090         rviz::ROSTopicStringPropertyWPtr topic_property_;
00091         rviz::FloatPropertyWPtr alpha_property_, radius_property_;
00092         rviz::IntPropertyWPtr history_length_property_;
00093 
00094     };
00095 } // end namespace rviz_plugin_tutorials
00096 
00097 #endif // POINT_DISPLAY_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


jsk_rviz_plugins
Author(s): Kei Okada
autogenerated on Sat Mar 23 2013 20:30:29