0
$\begingroup$

Rosanswers logo

I've been trying to get caught up on the latest and greatest now that an LTS release of ROS2 has come out. I'm currently trying to create a package in a ros2 overlay workspace and I'm having trouble getting the launch file up and running.

I'm used to ROS1 where I had a launch directory in my package which contained XML .launch files and as long as the package was built I could run roslaunch package_name launch_file.launch. I'm finding it to be not that straightforward in ROS2.

My package's structure is as follows where I have a containing folder called asar and in it:

.
├── CMakeLists.txt
├── image_capture
│   ├── CMakeLists.txt
│   ├── include
│   │   └── image_capture
│   ├── launch
│   │   └── publish_one_image.py
│   ├── package.xml
│   └── src
│       └── run_publish_images.cpp
└── vision_pipeline
    ├── CMakeLists.txt
    └── package.xml

So there are two packages in this folder and I'm focusing on the image_capture package right now.

I can call colcon build at the top of my workspace and it builds everything fine. If I run the resulting executable manually it publishes correctly (just having it publish strings as a proof of concept). However when I run ros2 launch image_capture publish_one_image.py I get an error back:

ssnover@styrka:~/dashing$ ros2 launch image_capture publish_one_image.py
Package 'image_capture' not found: "package 'image_capture' not found, searching: ['/home/ssnover/dashing/install/opencv_tests', '/home/ssnover/dashing/install/vision_opencv', '/home/ssnover/dashing/install/image_geometry', '/home/ssnover/dashing/install/examples_rclcpp_minimal_subscriber', '/home/ssnover/dashing/install/cv_bridge', '/opt/ros/dashing']"

Alright, so it's searching my workspace's install directories, and that list is generated by source /home/ssnover/dashing/install/local_setup.bash which is in bashrc file. I can see when I check in the install directory that a directory has been made called asar and there I can find the executable built by colcon under asar/lib/image_capture as well as some other shell files under asar. So colcon appears to be treating my package similarly to the others, but ros2 CLI can't find it.

Am I missing a step? Is my package file structure incorrect?


Originally posted by ssnover95 on ROS Answers with karma: 26 on 2019-06-16

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The problem lies in my addition of a CMakeLists.txt file to the top level of the asar directory. This was causing a directory asar to be created underneath my install folder. When I took that out, it was no longer created and image_capture was created directly under this folder instead. I'm now able to auto-complete the command ros2 launch image_capture publish_one_image.py without a problem!

I believe that what I was doing (having a top level CMake file with a few calls to add_subdirectory) was allowed in ROS1, but it appears that this causes problems when the src directory is parsed under colcon and ros2.


Originally posted by ssnover95 with karma: 26 on 2019-06-16

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by ssnover95 on 2019-06-16:
An unfortunate side-effect I've just realized is that CLion will have problems loading multiple packages into a single project, as it uses CMake files to parse the project.

Comment by sloretz on 2019-06-17:
I think there is an assumption in colcon that once a package is found it will not contain more packages in its subfolders. It looks like the intention is two packages: image_capture and vision_pipeline, but the cmake file outside of both is tricking colon into thinking there is one plain cmake package in the asar folder.

Interestingly, looks like AWS Robomaker had the same experience: https://docs.aws.amazon.com/robomaker/latest/dg/troubleshooting-colcon.html

$\endgroup$

Your Answer

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