Ask Your Question
1

[rosrun] Couldn't find executable

asked 2018-09-07 04:14:36 -0500

YSY gravatar image

updated 2018-09-10 00:56:36 -0500

mgruhler gravatar image

//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

edit retag flag offensive close merge delete

Comments

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 :-)

mgruhler gravatar imagemgruhler ( 2018-09-07 06:48:17 -0500 )edit
1

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 ..
mgruhler gravatar imagemgruhler ( 2018-09-10 00:59:15 -0500 )edit

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.

mgruhler gravatar imagemgruhler ( 2018-09-10 01:00:07 -0500 )edit

@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.

gvdhoorn gravatar imagegvdhoorn ( 2018-09-10 01:23:23 -0500 )edit

Thanks for clarifying.

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

mgruhler gravatar imagemgruhler ( 2018-09-10 01:31:21 -0500 )edit
1

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.

gvdhoorn gravatar imagegvdhoorn ( 2018-09-10 01:36:03 -0500 )edit

Has this been solved yet?

fvd gravatar imagefvd ( 2018-09-16 00:17:18 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-09-07 06:46:13 -0500

fvd gravatar image

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.

2) 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.

edit flag offensive delete link more

Comments

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)

YSY gravatar imageYSY ( 2018-09-07 09:43:24 -0500 )edit

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?

fvd gravatar imagefvd ( 2018-09-07 10:59:04 -0500 )edit

CMakeLists show at the questions. it will show out rosrun beginner_tutorials after tab completion i have no idea what the error is??

YSY gravatar imageYSY ( 2018-09-08 02:35:22 -0500 )edit

??????????????

YSY gravatar imageYSY ( 2018-09-10 00:09:47 -0500 )edit
1

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.

fvd gravatar imagefvd ( 2018-09-10 00:16:56 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-09-07 04:14:36 -0500

Seen: 448 times

Last updated: Sep 10 '18