Skip to content
This repository has been archived by the owner on Jul 17, 2019. It is now read-only.

Short tutorial for vscode-ros missing #26

Open
jespestana opened this issue Feb 25, 2019 · 2 comments
Open

Short tutorial for vscode-ros missing #26

jespestana opened this issue Feb 25, 2019 · 2 comments

Comments

@jespestana
Copy link

jespestana commented Feb 25, 2019

I just tested using vscode with ros and I think that it would be good to have a simple tutorial on how to set up the vscode for a given catkin workspace properly.

The following steps allowed me to run CMake and build the catkin workspace both from the terminal using catkin_make and from vscode by running CMake: Configure and CMake: Build:

  1. In a terminal, source the ros distribution by running the command: source /opt/ros/indigo/setup.bash. Then in this same terminal open vscode by running the command code.
  2. Create catkin workspace
  3. Compile the catkin workspace at least once
  4. In vscode: go to File -> Open Folder and open the src folder of the catkin workspace
    Note: vscode will create a build folder inside the src folder of the catkin workspace. This build folder can be deleted once vscode is configured properly.
  5. In vscode:
    4.a Either: in .vscode/settings.json set the cmake.buildDirectory to ${workspaceRoot}/../build
    4.b Or: in Workspace Settings set the CMake: Build Directory to ${workspaceRoot}/../build
  6. Now vscode is configured properly. The vscode commands CMake: Configure and CMake: Build allow to rerun CMake and Build the catking workspace.
@andur
Copy link

andur commented Mar 6, 2019

pls clarify...4.a
do you mean these settings?
~/catkin_ws/src/.vscode/settings.json
in this file add the line inside the brackets?
"cmake.buildDirectory": "${workspaceRoot}/../build"

concerning point 4.b:
...there is no workspace setting for the ROS-Extension to specify the cmake.buildirectory only "distro" is shown.

I am using the "Visual Studio Code - Preview" Snap-Packet for Ubuntu...

@jespestana
Copy link
Author

jespestana commented Mar 6, 2019

Hi Andur,

take into account that I am running an old version of Ubuntu (14.04) and ROS (indigo) and that I am not sure how the ROS Extenstion is supposed to work. If you have another set of steps that makes more sense, please share it in this issue.

do you mean these settings? "~/catkin_ws/src/.vscode/settings.json"

Yes

pls clarify...4.a / 4.b

For step 4, you can either do "4.a" or "4.b", they actually result in the same setting in the "settings.json" file. They both modify the value of the configuration parameter "cmake.buildDirectory".

This is how my settings.json file looks like after doing either "4.a" or "4.b":

{
    "python.autoComplete.extraPaths": [
        "/opt/ros/indigo/lib/python2.7/dist-packages"
    ],
    "cmake.buildDirectory": "${workspaceRoot}/../build",
    "cmake.generator": "Unix Makefiles"
}

concerning point 4.b:
...there is no workspace setting for the ROS-Extension to specify the cmake.buildirectory only "distro" is shown.

The "cmake.buildDirectory" is a variable for the extension "CMake (twxs.cmake)" or for the extension "CMake Tools (vector-of-bool.cmake-tools)". It allows you to set the location of the build directory.

I might have forgotten to add that I needed to source my ros distribution as step "0", by running the command: source /opt/ros/indigo/setup.bash . I'll test it and modify the above steps if necessary.

Regarding my step "4.b", I get to the Workspace Settings menu by using the keyboard shortcut [R1] Ctrl+P and typing ">Preferences: Open Workspace Settings". Then in the search box look for "cmake build directory".

I am using the "Visual Studio Code - Preview" Snap-Packet for Ubuntu...

I am using "Visual Studio Code" version 1.31.1 in Ubuntu 14.04.5 LTS with ROS indigo.

[R1] https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf
[PS] There is a great tutorial in youtube on CMake and CMake in vscode. The tutorial has been filmed by vector-of-bool, the author of the cmake-tools extension.
Link: https://www.youtube.com/playlist?list=PLK6MXr8gasrGmIiSuVQXpfFuE1uPT615s

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants