Getting Started¶
From an assembled BugBot to your first program in a few minutes. Nothing to install: the simulator runs in the browser and talks to the robot over USB.
No robot yet?
Skip to the IDE. Everything in the lessons works there too.
What you need¶
- An assembled BugBot with a charged battery
- A USB-C cable
- Chrome or Edge (they support WebSerial, which the simulator uses to talk to the robot)
Step 1: open the simulator¶
Open the BugBot IDE. The editor is on the left, the 3D view on the right.
Step 2: connect the robot¶
- Plug the robot into your computer with the USB-C cable and switch it on.
- Press Connect and pick the BugBot port in the browser's dialog.
- If the robot's firmware is older than the simulator expects, it offers to update it. Say yes.
The status shows Connected when the robot answers.
Step 3: your first program¶
Paste this into the editor:
from bugbot import *
connect() # the commands, then the robot
led("green")
forward(50) # start driving at half speed
wait(1.5) # keep going for 1.5 seconds
stop()
led("off")
print("done")
Press Run on robot. The LED turns green, the robot drives for a second and a half, stops, and done appears in the console. Press Run in sim to see the same program in the 3D view.
How it works
Every program starts the same way. from bugbot import * brings in the robot's commands, so you can write forward rather than bugbot.forward, and connect() opens the link to the robot. The program runs on the robot, so sensor readings are instant.
Running without a cable¶
Once a program is on the robot you can unplug it and press the button to run it again. To send new programs without the cable, use the dongle and the Python Library.
Troubleshooting¶
No port appears when I press Connect. Check the cable carries data (some only charge) and the robot is switched on. On Windows the robot shows in Device Manager under Ports.
The robot moves but not straight. That is normal for a vibration drive; the sensors correct it when you use forward(speed, distance=...) and turn_right(speed, angle=...), which close the loop. Plain forward(speed) is open loop.
The battery light is red. Charge it over USB-C. The robot will not drive below 3.2 V.
What's next¶
- Lessons, starting with lesson F1.1
- API Reference for every function