HI,
The easiest way to work with VS Code is to use the Visual Studio Code Extension for ROS
If you have it installed, just make sure you source the ROS setup (i.e. /opt/ros//setup.bash) or your workspace (install/setup.bash) before running VS code. It should recognize all the ROS components then,
Originally posted by Mario Garzon with karma: 802 on 2020-11-30
This answer was ACCEPTED on the original site
Post score: 4
Original comments
Comment by RFRIEDM_Trimble on 2021-04-22:
If ROS2 is running in a Docker container, with VSCode using the remote containers extension, I cannot find a way to source ROS before VSCode opens. As a fix, I have installed the ROS extension.
In .vscode/settings.json, add the
following:
In .vscode/c_cpp_properties.json, add
this to the includePath list:
- "/opt/ros/foxy/include/**"
Comment by Mario Garzon on 2021-04-26:
If you are using Docker containers with VS Code, I'll definitely recommend you to check this: vscode-docker-ros2