I have ROS node and debug it in VS Code over launch task like this:
{
"name": "(gdb) Launch ROS node",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/catkin_ws/devel/lib/my_ros_node/my_ros_node",
"args": [
<some cmd-line arguments>
],
"cwd": "${workspaceFolder}/build/catkin_ws/devel/lib/my_ros_node/",
"environment": [{"name": "LD_LIBRARY_PATH", "value": "${workspaceFolder}/build/lib/:/opt/ros/melodic/lib"} ],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
All works fine. But in one moment I have to remap topics. Easiest way is use roslaunch. I wrote launch-file for it:
<launch>
<remap from="topicA" to="topicB" />
<remap from="topicD" to="topicC" />
<node name="my_ros_node" pkg="my_ros_node" type="my_ros_node" args="<some args>"/>
</launch>
and I should correct VS Code launch target. I cannot find out how launch in VS Code launch target ROS node over roslaunch command. VS Code extension for ROS does not works fine probably case my ros node is just little part of my workspace.
I find out just one solution: launch ros node over roslaunch separately. and after this attach to proccess in VS Code. It works fine but ask for grant root access.
Is there a simpler solution than mine?
Checkout the vscode ROS extension (ms-iot.vscode-ros):
https://marketplace.visualstudio.com/items?itemName=ms-iot.vscode-ros
This adds among other things support for debug configs of
"type": "ros", "request": "launch"
where you specify "target": "<path_to_your_launch_file>"
.