canbus.packet
AmigaControlState Objects​
class AmigaControlState(IntEnum)
State of the Amiga vehicle control unit (VCU)
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,
cmd_speed: float,
cmd_ang_rate: float,
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.
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.
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.
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.
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.
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.