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/Linux-Install-Debians
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="[email protected]">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})
## Build the executable
add_executable(sdsmt_simulator ${UI_SRCS} ${CPP_SRCS} ${MOC_SRCS} ${LIB_SRCS} ${LIB_MOC_SRCS} ${RCC_SRCS})
## Add qt module dependencies to executable
## this will find all the headers and link all the libraries
qt5_use_modules(sdsmt_simulator Core Gui Widgets)
## Pull in stuff exported from other packages
ament_target_dependencies(sdsmt_simulator
"rclcpp"
"std_msgs"
"sdsmt_simulator_box2d"
)
## Add fPIC for library exports
if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
## Build Library
add_library(sdsmt_simulator_objs STATIC ${LIB_SRCS} ${LIB_MOC_SRCS})
## Add qt module dependencies to library
## this will find all the headers and link all the libraries
qt5_use_modules(sdsmt_simulator_objs Core)
## Pull in stuff exported from other packages
ament_target_dependencies(sdsmt_simulator_objs
"rclcpp"
"sdsmt_simulator_box2d"
)
#############
## Install ##
#############
## Install include dir
install(
DIRECTORY include/sdsmt_simulator
DESTINATION include
)
## Install executable and lib
install(
TARGETS sdsmt_simulator sdsmt_simulator_objs
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin/sdsmt_simulator
)
ament_package()
I would not be surprised if I missed something important when following the migration steps, but I cannot find what it might be, and I can't see any major difference between my package/cmakelists and the example ones provided in the ros2 repos.
Originally posted by ipiano on ROS Answers with karma: 35 on 2018-01-17
Post score: 0