Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include "jlo_topic_display.h"
00033 #include "rviz/properties/property.h"
00034 #include "rviz/properties/property_manager.h"
00035
00036 #include "rviz/common.h"
00037
00038 #include <sstream>
00039
00040 using namespace vision_srvs;
00041 namespace rviz_shows_cop
00042 {
00043
00044 JloTopicDisplay::JloTopicDisplay(const std::string & name,
00045 rviz::VisualizationManager * manager)
00046 : JloDisplayBase(name, manager),
00047 inited(false)
00048 {
00049 }
00050
00051 JloTopicDisplay::~JloTopicDisplay()
00052 {
00053 unsubscribe();
00054 }
00055
00056 void JloTopicDisplay::setTopic(const std::string & topic)
00057 {
00058 unsubscribe();
00059 JloDisplayBase::setTopic(topic);
00060 inited = false;
00061 subscribe();
00062 }
00063
00064
00065 void JloTopicDisplay::subscribe()
00066 {
00067 if (!isEnabled() || topic_.length() < 2)
00068 {
00069 m_binited = false;
00070 return;
00071 }
00072 m_binited = true;
00073 jlo_subscriber = update_nh_.subscribe<std_msgs::UInt32>(topic_,1, boost::bind(&JloTopicDisplay::incomingMessage, this, _1));
00074 }
00075
00076 void JloTopicDisplay::unsubscribe()
00077 {
00078 jlo_subscriber.shutdown();
00079 }
00080
00081 void JloTopicDisplay::incomingMessage (const std_msgs::UInt32ConstPtr& msg)
00082 {
00083 JloDisplayBase::JloDescription jlo_descr[1];
00084
00085 m_currMessage = msg;
00086 inited = true;
00087
00088 std::stringstream strm;
00089
00090 jlo_descr[0].pose = msg->data;
00091 strm << msg->data;
00092 jlo_descr[0].label = strm.str();
00093 try
00094 {
00095 displayJloSet(&jlo_descr[0], &jlo_descr[1]);
00096 }
00097 catch(...)
00098 {
00099 ROS_INFO("tf sucks, please start a state publisher or similar stuff\n");
00100 }
00101 }
00102
00103 void JloTopicDisplay::createProperties()
00104 {
00105
00106
00107 JloDisplayBase::createProperties();
00108
00109 topic_property_ = property_manager_->createProperty<rviz::ROSTopicStringProperty> ("Topic", property_prefix_, boost::bind(&JloDisplayBase::getTopic, this),
00110 boost::bind(&JloDisplayBase::setTopic, this, _1), parent_category_, this);
00111 rviz::ROSTopicStringPropertyPtr topic_prop = topic_property_.lock();
00112 topic_prop->setMessageType(std_msgs::UInt32::__s_getDataType());
00113
00114 }
00115
00116
00117 }