Pi-puck Controllers¶
|
Main Pi-puck controller class. |
|
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).
-
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 ofpipuck.epuck.EPuck
-
expansion
¶ expansion board controller, either
None
or instance ofpipuck.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)
-
tof_sensors
¶ time-of-flight sensor controllers, 6-tuple of either
pipuck.tof_sensor.ToFSensor
instances orNone
FT903 Controller¶
-
class
pipuck.ft903.
FT903
(bus: smbus.SMBus, i2c_address: int = 28)¶ Class to interface with the FT903 microcontroller.
- Parameters
bus –
smbus.SMBus
instance to use for communicationi2c_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)¶