Ask Your Question

# [ros2] ros2 run [package] [executable] cannot find executable

I have a C++ project which consists of a number of packages that I'm migrating from ROS1 to ROS2; under ROS1 with catkin, I could build the project with catkin_make and run the executable with rosrun [package] [executable] (One of the packages is an executable, the rest are libraries or plugins).

I have installed ROS2 as per the binary install instructions https://github.com/ros2/ros2/wiki/Lin...

I have a workspace with my project cloned into it, and I believe I've finished migrating all of the package.xml and CMakeLists.txt files. The project can be built fully and the executable and libraries get put into the install directory as expected.

Unfortunately, after sourcing ./install/local_setup.bash (/opt/ros/ardent/setup.bash was sourced before building), the call ros2 run [package] [executable] returns "No executable found"

If I source the argcomplete setup in /opt/ros/ardent, I can try to tabcomplete after typing ros2 run and I can see that my package is listed as a possible completion, but if I run ros2 pkg executables, my package/executable pair is not listed.

I don't know what I have set up incorrectly.

Package.xml

<?xml version="1.0"?>
<package format="2">
<name>sdsmt_simulator</name>
<version>0.0.1</version>
<description>2D simulation environment for robots running in ROS</description>

<maintainer email="andrew.stelter@mines.sdsmt.edu">Andrew Stelter</maintainer>

<license>TODO</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>sdsmt_simulator_box2d</depend>
<depend>rclcpp</depend>
<depend>rmw_implementation</depend>
<depend>std_msgs</depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>


CMakeLists.txt

###########
## SETUP ##
###########
cmake_minimum_required(VERSION 3.5)
project(sdsmt_simulator)

## Compile as C++11
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") endif() ## Find required ROS packages find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(rmw_implementation REQUIRED) find_package(sdsmt_simulator_box2d REQUIRED) ## Find and configure QT find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui ) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) include_directories( include${CMAKE_BINARY_DIR} )

## TODO If possible: Figure out how to mark Qt as a dependency
ament_export_dependencies(
rclcpp
std_msgs
sdsmt_simulator_box2d
)

ament_export_include_directories( include )

ament_export_libraries(sdsmt_simulator_objs)

Message("Own includes:" ${sdsmt_simulator_INCLUDE_DIRS}) ################### ## FILE LISTINGS ## ################### ## Files that have any Qt macros or keywords in them ## Q_OBJECT, Q_PROPERTY, signals, slots.... etc. set(MOC_HDRS include/sdsmt_simulator/drivetrain_if.h include/sdsmt_simulator/sensor_if.h include/sdsmt_simulator/robotcomponent_if.h include/sdsmt_simulator/property.h include/sdsmt_simulator/world_object_component_if.h include/interfaces/simulator_physics_if.h include/interfaces/simulator_ui_if.h include/interfaces/simulator_visual_if.h include/interfaces/old_world_object_if.h include/basic_physics.h include/basic_viewer.h include/simulator_core.h include/robot.h include/map.h include/ui/mainwindow.h ) set(LIB_MOC_HDRS include/sdsmt_simulator/world_object.h include/sdsmt_simulator/model.h ) ## .ui qt widgets form files set(UI_FILES ui/mainwindow.ui) ## Any other source files set(CPP_SRCS src/basic_physics.cpp src/basic_viewer.cpp src/simulator_core.cpp src/robot.cpp src/map.cpp src/ui/mainwindow.cpp src/main.cpp ) set(LIB_SRCS src/world_object.cpp ) set(RCC_FILES ui/resources.qrc) qt5_add_resources(RCC_SRCS${RCC_FILES})

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

## Run MOC on files with Qt Keywords and Macros
qt5_wrap_cpp(LIB_MOC_SRCS ${LIB_MOC_HDRS}) qt5_wrap_cpp(MOC_SRCS${MOC_HDRS})
## Wrap .ui files as cpp files
qt5_wrap_ui(UI_SRCS ${UI_FILES ... edit retag close merge delete ## 2 Answers Sort by » oldest newest most voted You need to install the executable to lib/<PKGNAME> in order to be found by ros2 run. more ## Comments Specifically change RUNTIME DESTINATION bin/sdsmt_simulator to RUNTIME DESTINATION lib/${PROJECT_NAME}

( 2018-01-17 20:25:07 -0500 )edit

Since the install rule also covers libraries I am not sure that will work on Windows.

( 2018-01-17 20:41:03 -0500 )edit

That's true, it's better to install the libraries and binaries separately, so that the .dll's (considered part of RUNTIME by CMake) don't end up off the PATH. They belong in bin.

( 2018-01-17 20:43:06 -0500 )edit

Right now i'm just trying to get the migration to work on Ubuntu; step two will be to try it all on Windows. Was there some documentation page that I missed which says this is where the executable needs to be?

( 2018-01-17 22:37:39 -0500 )edit

## Your Answer

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

Add Answer

## Stats

Asked: 2018-01-17 19:12:56 -0500

Seen: 4,278 times

Last updated: Jan 17 '18