pycram.worlds.multiverse_communication.socket#
Multiverse Client base class.
Attributes#
Classes#
Module Contents#
- pycram.worlds.multiverse_communication.socket.T#
- class pycram.worlds.multiverse_communication.socket.MultiverseSocket(port: str, host: str = Conf.HOST, meta_data: pycram.datastructures.dataclasses.MultiverseMetaData = MultiverseMetaData())#
- _send_data = None#
- port#
- host#
- _meta_data#
- client_name#
- _multiverse_socket#
- property request_meta_data: typing_extensions.Dict#
The request_meta_data which is sent to the server.
- _api_callbacks: typing_extensions.Optional[typing_extensions.Dict] = None#
- _start_time = 0.0#
- run() None#
Run the client.
- _run() None#
Run the client, should call the _connect_and_start() method. It’s left to the user to implement this method in threaded or non-threaded fashion.
- stop() None#
Stop the client.
- property response_meta_data: typing_extensions.Dict#
Get the response_meta_data.
- Returns:
The response_meta_data as a dictionary.
- send_and_receive_meta_data()#
Send and receive the metadata, this should be called before sending and receiving data.
- send_and_receive_data()#
Send and receive the data, this should be called after sending and receiving the metadata.
- property send_data: typing_extensions.List[float]#
Get the send_data.
- property receive_data: typing_extensions.List[float]#
Get the receive_data, the first element should be the current simulation time, the rest should be the received data with the following order: double -> uint8_t -> uint16_t
- Returns:
The received data.
- property api_callbacks: typing_extensions.Dict[str, typing_extensions.Callable[[typing_extensions.List[str]], typing_extensions.List[str]]]#
Get the api_callbacks.
- Returns:
The api_callbacks as a dictionary of function names and their respective callbacks.
- _bind_request_meta_data(request_meta_data: T) T#
Bind the request_meta_data before sending it to the server.
- Parameters:
request_meta_data – The request_meta_data to bind.
- Returns:
The bound request_meta_data.
- _bind_response_meta_data(response_meta_data: T) T#
Bind the response_meta_data after receiving it from the server.
- Parameters:
response_meta_data – The response_meta_data to bind.
- Returns:
The bound response_meta_data.
- _bind_send_data(send_data: T) T#
Bind the send_data before sending it to the server.
- Parameters:
send_data – The send_data to bind.
- Returns:
The bound send_data.
- _bind_receive_data(receive_data: T) T#
Bind the receive_data after receiving it from the server.
- Parameters:
receive_data – The receive_data to bind.
- Returns:
The bound receive_data.
- _connect_and_start() None#
Connect to the server and start the client.
- _disconnect() None#
Disconnect from the server.
- _communicate(resend_request_meta_data: bool = False) bool#
Communicate with the server.
- Parameters:
resend_request_meta_data – Resend the request metadata.
- Returns:
True if the communication was successful, False otherwise.
- _restart() None#
Restart the client.
- log_info(message: str) None#
Log information.
- Parameters:
message – The message to log.
- log_warn(message: str) None#
Warn the user.
- Parameters:
message – The message to warn about.
- _message_template(message: str) str#
- property world_time: float#
Get the world time from the server.
- Returns:
The world time.
- property sim_time: float#
Get the current simulation time.
- Returns:
The current simulation time.