I created a qt application which can be build by cmake. My application uses some ros2 service so I need to build it with ros. For that I need to put my code under ros2_ws/src/. I want to avoid this thing. I want to build by application from any folder ( without putting under ros2_wc) with ament tool. How can I do it ?
2 Answers
If you want to do that, you need to build ROS2 as usual, and source the following script:
. install/local_setup.bash
Then you can call your build command using ament from the directory you want.
cd <dir>
ament build --force-cmake-configure ...

- 1,307
- 3
- 16
- 34
For those who are using the new ros2 build tool: colcon
You can keep your own ~/ros2_ws, and put the QT application to another ~/ros2_overlay_ws
.
For example, if your new QT application depends on some service or msg located in the original ~/ros2_ws
, you could go to ~/ros2_ws
and run colcon build
.
After compile finished, please remember to import and re-index your packages by the following command: source ~/ros2_ws/install/setup.bash
. This will re-index your ros2 packages at current terminal.
Now go to ~/ros2_overlay_ws/
and put your QT application to ~/ros2_overlay_ws/src
and then run colcon build
. colcon will find your indexed package and add them to your dependency.

- 191
- 1
- 4