Lab 7 · Motor Lab

What This Lab Is

  • The layer under everything you drove so far: the VESC motor controller, power and safety, and what eRPM means.
  • This is where ROS2 gets introduced - the labs before this hid it behind the Racer API on purpose.
PHOTO: VESC + motor wiring on the car

The VESC

The VESC 6 EDU is the muscle. It takes a command from the Jetson over USB, drives the brushless motor with field-oriented control, and reports back: motor speed, current, and battery voltage. It also runs a small program of its own (LispBM) that never depends on the Jetson - that is where the safety lives.

  • Kill switch. An RF receiver on the VESC's ADC2 pin. DISARM on the remote cuts the motor at the controller, below any software. The Jetson cannot override it.
  • Battery cutoff. The 2S LiPo is watched by the VESC itself: warning at 6.8 V, latched kill at 6.6 V. Under 6.6 V the car stops and stays stopped until you power-cycle it.
  • Beeps. The motor windings double as the speaker. Each event has a cue; learn them and you can hear the car's state from across the room.
EventCue
Powered, armed, above 6.8 Vlow-mid-high, pause, low-high
Host command path readylow-low-high
Armed / disarmedmid-high / high-mid
At or below 6.8 Vthree equal notes, repeated every 5 s
Latched cutoff at or below 6.6 Vimmediate kill; low-high-low after stopping, repeated every 5 s

One Stick, Three Meanings

A motor controller can hold three different things constant. The F710 picks which one with X, Y, or B, and the stick value in [-1, 1] scales to that mode's cap:

  • X - current, up to 20 A. You command torque. The car surges off the line and coasts when you let go.
  • Y - eRPM, up to 60,000. You command speed. The controller adds whatever current it takes to hold it - uphill, downhill, or into a wall. This is how the trained policy (the neural network from Lab 8) drives: it was trained on speed targets, so it commands speed.

eRPM and duty modes do not care what is in the way. A blocked wheel in eRPM mode pulls current to the limit and cooks the motor or the ESC. Use current mode when you are close to the car or to people.

  • B - duty, up to 100%. You command raw voltage as a fraction of the battery. Speed then depends on load. The rawest mode, and the one that teaches you what the other two are hiding.

eRPM is electrical RPM: how fast the magnetic field spins, not the shaft. Divide by the motor's pole pairs to get shaft RPM, then through the gearing and wheel diameter to get ground speed. The VESC only ever sees eRPM; every speed number on the dashboard is derived from it. Under 100 eRPM the car counts as stopped - that is the number the cutoff logic waits for before it beeps.

Hello, ROS2

Every lab so far called racer.drive(steer, throttle) and the plumbing was hidden. Here is the plumbing. On the car the command is a message on a ROS2 topic. Exactly one process publishes it at a time:

  • goat-control-mode teleop - the F710 publishes (goat-teleop.service).
  • goat-control-mode policy - the trained policy publishes. systemd stops the other producer first.
  • goat-control-mode none - nobody publishes. Losing the producer commands coast, never the last value.

The motor bridge node sits between that topic and the VESC. It is the one place the [-1, 1] contract becomes amps. Change the mapping there and every commander - pad, policy, your code - changes with it.

// Next: Train Lab - hand the wheel to a policy and watch it publish on the same topic.

Follow the White Rabbit

Hints
Hint 1: the modes all look the same

Watch the readout, not the bar. The bar is the stick. The readout is what the VESC is asked to hold: amps, eRPM, or a duty fraction.

Hint 2: why does eRPM mode feel dangerous

Speed control adds current until the speed is met. Blocked wheel, same command: the controller pours in current up to its limit. Current mode caps the torque instead, so a blocked wheel just stalls.

Hint 3: from eRPM to km/h

eRPM / pole pairs = shaft RPM. Shaft RPM / gear ratio = wheel RPM. Wheel RPM x wheel circumference = distance per minute. Count the pole pairs on the motor label and measure the wheel; the gear ratio is printed on the drivetrain.