0
$\begingroup$

Rosanswers logo

//www.ros.org/wiki/ROS/Tutorials/ExaminingPublisherSubscriber.

When I try to run rosrun beginner_tutorials talker. It tells me that: [rosrun] Couldn't find executable named talker below /home/MY_NAME/catkin_ws/src/beginner_tutorials

Additional information: When I ran find -executable -type f the output is given as below:

./src/beginner_tutorials/talker.cpp
./src/beginner_tutorials/listener.cpp
./devel/_setup_util.py
./devel/env.sh
./build/catkin_generated/stamps/Project/_setup_util.py.stamp
./build/catkin_generated/installspace/_setup_util.py
./build/catkin_generated/installspace/env.sh
./build/catkin_generated/setup_cached.sh
./build/catkin_generated/env_cached.sh
./build/CMakeFiles/feature_tests.bin
./build/CMakeFiles/3.5.1/CompilerIdC/a.out
./build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin
./build/CMakeFiles/3.5.1/CompilerIdCXX/a.out
./build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin

After using the env | grep ROS_PACKAGE_PATH I get:

ROS_PACKAGE_PATH=/home/MY_NAME/catkin_ws/src:/opt/ros/kinetic/share

and I have sourced the file using the following command: source ./devel/setup.bash

below is the CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(beginner_tutorials)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
)


################################################
## Declare ROS messages, services and actions ##
################################################

## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
##   your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
##   * add a build_depend tag for "message_generation"
##   * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
##   * If MSG_DEP_SET isn't empty the following dependency has been pulled in
##     but can be declared for certainty nonetheless:
##     * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
##   * add "message_generation" and every package in MSG_DEP_SET to
     find_package(catkin REQUIRED COMPONENTS 
    roscpp
    rospy
    std_msgs
    message_generation
     )
##   * add "message_runtime" and every package in MSG_DEP_SET to
     catkin_package(
    ...
        CATKIN_DEPENDS message_runtime ...
        ...)
##   * uncomment the add_*_files sections below as needed
##     and list every .msg/.srv/.action file to be processed
##   * uncomment the generate_messages entry below
##   * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)

## Generate messages in the 'msg' folder
 add_message_files(
   FILES
   Num.msg
 )

generate_messages()

## Generate services in the 'srv' folder
 add_service_files(
   FILES
   AddTwoInts.srv
 )

## Generate added messages and services with any dependencies listed here
 generate_messages(
   DEPENDENCIES
   std_msgs
 )

catkin_package(
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
 include
  ${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)

add_executable(add_two_ints_server src/add_two_ints_server.cpp)
target_link_libraries(add_two_ints_server ${catkin_LIBRARIES})
add_dependencies(add_two_ints_server beginner_tutorials_gencpp)

add_executable(add_two_ints_client src/add_two_ints_client.cpp)
target_link_libraries(add_two_ints_client ${catkin_LIBRARIES})
add_dependencies(add_two_ints_client beginner_tutorials_gencpp)

thanks


Originally posted by YSY on ROS Answers with karma: 21 on 2018-09-07

Post score: 2


Original comments

Comment by mgruhler on 2018-09-07:
as no executbale is found, seems that you did not build the node as described in this tutorial. What makes no sense, though, is that the talker/listner.cpp are executable. This is not python :-)

Comment by mgruhler on 2018-09-10:
I took the liberty of reformatting the question and get rid of a lot of the comments.

Two things are strange.

  1. if this is a 1-to-1 copy of your CMakeLists.txt: you call find_package twice. I'm not sure if this is even possible or what the effects are.
  2. If no talker executable is found ..

Comment by mgruhler on 2018-09-10:
in devel, the compilation was not succesfull. You did call catkin_make again after adding the respective *.cpp files, right? You have to call those every time you change something.

Comment by gvdhoorn on 2018-09-10:
@mgruhler wrote:

you call find_package twice. I'm not sure if this is even possible or what the effects are.

It won't work.

It needs to be removed / the second call needs to be merged with the first.

Comment by mgruhler on 2018-09-10:
Thanks for clarifying.

I suspected as much but have not tested it and didn't have the time to investigate.

Comment by gvdhoorn on 2018-09-10:
Well to be fair it does "work", but almost never does what the user expects. It's infinitely better and more intuitive to not have two find_package(catkin ..) statements in there.

Comment by fvd on 2018-09-16:
Has this been solved yet?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

  1. Are you trying to run a python node? You need to make it executable via chmod +x yournode.py and put it into the scripts/ folder or your package.

There is a set of best practices for setting up your workspace with Python nodes that I can't manage to find right now.

  1. If it's a C++ node, the problem is usually that it's not listed in your CMakeLists.txt as a build target. I don't think this is your problem, but maybe someone else's who will come across this.

Originally posted by fvd with karma: 2180 on 2018-09-07

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by YSY on 2018-09-07:
it is a C++ node i have add the code below into CMakeLists.txt before

add_executable(listener src/listener.cpp)

target_link_libraries(listener ${catkin_LIBRARIES})

add_dependencies(listener beginner_tutorials_generate_messages_cpp)

Comment by fvd on 2018-09-07:
Please add all the relevant CMakeLists.txt parts to the question. Can you do tab completion on "rosrun begin" and "rosrun beginner_tutorials lis" after sourcing? What exactly is the error?

Comment by YSY on 2018-09-08:
CMakeLists show at the questions. it will show out rosrun beginner_tutorials after tab completion i have no idea what the error is??

Comment by YSY on 2018-09-10:
??????????????

Comment by fvd on 2018-09-10:
Please don't spam punctuation marks, everyone is a volunteer here. Would you mind formatting the file as code? There is a button in the editor.

$\endgroup$

Your Answer

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