dotbot.protocol module#

Module for the Dotbot protocol API.

exception dotbot.protocol.ProtocolPayloadParserException[source]#

Bases: Exception

Exception raised on invalid or unsupported payload.

class dotbot.protocol.Advertisement[source]#

Bases: ProtocolData

Dataclass that holds an advertisement (emtpy).

static from_bytes(_)[source]#

Returns a ProtocolData instance from a bytearray.

Parameters:

_ (bytes) –

Return type:

ProtocolData

property fields: List[ProtocolField]#

Returns the list of fields in this data.

class dotbot.protocol.ApplicationType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: IntEnum

Types of DotBot applications.

DotBot = 0#
Freebot = 2#
SailBot = 1#
XGO = 3#
class dotbot.protocol.CommandMoveRaw(left_x=0, left_y=0, right_x=0, right_y=0)[source]#

Bases: ProtocolData

Dataclass that holds move raw command data fields.

Parameters:
  • left_x (int) –

  • left_y (int) –

  • right_x (int) –

  • right_y (int) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

property fields: List[ProtocolField]#

Returns the list of fields in this data.

left_x: int = 0#
left_y: int = 0#
right_x: int = 0#
right_y: int = 0#
class dotbot.protocol.CommandRgbLed(red=0, green=0, blue=0)[source]#

Bases: ProtocolData

Dataclass that holds a complete rgb led command fields.

Parameters:
  • red (int) –

  • green (int) –

  • blue (int) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

blue: int = 0#
property fields: List[ProtocolField]#

Returns the list of fields in this data.

green: int = 0#
red: int = 0#
class dotbot.protocol.CommandXgoAction(action=0)[source]#

Bases: ProtocolData

Dataclass that holds an XGO action.

Parameters:

action (int) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

action: int = 0#
property fields: List[ProtocolField]#

Returns the list of fields in this data.

class dotbot.protocol.ControlMode(mode=ControlModeType.MANUAL)[source]#

Bases: ProtocolData

Dataclass that holds a control mode message.

Parameters:

mode (ControlModeType) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

property fields: List[ProtocolField]#

Returns the list of fields in this data.

mode: ControlModeType = 0#
class dotbot.protocol.ControlModeType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: IntEnum

Types of DotBot control modes.

AUTO = 1#
MANUAL = 0#
class dotbot.protocol.DotBotData(direction=65535, locations=<factory>)[source]#

Bases: ProtocolData

Dataclass that holds direction and LH2 raw data from DotBot application.

Parameters:
static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

direction: int = 65535#
property fields: List[ProtocolField]#

Returns the list of fields in this data.

locations: List[Lh2RawLocation]#
class dotbot.protocol.DotBotSimulatorData(theta=65535, pos_x=0, pos_y=0)[source]#

Bases: ProtocolData

Dataclass that holds direction and GPS data and heading from SailBot application.

Parameters:
  • theta (int) –

  • pos_x (int) –

  • pos_y (int) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

property fields: List[ProtocolField]#

Returns the list of fields in this data.

pos_x: int = 0#
pos_y: int = 0#
theta: int = 65535#
class dotbot.protocol.GPSPosition(latitude=0, longitude=0)[source]#

Bases: ProtocolData

Dataclass that holds GPS positions.

Parameters:
  • latitude (int) –

  • longitude (int) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

property fields: List[ProtocolField]#

Returns the list of fields in this data.

latitude: int = 0#
longitude: int = 0#
class dotbot.protocol.GPSWaypoints(threshold, waypoints=<factory>)[source]#

Bases: ProtocolData

Dataclass that holds a list of GPS waypoints.

Parameters:
  • threshold (int) –

  • waypoints (List[GPSPosition]) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

property fields: List[ProtocolField]#

Returns the list of fields in this data.

threshold: int#
waypoints: List[GPSPosition]#
class dotbot.protocol.LH2Location(pos_x=0, pos_y=0, pos_z=0)[source]#

Bases: ProtocolData

Dataclass that holds LH2 computed location data.

Parameters:
  • pos_x (int) –

  • pos_y (int) –

  • pos_z (int) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

property fields: List[ProtocolField]#

Returns the list of fields in this data.

pos_x: int = 0#
pos_y: int = 0#
pos_z: int = 0#
class dotbot.protocol.LH2Waypoints(threshold, waypoints=<factory>)[source]#

Bases: ProtocolData

Dataclass that holds a list of LH2 waypoints.

Parameters:
  • threshold (int) –

  • waypoints (List[LH2Location]) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

property fields: List[ProtocolField]#

Returns the list of fields in this data.

threshold: int#
waypoints: List[LH2Location]#
class dotbot.protocol.Lh2RawData(locations=<factory>)[source]#

Bases: ProtocolData

Dataclass that holds LH2 raw data.

Parameters:

locations (List[Lh2RawLocation]) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

property fields: List[ProtocolField]#

Returns the list of fields in this data.

locations: List[Lh2RawLocation]#
class dotbot.protocol.Lh2RawLocation(bits=0, polynomial_index=0, offset=0)[source]#

Bases: ProtocolData

Dataclass that holds LH2 raw location data.

Parameters:
  • bits (int) –

  • polynomial_index (int) –

  • offset (int) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

bits: int = 0#
property fields: List[ProtocolField]#

Returns the list of fields in this data.

offset: int = 0#
polynomial_index: int = 0#
class dotbot.protocol.PayloadType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

Types of DotBot payload types.

ADVERTISEMENT = 4#
CMD_MOVE_RAW = 0#
CMD_RGB_LED = 1#
CMD_XGO_ACTION = 11#
CONTROL_MODE = 7#
DOTBOT_DATA = 6#
DOTBOT_SIMULATOR_DATA = 250#
GPS_POSITION = 5#
GPS_WAYPOINTS = 9#
INVALID_PAYLOAD = 12#
LH2_LOCATION = 3#
LH2_RAW_DATA = 2#
LH2_WAYPOINTS = 8#
SAILBOT_DATA = 10#
class dotbot.protocol.ProtocolData[source]#

Bases: ABC

Base class for protocol payload data classes.

abstract static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

abstract property fields: List[ProtocolField]#

Returns the list of fields in this data.

class dotbot.protocol.ProtocolField(value=0, name='', length=1, signed=False)[source]#

Bases: object

Data class that describes a payload field.

Parameters:
  • value (int) –

  • name (str) –

  • length (int) –

  • signed (bool) –

length: int = 1#
name: str = ''#
signed: bool = False#
value: int = 0#
class dotbot.protocol.ProtocolHeader(destination=18446744073709551615, source=0, swarm_id=0, application=ApplicationType.DotBot, version=8, msg_id=0)[source]#

Bases: ProtocolData

Dataclass that holds header fields.

Parameters:
  • destination (int) –

  • source (int) –

  • swarm_id (int) –

  • application (ApplicationType) –

  • version (int) –

  • msg_id (int) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

application: ApplicationType = 0#
destination: int = 18446744073709551615#
property fields: List[ProtocolField]#

Returns the list of fields in this data.

msg_id: int = 0#
source: int = 0#
swarm_id: int = 0#
version: int = 8#
class dotbot.protocol.ProtocolPayload(header, payload_type, values)[source]#

Bases: object

Manage a protocol complete payload (header + type + values).

Parameters:
static from_bytes(bytes_)[source]#

Parse a bytearray to return a protocol payload instance.

Parameters:

bytes_ (bytes) –

to_bytes(endian='little')[source]#

Converts a payload to a bytearray.

Return type:

bytes

header: ProtocolHeader#
payload_type: PayloadType#
values: ProtocolData#
class dotbot.protocol.SailBotData(direction=65535, latitude=0, longitude=0, wind_angle=65535, rudder_angle=0, sail_angle=0)[source]#

Bases: ProtocolData

Dataclass that holds SailBot data from SailBot application.

Parameters:
  • direction (int) –

  • latitude (int) –

  • longitude (int) –

  • wind_angle (int) –

  • rudder_angle (int) –

  • sail_angle (int) –

static from_bytes(bytes_)[source]#

Returns a ProtocolData instance from a bytearray.

Return type:

ProtocolData

direction: int = 65535#
property fields: List[ProtocolField]#

Returns the list of fields in this data.

latitude: int = 0#
longitude: int = 0#
rudder_angle: int = 0#
sail_angle: int = 0#
wind_angle: int = 65535#