ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

vel_msg not declared in scope using turtlesim geometry_msgs

asked 2020-07-05 13:22:06 -0500

quadman gravatar image

I'm following a beginner turtlesim tutorial to make a simple move node. It seems that geometry_msgs cmd_vel is not being found despite being in my CMakeList.txt and package.xml

error when running **catkin_make**:`
/home/ubuntu/catkin_ws/src/turtlesim_cleaner/src/robot_cleaner.cpp: In function ‘void move(double, double, bool)’:
/home/ubuntu/catkin_ws/src/turtlesim_cleaner/src/robot_cleaner.cpp:42:3: error: ‘vel_msg’ was not declared in this scope
   vel_msg.linear.x =abs(speed);
   ^~~~~~~
/home/ubuntu/catkin_ws/src/turtlesim_cleaner/src/robot_cleaner.cpp:44:3: error: ‘vel_msg’ was not declared in this scope
   vel_msg.linear.x =-abs(speed);
   ^~~~~~~
/home/ubuntu/catkin_ws/src/turtlesim_cleaner/src/robot_cleaner.cpp:45:2: error: ‘vel_msg’ was not declared in this scope
  vel_msg.linear.y =0;

^~~~~~~

In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/string:40,
                 from /opt/ros/melodic/include/ros/platform.h:38,
                 from /opt/ros/melodic/include/ros/time.h:53,
                 from /opt/ros/melodic/include/ros/ros.h:38,
                 from /home/ubuntu/catkin_ws/src/turtlesim_cleaner/src/robot_cleaner.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h: In instantiation of ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = true; _II = double; _OI = int]’:
/usr/include/c++/7/bits/stl_algobase.h:422:45:   required from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = true; _II = double; _OI = int]’

/usr/include/c++/7/bits/stl_algobase.h:487:39:   required from ‘_OI std::move(_II, _II, _OI) [with _II = double; _OI = int]’
/home/ubuntu/catkin_ws/src/turtlesim_cleaner/src/robot_cleaner.cpp:36:18:   required from here
/usr/include/c++/7/bits/stl_algobase.h:377:57: error: no type named ‘value_type’ in ‘struct std::iterator_traits<double>’
       typedef typename iterator_traits<_II>::value_type _ValueTypeI;
                                                         ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_algobase.h:378:57: error: no type named ‘value_type’ in ‘struct std::iterator_traits<int>’
       typedef typename iterator_traits<_OI>::value_type _ValueTypeO;
                                                         ^~~~~~~~~~~
/usr/include/c++/7/bits/stl_algobase.h:379:64: error: no type named ‘iterator_category’ in ‘struct std::iterator_traits<double>’
       typedef typename iterator_traits<_II>::iterator_category _Category;
                                                                ^~~~~~~~~
/usr/include/c++/7/bits/stl_algobase.h:383:9: error: no type named ‘value_type’ in ‘struct std::iterator_traits<double>’
       const bool __simple = (__is_trivial(_ValueTypeI)
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~
                       && __is_pointer<_II>::__value
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                       && __is_pointer<_OI>::__value
                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         && __are_same<_ValueTypeI, _ValueTypeO>::__value);
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_algobase.h:386:44: error: no type named ‘iterator_category’ in ‘struct std::iterator_traits<double>’
       return std::__copy_move<_IsMove, __simple,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        _Category>::__copy_m(__first, __last, __result);
                        ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
turtlesim_cleaner/CMakeFiles/robot_cleaner_node.dir/build.make:62: recipe for target 'turtlesim_cleaner/CMakeFiles/robot_cleaner_node.dir/src/robot_cleaner.cpp.o' failed
make[2]: *** [turtlesim_cleaner/CMakeFiles/robot_cleaner_node.dir/src/robot_cleaner.cpp.o] Error 1
CMakeFiles/Makefile2:75685: recipe for target 'turtlesim_cleaner/CMakeFiles/robot_cleaner_node.dir/all' failed
make[1]: *** [turtlesim_cleaner/CMakeFiles/robot_cleaner_node.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 58%] Linking CXX shared library /home/ubuntu/catkin_ws/devel/lib/libmavros.so
[ 58%] Built target mavros
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j8 -l8" failed
`

CmakeList.txt:

cmake_minimum_required(VERSION 2.8.3)
project(turtlesim_cleaner)

 find_package(catkin REQUIRED COMPONENTS
    roscpp
    rospy
    std_msgs
    geometry_msgs
    message_generation
 )


catkin_package(
  CATKIN_DEPENDS roscpp rospy ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-07-05 13:36:41 -0500

quadman gravatar image

updated 2020-07-05 13:45:15 -0500

I added a global variable:

geometry_msgs::Twist vel_msg;

and changed the name of 'move' to 'movebot' since 'move' seems to be a reserved function in c++. I hope this helps someone else!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-07-05 13:22:06 -0500

Seen: 516 times

Last updated: Jul 05 '20