Ubuntu中可能安装了多个ROS版本,比如ROS1 noetic, ROS2 foxy, humble等。有时候需要在vscode中对ROS程序进行debug,一般会先安装ROS插件。当电脑上有多个ROS版本时,选择Debug中选择ROS:Launch ROS:Attach(ROS1)或者ROS:Debug Launch File(ROS2)时,会没有反应,并且会提示:vscode unable to deteremine the ros distribution。这是因为系统中有多个ROS版本,vscode中ROS插件不知道选哪个版本。这个时候在.vscode目录中新建settings.json文件,内容如下:
{"ros.distro": "foxy", #ros版本"ros.rosSetupScript": "/opt/ros/foxy/install/setup.bash",#"ros.isolateEnvironment": "false"
}
然后重启vscode就可以使用GDB对ROS launch文件进行Debug。