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

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

asked 2019-06-10 22:03:40 -0500

wan_da gravatar image

I am trying to build 2 new nodes, based on the minimal_publisher and minimal_subscriber examples provided by the ros2_ws overlay workspace. I have copied and pasted my code from the examples, with the intention to change them in the near future.

I then changed the names of the source files, and the name of the package, among other names. To ensure a successful build, I made several corresponding changes to the CMakeLists.txt and package.xml of each package as well.

Both packages built successfully. However, the only way I can run them is if I locate the binary files in the install directory of the ros2_ws workspace and run them from there.

If I run ros2 pkg list or ros2 pkg executables, none of my packages show up there. Predictably, when I run ros2 run publisht tester_publisht (publisht is the name of my pkg and tester_publisht is the name of the executable) , it just shows Package 'publisht' not found.

Why is it that ros2 pkg cannot find my package?

My publisht package in the install directory of ros2_ws:

publisht
├── lib
│   └── publisht
│       └── tester_publisht
└── share
    ├── ament_index
    │   └── resource_index
    │       ├── package_run_dependencies
    │       │   └── publisht
    │       ├── packages
    │       │   └── publisht
    │       └── parent_prefix_path
    │           └── publisht
    ├── colcon-core
    │   └── packages
    │       └── publisht
    └── publisht
        ├── cmake
        │   ├── publishtConfig.cmake
        │   └── publishtConfig-version.cmake
        ├── environment
        │   ├── ament_prefix_path.sh -> /home/user/ros2_ws/src/ament/ament_cmake/ament_cmake_core/cmake/environment_hooks/environment/ament_prefix_path.sh
        │   └── path.sh -> /home/user/ros2_ws/src/ament/ament_cmake/ament_cmake_core/cmake/environment_hooks/environment/path.sh
        ├── hook
        │   ├── cmake_prefix_path.ps1
        │   └── cmake_prefix_path.sh
        ├── local_setup.bash
        ├── local_setup.sh
        ├── local_setup.zsh
        ├── package.bash
        ├── package.ps1
        ├── package.sh
        ├── package.xml
        └── package.zsh

My tester directory in ros2_ws/src, which contains the source code for the 2 nodes I intend to make, publisht and subscribet:

tester 
├── publisht
│   ├── CMakeLists.txt
│   ├── package.xml
│   ├── publisht.cpp
│   └── README.md
├── README.md
└── subscribet
    ├── CMakeLists.txt
    ├── package.xml
    ├── README.md
    └── subscribet.cpp

My CMakeLists.txt for publisht:

cmake_minimum_required(VERSION 3.5) 
project(publisht)

# 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)

add_executable(tester_publisht publisht.cpp)
ament_target_dependencies(tester_publisht rclcpp std_msgs)

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

ament_package()

And my package.xml for publisht:

<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
  <name>publisht</name>
  <version>0.6.3</version>
  <description>Ready to publish to topics from selected nodes</description>
  <maintainer email="MAINTAINER@u.uni.edu">MAINTAINER</maintainer>
  <license>Apache License 2.0</license>
  <author>AUTHOR</author>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <build_depend>rclcpp</build_depend>
  <build_depend>std_msgs</build_depend>

  <exec_depend>rclcpp</exec_depend>
  <exec_depend>std_msgs</exec_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>
edit retag flag offensive close merge delete

Comments

Yes, it worked. My bad; I thought that since I sourced the setup.bash in my .bashrc I didn't need to source it again. Apparently I need to source it again after I built publisht.

Thank you very much.

wan_da gravatar image wan_da  ( 2019-06-10 22:35:38 -0500 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2019-06-10 22:14:21 -0500

Have you sourced the install/setup.bash file in the workspace where you built publish?

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2019-06-10 22:03:40 -0500

Seen: 10,160 times

Last updated: Jun 10 '19