0
$\begingroup$

Rosanswers logo

I am working through the ROS begnner tutorials, specifically on this section I am running into an issue:

http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29

I am using ROS kinetic and Ubuntu16.04 LTS.

I section 3, I have added the extra lines below to the CMakeLists.txt file:

add_executable(talker src/talker.cpp)

target_link_libraries(talker ${catkin_LIBRARIES})

add_dependencies(talker beginner_tutorials_generate_messages_cpp)

add_executable(listener src/listener.cpp)

target_link_libraries(listener ${catkin_LIBRARIES})

add_dependencies(listener beginner_tutorials_generate_messages_cpp)

Once these are added, I have saved the .txt file and have then run the following command to add dependencies for the executable targets to message generation targets:

add_dependencies(talker beginner_tutorials_generate_messages_cpp)

Note that the abve command had to be edidet to escape the brackets, it now looks like below:

add_dependencies(talker beginner_tutorials_generate_messages_cpp)

However, when I run this command I get the following error:

add_dependencies(talker: command not found

I am unsure why this is, I have seen similar issues on forums such as here https://answers.ros.org/question/67415/beginner-tutorial-catkin_make-error-directory-not-found/?answer=257676?answer=257676#post-id-257676, but could not find a solution for mine, maybe I have missed the solution somewhere.

Has anyone come across this before and has a solution?

Below is my CMakeLists.txt file (Note that I have put a . between the # so as the text does not look so large.

cmake_minimum_required(VERSION 2.8.3)

project(beginner_tutorials)

.#.# Find catkin and any catkin packages

find_package(catkin REQUIRED COMPONENTS

roscpp

rospy

std_msgs

message_generation

)

.#.#. Declare ROS messages and services

add_message_files(

FILES

Num.msg

)

add_service_files(

FILES

AddTwoInts.srv

)

.#.# Generate added messages and services

generate_messages(

DEPENDENCIES

std_msgs

)

.#.# Declare a catkin package

catkin_package(

CATKIN_DEPENDS message_runtime

)

.#.# Build talker and listener

${catkin_INCLUDE_DIRS}

)

add_executable(

talker src/talker.cpp

)

target_link_libraries(

talker ${catkin_LIBRARIES}

)

add_dependencies(

talker beginner_tutorials_generate_messages_cpp

)

add_executable(

listener src/listener.cpp

)

target_link_libraries(

listener ${catkin_LIBRARIES}

)

add_dependencies(

listener beginner_tutorials_generate_messages_cpp

)


Originally posted by jimc91 on ROS Answers with karma: 29 on 2020-05-08

Post score: 0


Original comments

Comment by gvdhoorn on 2020-05-08:\

Note that I have put a . between the # so as the text does not look so large.

that is because you are using >, which are for quoting ordinary text, not code (or build scripts, or terminal copy-pastes, etc).

If you want to format blocks verbatim (as would be needed for code, console text, etc), then paste the text into your question, select all the lines and press the Preformatted Text button (the one with 101010 on it), or press ctrl+k. That should format everything correctly.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I have [..] then run the following command to add dependencies for the executable targets to message generation targets:

add_dependencies(talker beginner_tutorials_generate_messages_cpp)

Similar to your other question (#q351468): what you show is not a command you run in the terminal, but another statement to add to the CMakeLists.txt of the package.

From the CMakeLists.txt you show it would appear it's already there, so things should be OK like this.


Originally posted by gvdhoorn with karma: 86574 on 2020-05-08

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.