Skip to content

Session 5: Sensors, Telemetry, and the Romi

Today the robot learns where it is, tells you about it, and then the code runs on the real Romi. You add the gyro and odometry to the drivetrain, publish numbers to NetworkTables, plot them in AdvantageScope, and drive the Romi over Wi-Fi from a laptop.

๐ŸŽฏ Objectives

By the end of this session you will be able to:

  • Explain what an encoder and a gyro measure, and what a setpoint is.
  • Convert encoder counts to inches and inches to meters in code, and test the math.
  • Read and extend a unit test that uses simulated hardware.
  • Publish a robot pose to NetworkTables and see it on a field in AdvantageScope.
  • Connect a laptop to the Romi, run your code on it, and check the sensors against reality.

โœ… Before you arrive

  • Session 4's branch is pushed. Today starts from a fresh main, which already has Sessions 2 through 4 in it.
  • Mentors: solution/session-4 is merged into main.
  • Mentors: the Romi is charged, its Wi-Fi network is up, and one laptop is confirmed to reach 10.0.0.2.

๐Ÿ—“๏ธ Agenda

Time Activity Page
0:00 Recap: controller to motor. Questions
0:05 The routine: refresh main, branch yourname/session-5 The Routine
0:10 Sensors and feedback: encoders, gyro, odometry, setpoints Sensors and Feedback
0:20 Units, decimals, and tests with fake hardware Units and Tests
0:30 Exercise part 1: extend the encoder test Exercise: Encoder Test
0:40 Exercise part 2: odometry and a field on the dashboard Exercise: Odometry
0:55 AdvantageScope: live values and log files Logs and AdvantageScope
1:05 The Romi: connect, run, drive, check the gyro sign Run It on the Romi
1:25 Wrap up: what the capstones add. The challenge is for home Challenge: See It Drive

Mentor pacing note

One Romi, many students. While pairs take turns at the Romi laptop, everyone else runs the odometry exercise in the simulator and AdvantageScope on the other laptops or their own machines. The Romi step is a demo plus one turn each at the sticks.

๐Ÿงช Exercises

  1. The Routine - refresh main and create yourname/session-5.
  2. Exercise: Encoder Test - add a test for the right encoder.
  3. Exercise: Odometry - gyro, odometry, Field2d, telemetry.
  4. Logs and AdvantageScope - plot live values and open a log file.
  5. Run It on the Romi - the real thing.

๐Ÿ† Challenge (optional)

See It Drive - make the robot on AdvantageScope's 2D and 3D field follow the real Romi, with a reset button and a test.

๐Ÿ“š Reference

โญ๏ธ What comes next

That is the last session. Next come the capstones: autonomous routines you design, and a robot arm. Nothing new to learn before the first one. Everything from Sessions 2 through 5 is the toolkit.