00001 #include "articulation_display.h" 00002 #include "rviz/common.h" 00003 #include "rviz/visualization_manager.h" 00004 #include "rviz/robot/robot.h" 00005 #include "rviz/robot/link_updater.h" 00006 #include "rviz/properties/property.h" 00007 #include "rviz/properties/property_manager.h" 00008 00009 #include <ogre_tools/axes.h> 00010 00011 #include <tf/transform_listener.h> 00012 #include <OGRE/OgreSceneNode.h> 00013 #include <OGRE/OgreSceneManager.h> 00014 00015 namespace articulation_rviz_plugin { 00016 00017 TrackDisplay::TrackDisplay(const std::string& name, 00018 rviz::VisualizationManager* manager) : 00019 Display(name, manager) { 00020 } 00021 00022 TrackDisplay::~TrackDisplay() { 00023 unsubscribe(); 00024 } 00025 00026 void TrackDisplay::setTopic(const std::string& topic) { 00027 unsubscribe(); 00028 track_topic_ = topic; 00029 subscribe(); 00030 00031 propertyChanged(topic_property_); 00032 } 00033 00034 void TrackDisplay::onEnable() { 00035 subscribe(); 00036 } 00037 00038 void TrackDisplay::onDisable() { 00039 unsubscribe(); 00040 } 00041 00042 void TrackDisplay::subscribe() { 00043 if (!isEnabled()) { 00044 return; 00045 } 00046 00047 if (!track_topic_.empty()) { 00048 sub_ = update_nh_.subscribe(track_topic_, 2, 00049 &TrackDisplay::incomingTrack, this); 00050 } 00051 00052 } 00053 00054 void TrackDisplay::unsubscribe() { 00055 sub_.shutdown(); 00056 } 00057 00058 void TrackDisplay::update(float wall_dt, float ros_dt) { 00059 } 00060 00061 void TrackDisplay::incomingTrack( 00062 const articulation_models::TrackMsg::ConstPtr& msg) { 00063 incoming_track_message_ = msg; 00064 } 00065 00066 void TrackDisplay::targetFrameChanged() { 00067 } 00068 00069 void TrackDisplay::createProperties() { 00070 topic_property_ = property_manager_->createProperty< 00071 rviz::ROSTopicStringProperty> ("Topic", property_prefix_, 00072 boost::bind(&TrackDisplay::getTopic, this), boost::bind( 00073 &TrackDisplay::setTopic, this, _1), parent_category_, this); 00074 rviz::ROSTopicStringPropertyPtr topic_prop = topic_property_.lock(); 00075 topic_prop->setMessageType(articulation_models::TrackMsg::__s_getDataType()); 00076 } 00077 00078 } 00079