0
$\begingroup$

Rosanswers logo

Hello,

I'm trying to run a node from rosrun (it works when I manually enter ./program inside build directory). Yet it doesn't work when called by rosrun - it finds the directory by tab completion, but not the executable. How can I help it? I need it to use it in launch files.

[rosrun] Found the following, but they're either not files,
[rosrun] or not executable:
[rosrun]   /home/user/ros_ws/catkin_ws/src/ros_programme

Originally posted by delta785 on ROS Answers with karma: 72 on 2014-05-19

Post score: 2


Original comments

Comment by LikeSmith on 2014-05-19:
did you run the setup script for your catkin workspace?

Comment by delta785 on 2014-05-19:
Yes. The problem lies in the location of the executables. They're in catkin_ws/build/package_name and they should be somewhere in devel/lib I think. I guess it's something with the CMake file inside package source, but no idea what exactly.

Comment by dornhege on 2014-05-19:
What is the exact command line of your rosrun? What is that package setup and ROS_PACKAGE_PATH?

Comment by delta785 on 2014-05-19:
rosrun ros_programme ros_programme - doesn't work ./ros_programme (build/ros_programme directory) works

I'm not sure what you mean by package setup, I'm a little bit green here. After sourcing many things, this is the ROS_PACKAGE_PATH.

/home/user/ros_ws/catkin_ws/install/share:/home/omikron/ros_ws/catkin_ws/install/stacks:/home/user/ros_ws/catkin_ws/src:/opt/ros/hydro/share:/opt/ros/hydro/stacks

Comment by dornhege on 2014-05-19:
Where is your code and "sourcing many things" would be the package setup. Is the binary in any of the paths in your package path? e.g. .../install

Comment by delta785 on 2014-05-19:
Additionally, the packages I put inside catkin_ws (downloaded from miscellaneous locations) usually allow me to easily use rosrun. This is the CMakeLists.txt of my package (also downloaded, but clearly somehow incomplete)

http://pastebin.com/XNkxU93i

Comment by delta785 on 2014-05-19:
The binary is only in build directory (catkin_ws/build/ros_programme).

Comment by Hamid Didari on 2014-05-19:
did you type ($source devel/setup.bash) in your catkin_ws before typing rosrun ...

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

EDIT

The final solution to this was to make sure to call catkin_package() in the CMakeLists.txt, and to make sure to call it before any add_executable() or add_library() calls.

Original answer

Looking at your CMakeLists.txt, you've named your executables ros_aruco and subpose. The correct way to run them is with:

rosrun ros_programme ros_aruco

Or

rosrun ros_programme subpose

The relevant lines in your CMakeLists.txt that set these names are:

add_executable(ros_aruco src/ros_aruco.cpp)
add_executable(subpose src/subpose.cpp)

I would also expect the final binaries to be generated into devel/lib/ros_aruco rather than build/ros_aruco; are you passing any extra flags to catkin_make that might be changing this behavior?


Originally posted by ahendrix with karma: 47576 on 2014-05-19

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by delta785 on 2014-05-19:
Nah, I've just modified the names for some clarity. The real package name is ros_aruco and I want to call it by running rosrun ros_aruco ros_aruco. So still nothing. ;/

Sorry for confusing things.

Comment by delta785 on 2014-05-19:
No, just "catkin_make".

Comment by ai-shwarya on 2016-10-19:
catkin_package() did the trick for me! Thanks!

$\endgroup$
0
$\begingroup$

Rosanswers logo

I ran across the same error when trying to rosrun after doing a catkin_make install, it turned out I had the install TARGETS set to CATKIN_GLOBAL_BIN_DESTINATION instead of CATKIN_PACKAGE_BIN_DESTINATION (because I had copied that from somewhere else?), and the executables were going into install/bin rather than install/lib/my_package.


Originally posted by lucasw with karma: 8729 on 2017-02-11

This answer was NOT ACCEPTED on the original site

Post score: 2


Original comments

Comment by cmkayjc on 2019-10-25:
Thanks! This solved my problem! I mistook adding my executable to the part for library installation. The default RUNTIME DESTINATION for libraries and executable are different.

$\endgroup$

Your Answer

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