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