Error in initializing costmap - does not name a type [closed]

asked 2015-07-22 16:33:36 -0600

sonali gravatar image

updated 2015-07-23 13:45:16 -0600

Hi everyone,

I am writing a node in which I need to use the cost map. The following two lines show how I initialized the cost map and used the start() function.

tf::TransformListener tf1(ros::Duration(10));    
costmap_2d::Costmap2DROS* costmap_ros = new costmap_2d::Costmap2DROS("global_costmap", tf1);
costmap_ros->start();

But when I compile it, I get the following error -

/home/sonali/catkin_ws/src/dr_wheelchair/wall_follower/src/wall_follower.cpp:71:1: error: ‘costmap_ros’ does not name a type
 costmap_ros->start();
 ^
make[2]: *** [dr_wheelchair/wall_follower/CMakeFiles/wall_follower.dir/src/wall_follower.cpp.o] Error 1
make[1]: *** [dr_wheelchair/wall_follower/CMakeFiles/wall_follower.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

Why does it say 'does not name a type' when I name it in just the previous line? What am I doing wrong?

I get the same error when I use the getRobotPose() function.

tf::Stamped<tf::Pose> global_pose;
costmap.getRobotPose(global_pose);

However, the program compiles without any errors when I try the getCostmap() function

costmap_2d::Costmap2D* costMapPointer = costmap.getCostmap();

These are the files i've included

#include "ros/ros.h"
#include "sensor_msgs/Range.h"
#include "geometry_msgs/Twist.h"
#include <costmap_2d/costmap_2d_ros.h>
#include <costmap_2d/costmap_2d.h>
#include <tf/transform_listener.h>
#include <iostream>
#include <string>

and I have included costmap_2d in the catkin required components of CMakeLists

Please let me know if you need more information to answer the question.

Thanks!

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2017-04-15 10:39:17.220440