我有一个非常简单的启动文件,如下所示:
<launch>
<arg name="dataset_dir" default="$(env HOME)/mnist" doc="location to the dataset" />
<node name="listener" pkg="package_a" type="listener.py" output="screen"/>
<node name="talker" pkg="package_a" type="talker" output="screen"/>
</launch>
在 VSCode ROS 调试器中运行时,显示以下错误:
请看launch.json
文件内容:
{
"version": "0.2.0",
"configurations": [
{
"name": "ROS: Launch",
"request": "launch",
"target": "/home/ravi/catkin_ws/src/package_a/launch/bringup.launch",
"type": "ros"
}
]
}
代码在普通终端中运行良好,但在 VSCode 中显示错误。
我在 Ubuntu 18.04.6 LTS 操作系统中的 ROS Melodic 上使用 VSCode v1.62.3。
最佳答案
这是在 https://github.com/ms-iot/vscode-ros/issues/566 下跟踪的.
如果您从终端窗口启动 code
,它将继承环境变量。或者您可以向启动配置添加一个“env”选项,例如:
{
"name": "ROS: Launch",
"request": "launch",
"env": [
"HOME": "/home/ravi"
]
"target": "/home/ravi/catkin_ws/src/package_a/launch/bringup.launch",
"type": "ros"
}
关于visual-studio-code - 无法在 VSCode ROS 调试器中读取环境变量 $HOME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70235522/