GridMapLoader.cpp
Go to the documentation of this file.
1 /*
2  * GridMapLoader.cpp
3  *
4  * Created on: Aug 24, 2015
5  * Author: Peter Fankhauser
6  * Institute: ETH Zurich, ANYbotics
7  *
8  */
9 
11 #include <grid_map_msgs/GridMap.h>
12 
13 using namespace grid_map;
14 
15 namespace grid_map_loader {
16 
17 GridMapLoader::GridMapLoader(ros::NodeHandle nodeHandle)
18  : nodeHandle_(nodeHandle)
19 {
21  publisher_ = nodeHandle_.advertise<grid_map_msgs::GridMap>(publishTopic_, 1, true);
22  if (!load()) return;
23  publish();
25 }
26 
28 {
29 }
30 
32 {
33  nodeHandle_.param("bag_topic", bagTopic_, std::string("/grid_map"));
34  nodeHandle_.param("publish_topic", publishTopic_, bagTopic_);
35  nodeHandle_.param("file_path", filePath_, std::string());
36  double durationInSec;
37  nodeHandle_.param("duration", durationInSec, 5.0);
38  duration_.fromSec(durationInSec);
39  return true;
40 }
41 
43 {
44  ROS_INFO_STREAM("Loading grid map from path " << filePath_ << ".");
45  return GridMapRosConverter::loadFromBag(filePath_, bagTopic_, map_);
46 }
47 
49 {
50  grid_map_msgs::GridMap message;
52  publisher_.publish(message);
53  duration_.sleep();
54 }
55 
56 } /* namespace */
void publish(const boost::shared_ptr< M > &message) const
std::string filePath_
Path the ROS bag to be published.
grid_map::GridMap map_
Grid map data.
bool sleep() const
static void toMessage(const grid_map::GridMap &gridMap, grid_map_msgs::GridMap &message)
std::string publishTopic_
Topic name of the grid map to be loaded.
ros::Duration duration_
Duration to publish the grid map.
Duration & fromSec(double t)
bool param(const std::string &param_name, T &param_val, const T &default_val) const
std::string bagTopic_
Topic name of the grid map in the ROS bag.
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::NodeHandle nodeHandle_
ROS nodehandle.
ROSCPP_DECL void requestShutdown()
#define ROS_INFO_STREAM(args)
ros::Publisher publisher_
Grid map publisher.


grid_map_loader
Author(s): Péter Fankhauser
autogenerated on Tue Jun 25 2019 20:02:25