← Back to Docs

Firmware flashing and teleoperation

Build and flash the Teensy firmware, monitor the serial output, start the micro‑ROS agent, and control the robot via keyboard.
1

Compile and flash the Teensy firmware

Build and upload the microcontroller firmware for closed‑loop control.

The closed‑loop motor controller firmware for the robot runs on a Teensy 4.0 microcontroller. Follow these steps to compile and upload the firmware using arduino-cli and teensy_loader_cli.

bash
cd ~/repos/common_platform/firmware/closed_loop
rm -rf build
mkdir build
bash
arduino-cli compile --fqbn teensy:avr:teensy40 -e -o build
bash
SERIAL_TEENSY_DEVICE=$(ls -1 /dev/serial/by-id/ | grep -i teensy | head -n1)
echo $SERIAL_TEENSY_DEVICE
bash
sudo stty -F /dev/serial/by-id/${SERIAL_TEENSY_DEVICE} 9600
bash
sudo teensy_loader_cli -v -w build/*.hex
2

Monitor Teensy debug output

Connect to the Teensy serial port to view debug information.

The firmware prints diagnostic messages over USB serial. Use Python’s serial tools to open the port and inspect output.

bash
SERIAL_NUM=$(ls /dev/serial/by-id/ | grep -i teensy | head -n1)
SERIAL_DEV=/dev/serial/by-id/${SERIAL_NUM}
echo $SERIAL_DEV
bash
python3 -m serial.tools.miniterm $SERIAL_DEV 115200
3

Start the micro‑ROS agent

Run the micro‑ROS serial agent in a Docker container to bridge the Teensy with ROS 2.

The Teensy communicates with ROS 2 via a micro‑ROS agent, which runs in a Docker container. Launch the agent on your development computer, passing it the serial device.

bash
sudo docker run -it --rm --network host --privileged microros/micro-ros-agent:kilted serial --dev $SERIAL_DEV
4

Launch keyboard teleoperation node

Use your keyboard to manually control the robot via evdev_teleop.

After the micro‑ROS agent is running, you can manually control the robot using a keyboard. Launch the evdev_teleop package from within the common_platform workspace.

bash
cd ~/repos/common_platform/common_platform_ws
source install/setup.bash
ros2 launch evdev_teleop evdev_teleop.launch.py

Subscribe to our newsletter

The latest educational robotics news and articles, sent to your inbox weekly.