Client
ClientThread
Bases: Thread
Thread class to read all data from a connection and pass along the data to the desired source.
__init__(conn, tcp_server, incoming_ip, incoming_port)
Set class variables Args: conn: tcp_server: server object incoming_ip: connected from this IP address incoming_port: connected from this port
read_int32(conn)
staticmethod
Reads four bytes from socket connection and unpacks them to an int
Returns: int
read_message(conn)
Decode destination and full message size from socket connection. Grab bytes in chunks until full message has been read.
read_string()
Reads int32 from socket connection to determine how many bytes to read to get the string that follows. Read that number of bytes and decode to utf-8 string.
Returns: string
recvall(conn, size, flags=0)
staticmethod
Receive exactly bufsize bytes from the socket.
run()
Receive a message from Unity and determine where to send it based on the publishers table and topic string. Then send the read message.
If there is a response after sending the serialized data, assume it is a ROS service response.
Message format is expected to arrive as int: length of destination bytes str: destination. Publisher topic, Subscriber topic, Service name, etc int: size of full message msg: the ROS msg type as bytes
serialize_message(destination, message)
staticmethod
Serialize a destination and message class.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destination |
name of destination |
required | |
message |
message class to serialize |
required |
Returns:
| Type | Description |
|---|---|
|
serialized destination and message as a list of bytes |