Brussels / 3 & 4 February 2018

schedule

Rusty robots

Programming a self-balancing robot in Rust


Are we embedded yet? I'd say yes! In this talk I'll show you how I programmed a self-balancing robot from scratch. I'll cover IO abstractions, motion sensors, motor drivers, filters, control stuff, bare metal multitasking, logging, etc. And I'll explain how some of Rust features made development easier and made the program more correct.

The talk will cover the following topics (as time allows):

  • Dynamics of the inverted pendulum

  • Motion sensors

    • Accelerometer
    • Gyroscope
    • Sensor fusion: computing the tilt angle from the sensor readings
  • Motors

    • Dynamics
    • H bridge: controlling direction
    • Pulse Width Modulation (PWM): controlling speed
    • Rotary encoder: sensing speed
  • Controller architecture

  • Implementation

    • Sensor interfaces
    • IO abstractions & pin distribution
    • Fixed Point Arithmetic
    • Sensor noise
    • Filter design
    • Sensor calibration
    • System characterization
    • Tasks
    • Multitasking
  • Logging

    • Communication over bluetooth
    • Binary (de)serialization
  • Performance evaluation

    • CPU usage
    • Response times
    • Program size

I should note that I won't go in too much detail about the control engineering topics; just enough to motivate the design of the program.

The main takeaways of the talk will be:

  • Rust's rich type system lets you validate parts of your program, like the system initialization, at compile time eliminating a whole class of logic bugs.

  • Zero cost abstractions give you the high performance required to target microcontrollers with just a few KBs of RAM and that operate at tens of MHz.

  • Memory safety enables fearless multitasking, even on a system without an OS.

Speakers

Jorge Aparicio Rivera

Attachments

Links