GridMapLoader.cpp
Go to the documentation of this file.
00001 /*
00002  * GridMapLoader.cpp
00003  *
00004  *  Created on: Aug 24, 2015
00005  *      Author: Peter Fankhauser
00006  *       Institute: ETH Zurich, ANYbotics
00007  *
00008  */
00009 
00010 #include <grid_map_loader/GridMapLoader.hpp>
00011 #include <grid_map_msgs/GridMap.h>
00012 
00013 using namespace grid_map;
00014 
00015 namespace grid_map_loader {
00016 
00017 GridMapLoader::GridMapLoader(ros::NodeHandle nodeHandle)
00018     : nodeHandle_(nodeHandle)
00019 {
00020   readParameters();
00021   publisher_ = nodeHandle_.advertise<grid_map_msgs::GridMap>(publishTopic_, 1, true);
00022   if (!load()) return;
00023   publish();
00024   ros::requestShutdown();
00025 }
00026 
00027 GridMapLoader::~GridMapLoader()
00028 {
00029 }
00030 
00031 bool GridMapLoader::readParameters()
00032 {
00033   nodeHandle_.param("bag_topic", bagTopic_, std::string("/grid_map"));
00034   nodeHandle_.param("publish_topic", publishTopic_, bagTopic_);
00035   nodeHandle_.param("file_path", filePath_, std::string());
00036   double durationInSec;
00037   nodeHandle_.param("duration", durationInSec, 5.0);
00038   duration_.fromSec(durationInSec);
00039   return true;
00040 }
00041 
00042 bool GridMapLoader::load()
00043 {
00044   ROS_INFO_STREAM("Loading grid map from path " << filePath_ << ".");
00045   return GridMapRosConverter::loadFromBag(filePath_, bagTopic_, map_);
00046 }
00047 
00048 void GridMapLoader::publish()
00049 {
00050   grid_map_msgs::GridMap message;
00051   grid_map::GridMapRosConverter::toMessage(map_, message);
00052   publisher_.publish(message);
00053   duration_.sleep();
00054 }
00055 
00056 } /* namespace */


grid_map_loader
Author(s): Péter Fankhauser
autogenerated on Tue Jul 9 2019 05:06:41