博客地址:https://www.cnblogs.com/zylyehuo/
主要原因是:没有 source 工作空间的 devel/setup.bash
task.json
{"version": "2.0.0","tasks": [{"type": "shell","label": "Catkin: build","command": "bash","args": ["-lc","cd \"${workspaceFolder}\" && if [ -f devel/setup.bash ]; then source devel/setup.bash; fi && catkin_make"],"options": {"cwd": "${workspaceFolder}"},"presentation": {"reveal": "always","panel": "shared"},"group": {"kind":"build", "isDefault": true},"problemMatcher": ["$gcc"],"detail": "Catkin_make template build task"}]
}
bash -lc "..." 可保证在一段干净的 shell 环境中先 source ROS,再执行 catkin_make,可避免 catkin_make: command not found。