ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

VSCode ROS2 setup

asked 2020-05-14 19:39:51 -0500

thejeeb gravatar image

I should preface my comments by saying I am fairly new to ROS2 and I haven't done any projects in ROS1. I am using a binary install of Eloquent on Ubuntu 18.04. I installed VSCode along with the Extension for ROS on Ubuntu 18.04.

First, I wanted to open up my ROS2 workspace(currently just a clone of turtlesim) in VSCode. I traversed to the workspace and started VSCode ('code .') and VSCode opens it as a VSCode workspace and seems to recognize it as a ROS2 eloquent workspace. Good so far.

Next, I wanted to make sure Intellisense worked. I found two options that worked. One option was to manually add /opt/ros/eqloquent/include to the includePath in c_cpp_properties.json of the VSCode workspace. The other option, which is probably better, was to point the compileCommands in c_cpp_properties.json to the compile_commands.json generated from a colcon build with cmake arg of -DCMAKE_EXPORT_COMPILE_COMMANDS=ON. Is this the best way to enable Intellisense? Ideally, I wouldn't have to do this and VSCode ROS extension would "determine" the paths automatically.

Next, I ran the VSCode build task(Ctrl-Shift-B) and it offered me 'colcon build' as the option. However, it doesn't let me pass any options e.g. if I want to do a clean first. Is there any way to do a clean from VSCode without typing it in a terminal? Also is there any way to just build a single package?

Next, I opened ROS terminal by running the command 'ROS: Create Terminal'. However, it doesn't seem to run the eloquent underlay setup.bash or the overlay setup.bash of my workspace. At least, that's what it seems like since it doesn't tab-complete after 'ros2'. It does seem to have the ROS environment variables defined e.g. ROS_DISTRO. Am I doing this wrong or do I have to always manually run the underlay and overlay setup.bash scripts?

Also, I was hoping that the 'ROS: Run a ROS executable(rosrun)' command (it does call 'ros2 run' even though it says rosrun) would let me run my workspace nodes but it offers me only the underlay nodes as options. Again, is there there anything additional step I need to do to make my ROS2 workspace visible?

Finally, I was attempting to debug the executable but I tried to attach, it gave me the message which I answered affirmatively: Superuser access is required to attach to a process. Attaching as superuser can potentially harm your computer. Do you want to continue? [y/N]. Is there any way to eliminate this query?

All things considered, the ROS extension for ROS2 is very useful and I was able to debug my executable with it. So, great job.

edit retag flag offensive close merge delete

Comments

You'll probably get answers to your questions by one of the MS guys frequenting this forum (but they are probably very busy with the on-line version of the developer's conference so it could take some time), but for future questions: please do not ask multiple questions (you have about 5 here) in a single post here.

ROS Answers is not a forum, but a Q&A site (like Stack Overflow). Those work best with a 1-to-1 ratio of questions to answers.

You probably already noticed this yourself, as "VSCode ROS2 setup" (which is the current title of your question) does not really reflect what you have problems with. It's more the category of questions you're asking, but that's not really a proper title for a Q&A site.

I'm not asking you to change anything now, but please do keep it in mind next time.

gvdhoorn gravatar image gvdhoorn  ( 2020-05-15 06:17:16 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-09-20 02:58:00 -0500

ljaniec gravatar image

Hi,

Maybe this blog:

https://www.allisonthackston.com/arti...

and author's GitHub repository:

https://github.com/athackst/vscode_ro...

would be helpful in your journey with ROS 2 development :)

edit flag offensive delete link more

Question Tools

4 followers

Stats

Asked: 2020-05-14 19:19:59 -0500

Seen: 6,816 times

Last updated: May 14 '20