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

catkin_make does not work in publisher and subscriber

asked 2021-04-13 15:45:33 -0600

petros gravatar image

updated 2021-04-13 17:59:43 -0600

Hello I have followed the beginner tutorials in http://wiki.ros.org/ROS/Tutorials and i have made every change recommended in the tutorial but when I type catkin_make, I get the following error. I am using ROS kinetic on Ubuntu 16.04

petros@petros-Lenovo-ideapad-100-15IBD:~/catkin_ws$ catkin_make
Base path: /home/petros/catkin_ws
Source space: /home/petros/catkin_ws/src
Build space: /home/petros/catkin_ws/build
Devel space: /home/petros/catkin_ws/devel
Install space: /home/petros/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/petros/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/petros/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/petros/catkin_ws/devel;/opt/ros/kinetic
-- This workspace overlays: /home/petros/catkin_ws/devel;/opt/ros/kinetic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.12", minimum required is "2") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/petros/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gmock': gtests will be built
-- Found gmock sources under '/usr/src/gmock': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.12") 
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - beginner_tutorials
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'beginner_tutorials'
-- ==> add_subdirectory(beginner_tutorials)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- beginner_tutorials: 1 messages, 1 services
-- Configuring done
-- Generating done
-- Build files have been written to: /home/petros/catkin_ws/build
####
#### Running command: "make -j4 -l4" in "/home/petros/catkin_ws/build"
####
[  0%] Built target std_msgs_generate_messages_eus
[  0%] Built target std_msgs_generate_messages_cpp
[  0%] Built target std_msgs_generate_messages_lisp
[  0%] Built target std_msgs_generate_messages_py
[  0%] Built target _beginner_tutorials_generate_messages_check_deps_AddTwoInts
[  0%] Built target _beginner_tutorials_generate_messages_check_deps_Num
[  0%] Built target std_msgs_generate_messages_nodejs
[ 11%] Built target beginner_tutorials_generate_messages_cpp
[ 29%] Built target beginner_tutorials_generate_messages_eus
[ 41%] Built target beginner_tutorials_generate_messages_lisp
Scanning dependencies of target talker
Scanning dependencies of target listener
[ 64%] Built target beginner_tutorials_generate_messages_py
[ 76%] Built target beginner_tutorials_generate_messages_nodejs
[ 82%] Building CXX object beginner_tutorials/CMakeFiles/listener.dir/src/listener.cpp.o
[ 88%] Building CXX object beginner_tutorials/CMakeFiles/talker.dir/src/talker.cpp.o
[ 88%] Built target beginner_tutorials_generate_messages
/home/petros/catkin_ws/src/beginner_tutorials/src/listener.cpp: In function ‘void chatterCallback(const ConstPtr&)’:
/home/petros/catkin_ws/src/beginner_tutorials/src/listener.cpp:8:46: error: ‘ROS_INFO’ was not declared in this scope
   ROS_INFO("I heard: [%s]", msg->data.c_str());
                                              ^
/home/petros/catkin_ws/src/beginner_tutorials/src/listener.cpp: In function ‘int main(int, char**)’:
/home/petros/catkin_ws/src/beginner_tutorials/src/listener.cpp:23:3: error: ‘init’ is not a member of ‘ros’
   ros::init(argc, argv, "listener");
   ^
/home/petros/catkin_ws/src/beginner_tutorials/src/listener.cpp:30:3: error: ‘NodeHandle’ is not a member of ‘ros’
   ros::NodeHandle n;
   ^
/home/petros/catkin_ws/src/beginner_tutorials/src/listener.cpp:47:3: error: ‘Subscriber’ is not a member of ‘ros’
   ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
   ^
/home/petros/catkin_ws/src/beginner_tutorials/src/listener.cpp:54:3: error: ‘spin’ is not a member of ‘ros’
   ros::spin();
   ^
beginner_tutorials/CMakeFiles/listener.dir/build.make:62: recipe for target 'beginner_tutorials/CMakeFiles/listener.dir/src/listener.cpp.o' failed ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2021-04-13 18:11:16 -0600

Most likely the issue is that you missed some change recommended in the tutorial. This could be a problem with the package.xml, the CMakeLists.txt, or the code itself. In general, when you have compilation errors like this providing the relevant snippets of all of these things will help people better answer your question (please remove the boilerplate comments from package.xml and CMakeLists.txt to add readability).

In this case, without seeing the code, my guess is that you've missed a #include "ros/ros.h" in listener.cpp. If that doesn't seem to be the issue, please edit your question and provide the code you're using.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-04-13 15:45:33 -0600

Seen: 132 times

Last updated: Apr 13 '21