mix bb_nsk.install (bb_nsk v0.1.2)

Copy Markdown View Source

Installs Balance Bot board support into a Nerves project

Establishes everything the bb_nsk.add_* tasks attach to: the Nerves system and its device tree provisioning, a robot module carrying the Balance Bot's measured geometry, and persistent parameters.

It adds no hardware. The wheels, the IMU and the balance loop are separate tasks, so the robot can be built up a piece at a time:

mix bb_nsk.add_wheels   # its wheels turn
mix bb_nsk.add_imu      # it knows which way up it is
mix bb_nsk.add_balance  # it stands up

mix bb_nsk.cheat runs all of them.

The device tree

This writes config/provisioning.conf, which sets the fit_config U-Boot variable to nsk-balance-bot. The Trellis system ships three device trees and defaults to the base Nerves Starter Kit, which has no motor PWM, no i2c0 on the add-on's pins and no ledc — so without this a freshly burned board reaches none of the add-on hardware.

It only applies to a from-scratch mix burn. A board already burned with the stock value can be fixed live, taking effect on the next boot:

Nerves.Runtime.KV.put("fit_config", "nsk-balance-bot")

It also adds phx_install, which bb_nsk.add_web needs later. A package added during an Igniter run is not available to that same run, so it has to be put in place a task ahead of the one that uses it.

Example

mix nerves.new my_bot --target trellis
cd my_bot
mix igniter.install bb_nsk

Options

  • --robot - The robot module (defaults to {AppPrefix}.Robot).