Skip to main content

canbus.packet

PendantButtons Objects

class PendantButtons(IntEnum)

Bit field for pendant buttons.

PAUSE

Square

BRAKE

Circle

PTO

Triangle

CRUISE

Cross (X)

LEFT

D-pad left

UP

D-pad up

D-pad right

DOWN

D-pad down

AmigaControlState Objects

class AmigaControlState(IntEnum)

State of the Amiga vehicle control unit (VCU)

ActuatorCommands Objects

class ActuatorCommands(IntEnum)

Commands for the linear and rotary actuators.

actuator_bits_cmd

def actuator_bits_cmd(a0=ActuatorCommands.passive,
a1=ActuatorCommands.passive,
a2=ActuatorCommands.passive,
a3=ActuatorCommands.passive)

Returns the command bits for up to four linear or rotary actuators.

actuator_bits_read

def actuator_bits_read(bits)

Parses the command bits for up to four linear or rotary actuators.

Packet Objects

class Packet()

Base class inherited by all CAN message data structures.

from_can_data

@classmethod
def from_can_data(cls, data, stamp: float)

Unpack CAN data directly into CAN message data structure.

stamp_packet

def stamp_packet(stamp: float)

Time most recent message was received.

fresh

def fresh(thresh_s: float = 0.5)

Returns False if the most recent message is older than thresh_s in seconds.

age

def age()

Age of the most recent message.

make_amiga_rpdo1_proto

def make_amiga_rpdo1_proto(
state_req: AmigaControlState = AmigaControlState.STATE_ESTOPPED,
cmd_speed: float = 0.0,
cmd_ang_rate: float = 0.0,
pto_bits: int = 0x0,
hbridge_bits: int = 0x0) -> canbus_pb2.RawCanbusMessage

Creates a canbus_pb2.RawCanbusMessage.

Uses the AmigaRpdo1 structure and formatting, that can be sent directly to the canbus service to be formatted and send on the CAN bus.

WARNING: Deprecated starting with farm-ng-amiga v2.3.0 Please use AmigaRpdo1.to_raw_canbus_message() instead.

Arguments:

  • state_req - State of the Amiga vehicle control unit (VCU).
  • cmd_speed - Command speed in meters per second.
  • cmd_ang_rate - Command angular rate in radians per second.
  • pto_bits - byte with encoded bits for PTO auto control
  • hbridge_bits - byte with encoded bits for h-bridge auto control

Returns:

An instance of a canbus_pb2.RawCanbusMessage.

AmigaRpdo1 Objects

class AmigaRpdo1(Packet)

State, speed, and angular rate command (request) sent to the Amiga vehicle control unit (VCU).

New in fw v0.1.9 / farm-ng-amiga v0.0.7: Add pto & hbridge control. Message data is now 8 bytes (was 5).

encode

def encode()

Returns the data contained by the class encoded as CAN message data.

decode

def decode(data)

Decodes CAN message data and populates the values of the class.

to_raw_canbus_message

def to_raw_canbus_message() -> canbus_pb2.RawCanbusMessage

Packs the class data into a canbus_pb2.RawCanbusMessage.

Returns: An instance of a canbus_pb2.RawCanbusMessage.

AmigaTpdo1 Objects

class AmigaTpdo1(Packet)

State, speed, and angular rate of the Amiga vehicle control unit (VCU).

New in fw v0.1.9 / farm-ng-amiga v0.0.7: Add pto & hbridge control. Message data is now 8 bytes (was 5).

encode

def encode()

Returns the data contained by the class encoded as CAN message data.

decode

def decode(data)

Decodes CAN message data and populates the values of the class.

to_proto

def to_proto() -> amiga_v6_pb2.AmigaTpdo1

Packs the class data into an AmigaTpdo1 proto message.

Returns: An instance of an AmigaTpdo1 proto.

from_proto

@classmethod
def from_proto(cls, proto: amiga_v6_pb2.AmigaTpdo1) -> AmigaTpdo1

Creates an instance of the class from a proto message.

Arguments:

  • proto - The AmigaTpdo1 proto message to parse.

from_raw_canbus_message

@classmethod
def from_raw_canbus_message(
cls, message: canbus_pb2.RawCanbusMessage) -> AmigaTpdo1

Parses a canbus_pb2.RawCanbusMessage.

IFF the message came from the dashboard and contains AmigaTpdo1 structure, formatting, and cobid.

Arguments:

  • message - The raw canbus message to parse.

Returns:

The parsed AmigaTpdo1 message.

parse_amiga_tpdo1_proto

def parse_amiga_tpdo1_proto(
message: canbus_pb2.RawCanbusMessage) -> AmigaTpdo1 | None

Parses a canbus_pb2.RawCanbusMessage.

IFF the message came from the dashboard and contains AmigaTpdo1 structure, formatting, and cobid.

WARNING: Deprecated starting with farm-ng-amiga v2.3.0 Please use AmigaTpdo1.from_raw_canbus_message() instead.

Arguments:

  • message - The raw canbus message to parse.

Returns:

The parsed AmigaTpdo1 message, or None if the message is not a valid AmigaTpdo1 message.

MotorControllerStatus Objects

class MotorControllerStatus(IntEnum)

Values representing the status of the motor controller.

PRE_OPERATIONAL

the motor is not ready to run

IDLE

the motor is waiting to start

POST_OPERATIONAL

the motor already started

RUN

the motor is running

FAULT

the motor controller is in fault mode

MotorState Objects

class MotorState()

Values representing the state of the motor.

Amalgamates values from multiple CAN packets.

to_proto

def to_proto() -> canbus_pb2.MotorState

Returns the data contained by the class encoded as CAN message data.

PendantState Objects

class PendantState(Packet)

State of the Pendant (joystick position & pressed buttons)

encode

def encode()

Returns the data contained by the class encoded as CAN message data.

decode

def decode(data)

Decodes CAN message data and populates the values of the class.

to_proto

def to_proto() -> amiga_v6_pb2.PendantState

Packs the class data into a PendantState proto message.

Returns: An instance of a PendantState proto.

from_proto

@classmethod
def from_proto(cls, proto: amiga_v6_pb2.PendantState) -> PendantState

Creates an instance of the class from a proto message.

Arguments:

  • proto - The PendantState proto message to parse.

from_raw_canbus_message

@classmethod
def from_raw_canbus_message(
cls, message: canbus_pb2.RawCanbusMessage) -> PendantState

Parses a canbus_pb2.RawCanbusMessage.

IFF the message came from the pendant and contains PendantState structure, formatting, and cobid.

Arguments:

  • message - The raw canbus message to parse.

Returns:

The parsed PendantState message.

is_button_pressed

def is_button_pressed(button: PendantButtons) -> bool

Returns True if the button is pressed.