Pi-puck Controllers

pipuck.pipuck.PiPuck(epuck_version, …)

Main Pi-puck controller class.

pipuck.ft903.FT903(bus, i2c_address)

Class to interface with the FT903 microcontroller.

Pi-puck Controller

Python module for controlling the Pi-puck.

class pipuck.pipuck.PiPuck(epuck_version: Optional[int] = None, tof_sensors: Sequence[bool] = False, False, False, False, False, False, yrl_expansion: bool = False)

Main Pi-puck controller class.

Parameters
  • epuck_version – version of the base e-puck robot (either 1 or 2)

  • tof_sensors – time-of-flight sensor boards attached (6 element tuple/list of bool values)

  • yrl_expansion – YRL Expansion Board attached

property battery_is_charging

Whether the robot is connected to a charger (either through USB or the charging contacts).

Returns

True if charging, otherwise False

static convert_adc_to_voltage(adc_value: str, scale: float = 1.0)float

Convert ADC reading to voltage.

Parameters
  • adc_value – raw value from ADC file (in mV)

  • scale – scaling factor of the ADC channel

Returns

current measured battery voltage (in V)

epuck

e-puck robot controller, either None or instance of pipuck.epuck.EPuck

expansion

expansion board controller, either None or instance of pipuck.yrl_expansion.YRLExpansion

ft903

FT903 microcontroller controller, instance of pipuck.ft903.FT903

get_battery_state(battery_type: str = 'epuck') → Tuple[bool, float, float]

Get current battery state.

Parameters

battery_type – battery type to check (either ‘epuck’ or ‘aux’)

Returns

tuple of (charging state, battery voltage, approximate battery percentage)

set_led_colour(led, colour: str)None

Set a single RGB LED colour.

Parameters
  • led – the LED to set (0-2)

  • colour – colour value (off/black/red/green/yellow/blue/magenta/cyan/white)

set_led_raw(led: int, value: int)None

Set a single RGB LED colour.

Parameters
  • led – the LED to set (0-2)

  • value – raw data byte value (0b00000BGR)

set_led_rgb(led: int, red: bool, green: bool, blue: bool)None

Set a single RGB LED colour.

Parameters
  • led – the LED to set (0-2)

  • red – red value (on/off)

  • green – green value (on/off)

  • blue – blue value (on/off)

set_leds_colour(colour: str)None

Set all RGB LEDs to the same colour.

Parameters

colour – colour value (off/black/red/green/yellow/blue/magenta/cyan/white)

set_leds_colours(colour1: str, colour2: str, colour3: str)None

Set RGB LEDs to the specified colours.

Parameters
  • colour1 – LED1 colour (off/black/red/green/yellow/blue/magenta/cyan/white)

  • colour2 – LED2 colour (off/black/red/green/yellow/blue/magenta/cyan/white)

  • colour3 – LED3 colour (off/black/red/green/yellow/blue/magenta/cyan/white)

set_leds_rgb(red: bool, green: bool, blue: bool)None

Set all RGB LEDs to the same colour.

Parameters
  • red – red value (on/off)

  • green – green value (on/off)

  • blue – blue value (on/off)

static speaker_enable(state: bool)None

Enable or disable the Pi-puck speaker audio amplifier.

Parameters

stateTrue to enable or False to disable

tof_sensors

time-of-flight sensor controllers, 6-tuple of either pipuck.tof_sensor.ToFSensor instances or None

FT903 Controller

class pipuck.ft903.FT903(bus: smbus.SMBus, i2c_address: int = 28)

Class to interface with the FT903 microcontroller.

Parameters
  • bussmbus.SMBus instance to use for communication

  • i2c_address – I2C slave address of the FT903 chip (default 0x1C)

read_data_16(address)
read_data_8(address)
write_data_16(address, data)
write_data_8(address, data)