ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Why doesn't ros2 pkg list show the packages that I built?

asked 2019-06-17 05:20:33 -0500

AwooOOoo gravatar image

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 ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-06-17 06:50:55 -0500

marguedas gravatar image

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>
edit flag offensive delete link more

Comments

=), 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

AwooOOoo gravatar image AwooOOoo  ( 2019-06-17 06:56:53 -0500 )edit
1

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_dependexec_depend and build_export_depend: http://www.ros.org/reps/rep-0140.html...

marguedas gravatar image marguedas  ( 2019-06-17 07:06:36 -0500 )edit

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

Jaroan gravatar image Jaroan  ( 2020-07-17 10:30:23 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-06-17 05:20:33 -0500

Seen: 2,288 times

Last updated: Jun 17 '19