Programming your Robot
We will program the robot using VSCode’s Remote Development extension. This extension allows us to connect to a remote host in a VSCode window and write code on its filesystem.
When you have completed this guide, check out the MBot Bridge API documentation to make your robot move!
- Connecting to the robot
- Video Tutorial
This tutorial assumes you have followed the instructions for installing VSCode. You will need a laptop connected to the same WiFi as the robot (this is MWireless on the UM campus).
Connecting to the robot
1. Add the Remote Development extension
First, we need the VSCode Remote Development extension, which will allow us to connect VSCode to the robot’s environment. Open VSCode and click on the “Extensions” icon in the toolbar on the left. Search for “Remote Development” and select the extension called “Remote Development.” Click “Install” to install it.
2. Add the Raspberry Pi as a remote host
Now we will tell VSCode how to connect to the Raspberry Pi board on the robot. To add the Raspberry Pi as a remote host in VSCode, click on the “Remote Explorer” in the toolbar on the left. Then, select the + beside “SSH” to add a new host:
In the box that appears, type in the following command:
Replace all of
<ROBOT-IP> with the IP address of your robot, and all of
<ROBOT-USER> with the robot’s username (default is
mbot). Check with course staff if you aren’t sure.
Press Enter, then select the default configuration file when the option appears:
3. Connect to the Raspberry Pi
To connect to the Raspberry Pi, open the “Remote Explorer” tab again, and select the new remote host you just added. If it doesn’t appear, press the refresh button. Click on the icon to the right of the address to connect to the host in a new window.
If you are already in a new VSCode window with no other files open, you can also right-click on the host address to connect in the current window. You will be asked to select a platform. Select “Linux.”
You will be asked for the password to the Raspberry Pi. The default password is i<3robots!. The first time you connect, it will take a few minutes for VSCode to do some setup on the Raspberry Pi. You should see the address of the Raspberry Pi on the bottom left of the VSCode window.
4. Opening a terminal
In the VSCode window connected to the robot, open a terminal by clicking on “Terminal” > “New Terminal.” A terminal will open on the Raspberry Pi. You can type command-line commands in this terminal.
This video tutorial goes through the process outlined above.