feathersdk.robot.comms.comms_manager Module

feathersdk.robot.comms.comms_manager.EMPTY_PAYLOAD = b''

Empty payload to send when a message doesn’t have a payload.

feathersdk.robot.comms.comms_manager.NUM_CAN_ENDPOINTS_MAX = 8

Absolute max CAN lines (candump bus field width / emulator MAX_NUM_CAN_LINES).

Prefer CommsManager.num_can_endpoints, queried from the Teensy at connect time.

feathersdk.robot.comms.comms_manager.RESULT_BUFFER_SIZE = 102400

The size of the result buffer for Teensy responses in bytes.

feathersdk.robot.comms.comms_manager.HEADER_SIZE = 12

The size of the header for a Teensy response message in bytes.

feathersdk.robot.comms.comms_manager.TeensyResponseType

Possible payload types stored for a Teensy response message.

alias of int | str

class feathersdk.robot.comms.comms_manager.CommsManagerConfig(*, teensy_ip='192.168.10.2', teensy_port=6613, teensy_operating_frequency=300.0, teensy_telemetry_update_frequency=300.0, teensy_candump_update_frequency=30.0, enable_teensy_debug_logging=False, teensy_correct_clock_drift=True, teensy_board_clock_sync_hz=10.0, teensy_expected_clock_drift_ns=100000, teensy_max_clock_sync_error_ns=12000000, teensy_clock_sync_trials=30, teensy_check_unused_messages_interval=10.0, teensy_max_rx_messages_per_tick=32, use_emulated_teensy=False, max_can_rate=3000.0, can_leniency=100.0, server_run_time_nanos=100000, can_read_run_time_nanos=100000, result_operating_frequency=200.0, await_thread_start_timeout=1.0, processing_toggle_timeout=0.3)

Bases: PyDFrozenBaseModel

Configuration for the comms manager.

Parameters:
  • teensy_ip (str)

  • teensy_port (int)

  • teensy_operating_frequency (float)

  • teensy_telemetry_update_frequency (float)

  • teensy_candump_update_frequency (float)

  • enable_teensy_debug_logging (bool)

  • teensy_correct_clock_drift (bool)

  • teensy_board_clock_sync_hz (float)

  • teensy_expected_clock_drift_ns (int)

  • teensy_max_clock_sync_error_ns (int)

  • teensy_clock_sync_trials (int)

  • teensy_check_unused_messages_interval (float)

  • teensy_max_rx_messages_per_tick (int)

  • use_emulated_teensy (bool)

  • max_can_rate (float)

  • can_leniency (float)

  • server_run_time_nanos (int)

  • can_read_run_time_nanos (int)

  • result_operating_frequency (float)

  • await_thread_start_timeout (float)

  • processing_toggle_timeout (float)

teensy_ip: str

Fallback IP of the Teensy when feather-teensy.local does not resolve. Direct-cable static address.

teensy_port: int

The port of the Teensy host.

teensy_operating_frequency: float

The frequency at which the comms manager will attempt to process results from the teensy socket.

teensy_telemetry_update_frequency: float

The frequency at which the comms manager will attempt to request motor telemetry updates from the Teensy.

teensy_candump_update_frequency: float

The frequency at which the comms manager will attempt to request candump updates from the Teensy.

enable_teensy_debug_logging: bool

Whether to enable debug logging from the Teensy over serial.

teensy_correct_clock_drift: bool

Whether to correct the clock drift of the Teensy.

teensy_board_clock_sync_hz: float

The frequency at which the comms manager will attempt to sync the Teensy clock to the host clock.

teensy_expected_clock_drift_ns: int

The expected clock drift of the Teensy in nanoseconds per second. This is used to determine when we will update the clock offset on the Teensy to re-sync the clock to the jetson.

teensy_max_clock_sync_error_ns: int

The maximum error in nanoseconds between the Teensy and host clocks that is acceptable for clock sync.

teensy_clock_sync_trials: int

The number of trials to attempt to sync the Teensy clock to the host clock.

teensy_check_unused_messages_interval: float

The interval in seconds to check for unused message responses.

teensy_max_rx_messages_per_tick: int

The maximum number of message responses to process per tick.

use_emulated_teensy: bool

Whether to use the emulated Teensy running on the host machine instead of a real connected Teensy 4.1 board. This requires you to have the can usb devices connected to the host machine.

max_can_rate: float

The maximum messages per second that can be sent on a CAN interface. Sent to the Teensy on initialize and used for host-side CAN rate limiting.

can_leniency: float

Leniency for CAN bus overload checks. Must be <= max_can_rate. Sent to the Teensy on initialize.

server_run_time_nanos: int

Max time in nanoseconds the Teensy may spend servicing the ethernet server loop per tick. Sent on initialize.

can_read_run_time_nanos: int

Max time in nanoseconds the Teensy may spend polling CAN buses per tick. Sent on initialize.

result_operating_frequency: float

The frequency at which the comms manager result processing thread will attempt to process results from the socket result buffer.

await_thread_start_timeout: float

The timeout in seconds to wait for the processing thread to start.

processing_toggle_timeout: float

The timeout in seconds to wait for the processing thread to toggle processing when making changes to the processing state.

validate_can_leniency_vs_rate()
Return type:

Self

set_ip_to_localhost_if_emulated()
Return type:

Self

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class feathersdk.robot.comms.comms_manager.CommsManager(config, *args, **kwargs)

Bases: Configurable[CommsManagerConfig], Abortable

Handles communication

Parameters:
send_teensy_message(**kwargs)
Parameters:
  • args (~P)

  • kwargs (~P)

Return type:

R

cansend(bus, extended, can_id, data, block=False, timeout=0.1)

Send a plain CAN frame via the Teensy. See _TeensyHandler.cansend.

Parameters:
Return type:

int | Tuple[int, int | str, float]

exception feathersdk.robot.comms.comms_manager.TeensyError

Bases: Exception

An error occurred while communicating with the Teensy.