19 const std::string& parameterName)
20 : nodeHandle_(nodeHandle),
21 visualizationsParameter_(parameterName),
22 factory_(nodeHandle_),
25 ROS_INFO(
"Grid map visualization node started.");
41 double activityCheckRate;
50 "Could not load the visualizations configuration from parameter %s,are you sure it" 51 "was pushed to the parameter server? Assuming that you meant to leave it empty.",
58 ROS_ERROR(
"%s: The visualization specification must be a list, but it is of XmlRpcType %d",
60 ROS_ERROR(
"The XML passed in is formatted as follows:\n %s", config.toXml().c_str());
65 for (
int i = 0; i < config.size(); ++i) {
67 ROS_ERROR(
"%s: Visualizations must be specified as maps, but they are XmlRpcType:%d",
70 }
else if (!config[i].hasMember(
"type")) {
71 ROS_ERROR(
"%s: Could not add a visualization because no type was given",
74 }
else if (!config[i].hasMember(
"name")) {
75 ROS_ERROR(
"%s: Could not add a visualization because no name was given",
80 for (
int j = i + 1; j < config.size(); ++j) {
82 ROS_ERROR(
"%s: Visualizations must be specified as maps, but they are XmlRpcType:%d",
87 if (!config[j].hasMember(
"name")
90 ROS_ERROR(
"%s: Visualizations names must be strings, but they are XmlRpcTypes:%d and %d",
95 std::string namei = config[i][
"name"];
96 std::string namej = config[j][
"name"];
98 ROS_ERROR(
"%s: A visualization with the name '%s' already exists.",
107 ROS_ERROR(
"Could not find visualization of type '%s'.", std::string(config[i][
"type"]).c_str());
112 for (
int i = 0; i < config.size(); ++i) {
113 std::string type = config[i][
"type"];
114 std::string name = config[i][
"name"];
116 visualization->readParameters(config[i]);
118 ROS_INFO(
"%s: Configured visualization of type '%s' with name '%s'.",
128 visualization->initialize();
131 ROS_INFO(
"Grid map visualization initialized.");
137 bool isActive =
false;
140 if (visualization->isActive()) {
154 ROS_DEBUG(
"Cancelled subscription to grid map.");
160 ROS_DEBUG(
"Grid map visualization received a map (timestamp %f) for visualization.",
161 message.info.header.stamp.toSec());
166 visualization->visualize(map);
bool isValidType(const std::string &type)
std::vector< std::shared_ptr< VisualizationBase > > visualizations_
List of visualizations.
std::shared_ptr< VisualizationBase > getInstance(const std::string &type, const std::string &name)
ros::Timer activityCheckTimer_
Timer to check the activity of the visualizations.
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool isSubscribed_
If the grid map visualization is subscribed to the grid map.
VisualizationFactory factory_
Visualization factory.
static bool fromMessage(const grid_map_msgs::GridMap &message, grid_map::GridMap &gridMap, const std::vector< std::string > &layers, bool copyBasicLayers=true, bool copyAllNonBasicLayers=true)
Duration & fromSec(double t)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
virtual ~GridMapVisualization()
ros::Subscriber mapSubscriber_
ROS subscriber to the grid map.
std::string mapTopic_
Topic name of the grid map to be visualized.
bool getParam(const std::string &key, std::string &s) const
void updateSubscriptionCallback(const ros::TimerEvent &timerEvent)
ros::Duration activityCheckDuration_
Duration of checking the activity of the visualizations.
void callback(const grid_map_msgs::GridMap &message)
ros::NodeHandle & nodeHandle_
ROS nodehandle.
std::string visualizationsParameter_
Parameter name of the visualizer configuration list.