RFRIEDM
February 20, 2024, 2:14pm
64
Here’s the tutorial:
https://docs.ros.org/en/rolling/Tutorials/Intermediate/Testing/CLI.html#debugging-tests-with-gdb
There’s also a comprehensive tutorial here on debugging nodes at runtime:
https://navigation.ros.org/tutorials/docs/get_backtrace.html
Note that GDB doesn’t integrate well with ROS launch: ROS2 Launch fails to return GDB session for debugging · Issue #165 · ros2/launch_ros · GitHub
Additionally, some issues is doing similar things in VSCode because ROS requires running a setup script (install/setup.bash
), but VSCode tasks only support environment variable arguments, not running a whole environment setup script.
opened 05:24AM - 15 Jan 24 UTC
bug
help wanted
Building
(Please add appropriate labels)
- [ ] Windows: (Version)
- [x] Linux: (Dist/V… ersion) Ubuntu 22.04 for development server, Windows 10 for host OS, connected using vscode ssh extension
- [ ] ROS 1: Dist
- [ ] ROS 2: ROS 2 humble
Plugin v0.9.6 pre-release
![image](https://github.com/ms-iot/vscode-ros/assets/25047695/2a4f2c1d-4dc0-4e9c-92bc-506a1b9cfaae)
# what is the bug
When I add a task to run colcon build, it does not source the ROS environment.
## Repro steps
1. Add `"ros.distro": "humble",` to .vscode/settings.json on the remote computer
2. Add this to tasks.json
```json
{
"label": "colconBuildDebug",
"detail": "Build ROS 2 workspace with debug symbols",
"type": "shell",
"command": "colcon build --symlink-install --mixin debug",
"group": "build",
"problemMatcher": "$gcc"
},
```
3. Ensure the ROS extension is started and running in pre-release on the development server
4. Type F1: `Tasks: Run task` and select `colconBuildDebug`
5. Observe the output showing that it never sourced the ROS environment
```
* Executing task: colcon build --symlink-install --mixin debug
Starting >>> grid_map_geo
--- stderr: grid_map_geo
Traceback (most recent call last):
File "/opt/ros/humble/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py", line 21, in <module>
from ament_package.templates import get_environment_hook_template_path
ModuleNotFoundError: No module named 'ament_package'
CMake Error at /opt/ros/humble/share/ament_cmake_core/cmake/ament_cmake_package_templates-extras.cmake:41 (message):
execute_process(/usr/bin/python3.10
/opt/ros/humble/share/ament_cmake_core/cmake/package_templates/templates_2_cmake.py
/home/ryan/Dev/ros2_ws/src/grid_map_geo/build/grid_map_geo/ament_cmake_package_templates/templates.cmake)
returned error code 1
Call Stack (most recent call first):
/opt/ros/humble/share/ament_cmake_core/cmake/ament_cmake_coreConfig.cmake:41 (include)
/opt/ros/humble/share/ament_cmake/cmake/ament_cmake_export_dependencies-extras.cmake:15 (find_package)
/opt/ros/humble/share/ament_cmake/cmake/ament_cmakeConfig.cmake:41 (include)
CMakeLists.txt:18 (find_package)
---
Failed <<< grid_map_geo [0.13s, exited with code 1]
Summary: 0 packages finished [0.50s]
1 package failed: grid_map_geo
1 package had stderr output: grid_map_geo
* The terminal process "/bin/bash '-c', 'colcon build --symlink-install --mixin debug'" terminated with exit code: 1.
* Terminal will be reused by tasks, press any key to close it.
```
# expected behavior
Colcon build will be successful and first `source /opt/ros/humble/setup.bash` before running.
# additional context
Even if I add `source /opt/ros/humble/setup.bash` to my bashrc, it doesn't source.
As a workaround, I could do modify the task command like so, but that is not documented:
`"command": "source /opt/ros/humble/setup.bash && colcon build --symlink-install --mixin debug",`
Then, the launch still fails because it's not sourcing the local ROS workspace before launch:
![image](https://github.com/ms-iot/vscode-ros/assets/25047695/0c16b566-7ab3-4afe-a8de-52e6267f1791)
The best recommendation I have until VSCode and ros2 launch
are more GDB/ROS friendly is use terminal GDB, which you can learn a bunch from Tridge and Henry here:
I’m happy to discuss/help more, but feel it’s a bit off-topic, so feel free to follow up privately or tag me another thread or Github issue. Debugging is important, and the barrier to entry is quite high still when using ROS 2.
3 Likes