Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You did forget to edit your CMakelists.txt as it is in the book in the paragraph Building the node

rosbuild_add_executable(example1_a src/example1_a.cpp) 
rosbuild_add_executable(example1_b src/example1_b.cpp)

And in the book there are using Rosbuild package, but if you want to use catkin, just edit your CMakelists.txt as follow

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(example1_a src/example1_a.cpp)
target_link_libraries(example1_a ${catkin_LIBRARIES})
add_dependencies(example1_a chapter2_tutorials_generate_messages_cpp)

add_executable(example1_b src/example1_b.cpp)
target_link_libraries(example1_b ${catkin_LIBRARIES})
add_dependencies(example1_b chapter2_tutorials_generate_messages_cpp)

You should first run source ~/dev/catkin_ws/devel/setup.bash and if you use rosbuild(which is not your case) from the terminal echo "export ROS_PACKAGE_PATH"~/dev/yourfoldername:${ROS_PACKAGE_PATH}" >> ~/.bashrc or manually add this export ROS_PACKAGE_PATH"~/dev/yourfoldername:${ROS_PACKAGE_PATH} at the end of the ~/.bashrc file

You did forget to edit your CMakelists.txt as it is in the book in the paragraph Building the node

rosbuild_add_executable(example1_a src/example1_a.cpp) 
rosbuild_add_executable(example1_b src/example1_b.cpp)

And in the book there are using Rosbuild package, but if you want to use catkin, just edit your CMakelists.txt as follow

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(example1_a src/example1_a.cpp)
target_link_libraries(example1_a ${catkin_LIBRARIES})
add_dependencies(example1_a chapter2_tutorials_generate_messages_cpp)

add_executable(example1_b src/example1_b.cpp)
target_link_libraries(example1_b ${catkin_LIBRARIES})
add_dependencies(example1_b chapter2_tutorials_generate_messages_cpp)