- Visual Studio Code
- Git
- VirtualBox
- Install Extension Pack for USB passthrough support (required for servo control, cameras, etc)
Note: If you do not wish to use vagrant, you can instead run the vagrant-scripts/bootstrap.sh script on a clean Ubuntu Focal Fossa installation (you have to do minor changes to the script)
Note: after creating the machine, you will have to enable the USB controller in VM settings manually
If you are not familiar with git, take a look at this tutorial: https://www.tutorialspoint.com/git/index.htm
Fork this repository and do your development there.
Remember to git commit
your changes and push them to remote after
every development session.
At the end of the project, create light documentation for your ROS package in english (document code, what dependencies it requires, how it should be used, how it integrates with ROS and does it require more development to be usable) in markdown.
Install Vagrant
Vagrantfile is provided for setting up the ROS development environment. Do not store anything important in the guest. The guest is only meant for building and testing the ROS nodes.
The vagrant syncs the repository (workspace) directory to ~/SOP-Robot
directory in the guest.
To provision the guest (you may have to set the provider manually):
vagrant up --provider=virtualbox
Provisioning the machine for the first time can take up to 1 hour, because after vagrant has set up the box it will install everything listed in ansible-scripts/playbook.yml. In the meantime, download VSCode and checkout the remote development feature mentioned below. If you are using HyperV on Windows as hypervisor, you may have to enable smb direct
in Windows features to be able to mount smb shares.
Now test that the provision succeeded, so vagrant ssh
into the guest and run ls
, you should be see the following output:
PS C:\projects\SOP-Robot> vagrant ssh
vagrant@vagrant-ros:~/SOP-Robot $ ls
2 config docs img launch Makefile README.md scripts sop-robot.code-workspace src vagrant Vagrantfile vagrant-scripts
The easiest way to setup development environment for the ROS packages is to use the SSH Remote Development feature in Visual Studio Code and to do the development inside the guest machine using this feature.
Follow this tutorial to setup the remote development on your host machine and the instructions below to setup the remote connection to your vagrant guest machine:
- Use
vagrant up
to bring up the guest machine If something would fail on the way runvagrant provision
until it runs thru sucessfully - Use
vagrant ssh-config >> ~/.ssh/config
to export the ssh-config- IMPORTANT! Confirm that the file encoding is UTF-8 without BOM, especially if you are on Windows! VSCode shows the file encoding in the bottom-right corner. Convert the encoding if necessary.
- Open
Remote-SSH: Connect to Host
in VSCode - Select
vagrant-ros
- Select
Linux
- Open the
~/SOP-Robot
directory (you will enter this folder automatically when you runvagrant ssh
) - Install whatever extensions you want to use on the guest
Note: you may have to do recursive git clone (git submodule update --init --recursive
) and run: rosdep install --from-paths src --ignore-src --rosdistro foxy -r -y
after vagrant up
, if the shared folder was not mounted correctly during vagrant up
.
Additionally, if you lose the files of git submodules (dynamixel-workbench
and dynamixel-workbench-msgs
) you can get them back with git submodule update --init --recursive
.
When using vagrant virtualbox provider, the GUI should pop up when executing vagrant up
. With virtualbox you can also just start the VM from virtualbox GUI.
After the VM is created, remember to add USB device filters for the USB devices you are using with the robot in the VM settings (e.g., webcam, servo controller). Oracle VM VirtualBox Manager -> Select the created VM -> Settings -> USB -> Check the 'Enable USB Controller' box and choose USB 3.0 Controller -> Add filters for devices using the '+' button. Devices might not always automatically connect to VM even the filters are configured. You can connect them manually from the menu bar. Devices -> USB -> and you will get the list of usb devices. Just select one of them and Virtualbox attaches it to the VM. Tick appears next to the device when it is attached.
Note: The Ubuntu in VM defaults to US keyboard layout. You can change the layout from Ubuntu's options.
Note: if your VM GUI freezes on resize, try changing the virtual machine graphics controller in the VirtualBox settings to VMSVGA
Note: If you have Hyper-V activated on Windows Host and decide to use Virtualbox as a hypervisor, Virtualbox will run very slowly. More information on virtualbox forum and here.
- Open VSCode remote development session
- cd into
src/
and useros2 pkg create
as described here- For Python,
ros2 pkg create --build-type ament_python --node-name <my_node_name> <my_package_name>
- For C++,
ros2 pkg create --build-type ament_cmake --node-name <my_node_name> <my_package_name>
- For Python,
Note: Package node name cannot contain hyphen (setup.py entrypoint). If it does, the package compilation fails!