eborghi10 / ColumbiaX-Robotics

Projects from edX | CSMM.103x Robotics
https://courses.edx.org/courses/course-v1:ColumbiaX+CSMM.103x+1T2017
41 stars 26 forks source link

catkin_make error on utils folder #3

Closed Minyanaing closed 3 years ago

Minyanaing commented 4 years ago

I am using ROS kinetic and I cloned the projects for the purpose of testing. When doing catkin_make the terminal showed the following errors that are related to robot_sim package.

/home/roar/catkin_ws/src/utils/kuka_lwr/robot_sim/src/robot_sim_bringup.cpp: In function ‘int main(int, char)’: /home/roar/catkin_ws/src/utils/kuka_lwr/robot_sim/src/robot_simbringup.cpp:49:20: error: ISO C++ forbids declaration of ‘it’ with no type [-fpermissive] for (auto const &it : model.joints) ^ /home/roar/catkin_ws/src/utils/kuka_lwr/robot_sim/src/robot_simbringup.cpp:49:25: warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11 for (auto const &it : model.joints) ^ /home/roar/catkin_ws/src/utils/kuka_lwr/robot_sim/src/robot_sim_bringup.cpp:51:12: error: request for member ‘second’ in ‘it’, which is of non-class type ‘const int’ if (it.second->type != urdf::Joint::FIXED) ^ /home/roar/catkin_ws/src/utils/kuka_lwr/robot_sim/src/robot_sim_bringup.cpp:53:19: error: request for member ‘first’ in ‘it’, which is of non-class type ‘const int’ name_map[it.first]=i; ^ utils/kuka_lwr/robot_sim/CMakeFiles/robot_sim_bringup.dir/build.make:62: recipe for target 'utils/kuka_lwr/robot_sim/CMakeFiles/robot_sim_bringup.dir/src/robot_sim_bringup.cpp.o' failed make[2]: ** [utils/kuka_lwr/robot_sim/CMakeFiles/robot_sim_bringup.dir/src/robot_sim_bringup.cpp.o] Error 1 CMakeFiles/Makefile2:18667: recipe for target 'utils/kuka_lwr/robot_sim/CMakeFiles/robot_sim_bringup.dir/all' failed make[1]: [utils/kuka_lwr/robot_sim/CMakeFiles/robot_sim_bringup.dir/all] Error 2 Makefile:138: recipe for target 'all' failed make: *** [all] Error 2 Invoking "make -j4 -l4" failed

Is there anyway to fix this problem? Thanks for your help.

eborghi10 commented 4 years ago

Hi @Minyanaing, as you can see here:

warning: range-based ‘for’ loops only available with -std=c++11 or -std=gnu++11

The issue can be solved compiling with C++11 so you have to add here this instruction:

add_compile_options(-std=c++11)
eborghi10 commented 4 years ago

Tell me if that works please and if you know how to do it, create a PR :smile:

Minyanaing commented 4 years ago

I am not sure that the error was with the version different. Since I am using Kinetic, I edited a few lines by referencing with your previous commit.

In the ~/utils/kuka_lwr/robot_sim/src/robot_sim_bringup.cpp file, I replaced the line 49-56 with

for (std::map<std::string, boost::sharedptr >::iterator it = model.joints.begin(); it != model.joints_.end(); it++) { if (it->second->type != urdf::Joint::FIXED) { name_map[it->first]=i; i++; } }

which was your previous version. Then, catkin_make worked with no error. Thanks.