message_manager

Сlass operates with protobuff messages. used to create and parse messages.

Module Contents

Classes

MessageManager

class message_manager.MessageManager(logger=logging, head_buffer_size=4)[source]
get_size(self)[source]
Returns

Value of heder byte buffer.

Return type

int

static create_requests_message()[source]

Create Empty protobuf class instance for request message.

Returns

Empty protobuf class instance.

Return type

messages_pb2

static create_answer_message()[source]

Create Empty protobuf class instance for answer message.

Returns

Empty protobuf class instance.

Return type

messages_pb2

static build_request_from_file(path)[source]

Parsing data from message file to protobuf message instance.

Parameters

path (string) – path to filename.txt with message.

Returns

protobuf class instance of filled message from file.

Return type

messages_pb2

build_request_positions(self, positions)[source]

Сreating an instance of the protobuff class and fills it with the values ​​of the actuators

Parameters

positions (dict) – key - servo name and values ​​- position.

Returns

protobuf class instance of filled message with servos.

Return type

messages_pb2

static generate_message(message)[source]

Generate bytes string for sending message.

Parameters
  • message (messages_pb2) – protobuf class instance of filled

  • message.

Returns

bytes string of message.

Return type

bytes

message_from_file(self, path)[source]

Function process the protobuff message. Measurement values of sensors, messages from player.exe and webots. Received messages are placed in the dictionary :param path: path to filename.txt with default message. :type path: [string]

Returns

protobuf class instance, with values ​​from file.

Return type

messages_pb2

get_answer_size(self, content_size)[source]

Сalculating message size from header bytes

Parameters

content_size (bytes) – Byte size of answer message.

Returns

Size of answer message.

Return type

int

add_initial_request(self, sensor_name, sensor_time)[source]

Generate bytes string for sending message.

Parameters
  • sensor_name (string) – protobuf class instance of filled

  • message.

Returns

bytes string of message.

Return type

bytes

build_initial_request(self)[source]

Generate bytes string for initialization message.

Returns

bytes string of message.

Return type

bytes

parse_answer_message(self, data)[source]

Parsing answer message from byte array to dict with measurements

Parameters

data ([type]) – [description]

Returns

[description]

Return type

[type]

static parse_message(message) dict[source]

Function process the protobuff message. Measurement values of sensors, messages from player.exe and webots. Received messages are placed in the dictionary :param message: protobuf class instance :type message: messages_pb2 :param of new message with filled or unfilled.:

Returns

dict with keys of names sensors

Return type

dict