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 #include "point_cloud_display.h"
00031 #include "rviz/common.h"
00032 #include "rviz/visualization_manager.h"
00033 #include "rviz/properties/property.h"
00034 #include "rviz/properties/property_manager.h"
00035 #include "rviz/frame_manager.h"
00036
00037 #include <ros/time.h>
00038 #include "ogre_tools/point_cloud.h"
00039
00040 #include <tf/transform_listener.h>
00041
00042 #include <OGRE/OgreSceneNode.h>
00043 #include <OGRE/OgreSceneManager.h>
00044
00045 namespace rviz
00046 {
00047
00048 PointCloudDisplay::PointCloudDisplay( const std::string& name, VisualizationManager* manager )
00049 : PointCloudBase( name, manager )
00050 , tf_filter_(*manager->getTFClient(), "", 10, threaded_nh_)
00051 {
00052 tf_filter_.connectInput(sub_);
00053 tf_filter_.registerCallback(&PointCloudDisplay::incomingCloudCallback, this);
00054 vis_manager_->getFrameManager()->registerFilterForTransformStatusCheck(tf_filter_, this);
00055 }
00056
00057 PointCloudDisplay::~PointCloudDisplay()
00058 {
00059 unsubscribe();
00060 tf_filter_.clear();
00061 }
00062
00063 void PointCloudDisplay::setTopic( const std::string& topic )
00064 {
00065 unsubscribe();
00066 topic_ = topic;
00067 reset();
00068 subscribe();
00069
00070 propertyChanged(topic_property_);
00071
00072 causeRender();
00073 }
00074
00075 void PointCloudDisplay::onEnable()
00076 {
00077 PointCloudBase::onEnable();
00078
00079 subscribe();
00080 }
00081
00082 void PointCloudDisplay::onDisable()
00083 {
00084 unsubscribe();
00085 tf_filter_.clear();
00086
00087 PointCloudBase::onDisable();
00088 }
00089
00090 void PointCloudDisplay::subscribe()
00091 {
00092 if ( !isEnabled() )
00093 {
00094 return;
00095 }
00096
00097 sub_.subscribe(threaded_nh_, topic_, 2);
00098 }
00099
00100 void PointCloudDisplay::unsubscribe()
00101 {
00102 sub_.unsubscribe();
00103 }
00104
00105 void PointCloudDisplay::incomingCloudCallback(const sensor_msgs::PointCloudConstPtr& cloud)
00106 {
00107 addMessage(cloud);
00108 }
00109
00110 void PointCloudDisplay::targetFrameChanged()
00111 {
00112 }
00113
00114 void PointCloudDisplay::fixedFrameChanged()
00115 {
00116 tf_filter_.setTargetFrame( fixed_frame_ );
00117
00118 PointCloudBase::fixedFrameChanged();
00119 }
00120
00121 void PointCloudDisplay::createProperties()
00122 {
00123 topic_property_ = property_manager_->createProperty<ROSTopicStringProperty>( "Topic", property_prefix_, boost::bind( &PointCloudDisplay::getTopic, this ),
00124 boost::bind( &PointCloudDisplay::setTopic, this, _1 ), parent_category_, this );
00125 setPropertyHelpText(topic_property_, "sensor_msgs::PointCloud topic to subscribe to.");
00126 ROSTopicStringPropertyPtr topic_prop = topic_property_.lock();
00127 topic_prop->setMessageType(ros::message_traits::datatype<sensor_msgs::PointCloud>());
00128
00129 PointCloudBase::createProperties();
00130 }
00131
00132 }