FlatPointCloudVisualization.cpp
Go to the documentation of this file.
00001 /*
00002  * FlatPointCloudVisualization.cpp
00003  *
00004  *  Created on: Mar 9, 2016
00005  *      Author: Péter Fankhauser
00006  *   Institute: ETH Zurich, Autonomous Systems Lab
00007  */
00008 
00009 #include <grid_map_visualization/visualizations/FlatPointCloudVisualization.hpp>
00010 #include <grid_map_ros/GridMapRosConverter.hpp>
00011 
00012 #include <sensor_msgs/PointCloud2.h>
00013 
00014 namespace grid_map_visualization {
00015 
00016 FlatPointCloudVisualization::FlatPointCloudVisualization(ros::NodeHandle& nodeHandle, const std::string& name)
00017     : VisualizationBase(nodeHandle, name),
00018       height_(0.0)
00019 {
00020 }
00021 
00022 FlatPointCloudVisualization::~FlatPointCloudVisualization()
00023 {
00024 }
00025 
00026 bool FlatPointCloudVisualization::readParameters(XmlRpc::XmlRpcValue& config)
00027 {
00028   VisualizationBase::readParameters(config);
00029 
00030   height_ = 0.0;
00031   if (!getParam("height", height_)) {
00032     ROS_INFO("FlatPointCloudVisualization with name '%s' did not find a 'height' parameter. Using default.", name_.c_str());
00033   }
00034 
00035   return true;
00036 }
00037 
00038 bool FlatPointCloudVisualization::initialize()
00039 {
00040   publisher_ = nodeHandle_.advertise<sensor_msgs::PointCloud2>(name_, 1, true);
00041   return true;
00042 }
00043 
00044 bool FlatPointCloudVisualization::visualize(const grid_map::GridMap& map)
00045 {
00046   if (!isActive()) return true;
00047   sensor_msgs::PointCloud2 pointCloud;
00048 
00049   grid_map::GridMap mapCopy(map);
00050   mapCopy.add("flat", height_);
00051   grid_map::GridMapRosConverter::toPointCloud(mapCopy, "flat", pointCloud);
00052 
00053   publisher_.publish(pointCloud);
00054   return true;
00055 }
00056 
00057 } /* namespace */


grid_map_visualization
Author(s): Péter Fankhauser
autogenerated on Mon Oct 9 2017 03:09:35