A simple method to export data through the network. The MORSE sockets middleware will create one socket for each component. The service simulation.list_streams returns the list of available data streams, and the service simulation.get_stream_port(<stream name>) returns the port number associated to this stream.
Data is shared as JSON object, encoded in utf-8 strings. As such, when exchanging data with a particular component using this middleware, it is necessary to create a similar data structure to the local_data dictionary in the component. For example, when using telnet to connect to a waypoint actuator, you need to send a message like the following:
$ telnet localhost 60000
{"x":3.0, "y":5.0, "z":0.0, "tolerance":0.5, "speed":2.0}
The socket data-stream interface is implemented in morse.middleware.socket_datastream.
Note
The port numbers used for the socket datastream interface start at 60000.
Requests to components or MORSE itself can be sent through the socket interface.
The (ASCII) protocol is simple. Either:
id component service [parameters]
or:
id special
Note
Services that control the whole simulator belong to the special component simulation.
MORSE answer follows this model:
id status [result]
Example:
$ telnet localhost 4000
Connected to localhost.
> req1 Human move [1.0, 2.0]
req1 OK
Note
The socket service interface listen by default on port 4000. If this port is busy, MORSE will try to connect to the next 10 ports {4001-4010} before giving up.
Note
Why 4000?? That’s a good question! A free beer for the first one who finds out.
The socket service interface is implemented in morse.middleware.socket_request_manager.