0
$\begingroup$

Rosanswers logo

Hi, I am making a new ros2 node, but it is not showing up in the package list (similar to Why doesn't ros2 pkg list show the packages that I built?, but I believe I've sourced things correctly). I first build the minimal_publisher and minimal_subscriber and this worked fine. I then copied the pendulum_msgs demo to build a custom message (obstacle_msgs) and this works fine. Lastly I wanted to create a new node (obstacle_publisher) which based off minimal_publisher and have it use the newly defined message, but its not getting installed for ros2 to find (the first 3 example are).

CMakeList.txt:

cmake_minimum_required(VERSION 3.5)
project(obstacle_publisher)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(obstacle_msgs REQUIRED)

include_directories("../dependencies/")

add_executable(obstacle_publisher obstaclePublisher.cpp obstacles.cpp)
ament_target_dependencies(obstacle_publisher rclcpp std_msgs obstacle_msgs)

install(TARGETS
  obstacle_publisher
  DESTINATION lib/${PROJECT_NAME}
)

ament_package()

package.xml:

<?xml version="1.0"?>
<package format="2">
  <name>obstacle_publisher</name>
  <version>0.0.0</version>
  <description>The obstacle_publisher package</description>

  <maintainer email="paul">Paul</maintainer>
  <license>TODO</license>
  <!-- <author email="paul">Paul</author> -->

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>message_generation</build_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>obstacle_msgs</build_depend>

  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>

  <exec_depend>message_runtime</exec_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <exec_depend>obstacle_msgs</exec_depend>

  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- Other tools can request additional information be placed here -->

  </export>
</package>

If I remove all the build data

rm -r build/ install/ log/

and then remake the project

colcon build --symlink-install

I get the following;

Starting >>> obstacle_msgs
[0.221s] WARNING:colcon.colcon_ros.prefix_path.ament:The path 
'/home/paul/code/eclipse_ws/ROS2/install/obstacle_msgs' in the environment variable AMENT_PREFIX_PATH doesn't 
exist
[0.221s] WARNING:colcon.colcon_ros.prefix_path.ament:The path 
'/home/paul/code/eclipse_ws/ROS2/install/minimal_subscriber' in the environment variable AMENT_PREFIX_PATH 
doesn't exist
[0.221s] WARNING:colcon.colcon_ros.prefix_path.ament:The path 
'/home/paul/code/eclipse_ws/ROS2/install/minimal_publisher' in the environment variable AMENT_PREFIX_PATH 
doesn't exist
[0.221s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path 
'/home/paul/code/eclipse_ws/ROS2/install/obstacle_publisher' in the environment variable CMAKE_PREFIX_PATH 
doesn't exist
[0.221s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path 
'/home/paul/code/eclipse_ws/ROS2/install/obstacle_msgs' in the environment variable CMAKE_PREFIX_PATH doesn't 
exist
[0.221s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path 
'/home/paul/code/eclipse_ws/ROS2/install/minimal_subscriber' in the environment variable CMAKE_PREFIX_PATH 
doesn't exist
[0.221s] WARNING:colcon.colcon_ros.prefix_path.catkin:The path 
'/home/paul/code/eclipse_ws/ROS2/install/minimal_publisher' in the environment variable CMAKE_PREFIX_PATH 
doesn't exist
Starting >>> minimal_publisher
Starting >>> minimal_subscriber
Finished <<< minimal_publisher [4.67s]                                                             
Finished <<< minimal_subscriber [4.77s]                               
Finished <<< obstacle_msgs [7.55s]                       
Starting >>> obstacle_publisher
--- stderr: obstacle_publisher                               
CMake Warning:
  Manually-specified variables were not used by the project:

    CATKIN_INSTALL_INTO_PREFIX_ROOT


---
Finished <<< obstacle_publisher [4.60s]

Summary: 4 packages finished [12.3s]
  1 package had stderr output: obstacle_publisher

If I rebuild again, I don't get any build errors. Since the only warning that effects obstacle_publisher and not the other relates to CATKIN_INSTALL_INTO_PREFIX_ROOT, I assume it has something to do with the issue.

echo $CATKIN_INSTALL_INTO_PREFIX_ROOT (is blank)

I have 'source /opt/ros/dashing/setup.bash' in my ~/.bashrc file

I see the compiled binary sitting in

install/obstacle_publisher/lib/obstacle_publisher/

, and can execute it directly, but it just doesn't show up in the ros2 pkg list.

I'm sure I've missed something basic, but can somebody help me understand what I'm missing please.

Sincerely, Paul.


Originally posted by AwooOOoo on ROS Answers with karma: 117 on 2019-06-17

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

It looks like your package.xml is from ROS1 (only ROS1 dependencies in it and specifying catkin as a buildtool dependency). So my guess is that colcon is trying to build your package as a catkin package and not an ament package.

Fixing your package.xml may be sufficient to fix your issue. Something similar to:

<?xml version="1.0"?>
<package format="2">
  <name>obstacle_publisher</name>
  <version>0.0.0</version>
  <description>The obstacle_publisher package</description>

  <maintainer email="paul">Paul</maintainer>
  <license>TODO</license>
  <!-- <author email="paul">Paul</author> -->

  <buildtool_depend>ament_cmake</buildtool_depend>
  <depend>rclcpp</depend>
  <depend>std_msgs</depend>
  <depend>obstacle_msgs</depend>

  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- Other tools can request additional information be placed here -->
    <build_type>ament_cmake</build_type>
  </export>
</package>

Originally posted by marguedas with karma: 3606 on 2019-06-17

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by AwooOOoo on 2019-06-17:
=), You were right! I'd just found the buildtool_depend mistake and changed that, but I didn't realize you needed to also remove the build_export_depend and exec_depend sections.

Thank you

Comment by marguedas on 2019-06-17:\

but I didn't realize you needed to also remove the build_export_depend and exec_depend sections.

Sorry for the confusion, the source of the problem was the catkin buildtool_depend and the lack of <build_type>ament_cmake</build_type>. The fact that it was listing ROS1 dependencies and not the ROS2 packages it needs would likely result in other issues down the road.

Collapsing the dependencies necessary for both building and running the program under a depend tag is just an optimization that allowed me to update the dependency list with minimum typing. But is equivalent to list the dependencies under all build_depend exec_depend and build_export_depend: http://www.ros.org/reps/rep-0140.html#depend-multiple

Comment by Jaroan on 2020-07-17:
Hi, Sorry for pulling up an old question again, I wanted to know if build_export_depend has any alternatives in ROS2 packages. I'm having the following tag <build_export_depend>roscpp</build_export_depend> and am unsure how to make it compatible for ROS2 and rclcpp

$\endgroup$

Your Answer

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