morse.middleware package

Subpackages

Submodules

morse.middleware.abstract_datastream module

class AbstractDatastream(component_instance, kwargs)[source]

Bases: object

The class is inherited by all serializers/deserializers. Concrete classes need to implement default().

component_name
data
default(ci='unused')[source]

default method called by MORSE logic

Sensor: must read local_data, format and publish them. Actuator: must read a new incoming command and update local_data.

finalize()[source]

finalize the specific datastream

Can be overriden if needed

initialize()[source]

initialize the specific datastream

Can be overriden if needed

morse.middleware.hla_datastream module

class HLABaseNode(klass, fom, node_name, federation, sync_point, sync_register, time_sync, timestep)[source]

Bases: object

finalize()[source]

Close all open HLA connections.

class HLADatastreamManager(args, kwargs)[source]

Bases: morse.core.datastream.DatastreamManager

External communication using sockets.

action()[source]
finalize()[source]
register_component(component_name, component_instance, mw_data)[source]

Open the port used to communicate by the specified component.

class MorseBaseAmbassador(rtia, federation, time_sync, timestep)[source]

Bases: hla.rti.FederateAmbassador

advance_time()[source]
announceSynchronizationPoint(label, tag)[source]
attribute_handle(name, obj_handle)[source]
delete_object(name)[source]
discoverObjectInstance(obj, objectclass, name)[source]
federationSynchronized(label)[source]
get_attributes(obj_name)[source]
initialize_time_regulation()[source]
object_handle(name)[source]
reflectAttributeValues(obj, attributes, tag, order, transport, time=None, retraction=None)[source]
register_object(handle, name)[source]
register_sync_point(label)[source]
suscribe_attributes(name, obj_handle, attr_handles)[source]
timeAdvanceGrant(time)[source]
timeConstrainedEnabled(time)[source]
timeRegulationEnabled(time)[source]
unsuscribe_attributes(obj_handle)[source]
update_attribute(obj_handle, value)[source]
wait_until_sync(label)[source]

morse.middleware.moos_datastream module

class MOOSDatastreamManager(args, kwargs)[source]

Bases: morse.core.datastream.DatastreamManager

Handle communication between Blender and MOOS.

morse.middleware.pocolibs_datastream module

class DummyPoster(name)[source]

Bases: object

exception InvalidRead(value)[source]

Bases: Exception

class PocolibsDataStreamInput(component_instance, kwargs)[source]

Bases: morse.middleware.abstract_datastream.AbstractDatastream

finalize()[source]
initialize(kind)[source]
read()[source]
class PocolibsDataStreamOutput(component_instance, kwargs)[source]

Bases: morse.middleware.abstract_datastream.AbstractDatastream

finalize()[source]
initialize(kind)[source]
write(obj)[source]
class PocolibsDatastreamManager(args, kwargs)[source]

Bases: morse.core.datastream.DatastreamManager

Handle communication between Blender and Pocolibs.

compute_date()[source]

Compute the current time

( we only require that the date increases using a constant step so real time is ok)

exception PosterNotFound(value)[source]

Bases: Exception

poster_name(component_name, mw_data)[source]

morse.middleware.pocolibs_request_manager module

class PocolibsRequestManager[source]

Bases: morse.core.request_manager.RequestManager

Implements Pocolibs requests to control the MORSE simulator.

This is done by re-implementing (parts of) the TCLserv protocol.

HOST = ''
PORT = 9473
finalization()[source]

Terminate the ports used to accept requests

initialization()[source]
main()[source]
on_service_completion(intern_rqst_id, result)[source]
post_registration(component, service, is_async)[source]

morse.middleware.ros_datastream module

The ROS ‘datastream manager’ is responsible for ROS topic management in MORSE. It publishes simulated sensors and subscribes to topics controlling simulated actuators.

As you may have noticed, the morse.middleware.ros_datastream.ROSDatastreamManager class is actually empty: contrary to sockets, for instance, that always use direct JSON serialization of MORSE Python objects, there is no generic way to encode/decode ROS messages.

Thus, morse/middleware/ros contains one specific serialization/deserialization class for each sensor/actuator. These classes inherit either from morse.middleware.ros.abstract_ros.ROSPublisher or from:py:class:morse.middleware.ros.abstract_ros.ROSSubscriber.

If you want to add support for a new type of topic, you likely want to add it as a new serialization implementation in this directory.

Note also that management of ROS services and ROS actions takes place in ros_request_manager.py.

class ROSDatastreamManager(args, kwargs)[source]

Bases: morse.core.datastream.DatastreamManager

Handle communication between Blender and ROS.

morse.middleware.ros_request_manager module

morse.middleware.socket_datastream module

class MorseEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: json.encoder.JSONEncoder

default(obj)[source]
class SocketDatastreamManager(args, kwargs)[source]

Bases: morse.core.datastream.DatastreamManager

External communication using sockets.

action()[source]
get_all_stream_ports()[source]

Get stream ports for all streams.

get_stream_port(name)[source]

Get stream port for stream name.

list_streams()[source]

List all publish streams.

register_component(component_name, component_instance, mw_data)[source]

Open the port used to communicate by the specified component.

class SocketPublisher(component_instance, kwargs)[source]

Bases: morse.middleware.socket_datastream.SocketServ

default(ci='unused')[source]
encode()[source]
class SocketReader(component_instance, kwargs)[source]

Bases: morse.middleware.socket_datastream.SocketServ

decode(msg)[source]
default(ci='unused')[source]
class SocketServ(component_instance, kwargs)[source]

Bases: morse.middleware.abstract_datastream.AbstractDatastream

close_socket(sock)[source]
finalize()[source]

Terminate the ports used to accept requests

initialize()[source]

morse.middleware.socket_request_manager module

class SocketRequestManager[source]

Bases: morse.core.request_manager.RequestManager

Implements services to control the MORSE simulator over raw ASCII sockets.

The syntax of requests is:

>>> id component_name service [params with Python syntax]

id is an identifier set by the client to conveniently identify the request. It must be less that 80 chars in [a-zA-Z0-9].

The server answers:

>>> id status result_in_python|error_msg

status is one of the constants defined in morse.core.status.

finalization()[source]

Terminate the ports used to accept requests

initialization()[source]
main()[source]
on_service_completion(request_id, results)[source]
post_registration(component, service, is_async)[source]

morse.middleware.text_datastream module

class BasePublisher(component_instance, kwargs)[source]

Bases: morse.middleware.abstract_datastream.AbstractDatastream

default(ci)[source]
encode_data()[source]
finalize()[source]
header()[source]
initialize()[source]
class CSVPublisher(component_instance, kwargs)[source]

Bases: morse.middleware.text_datastream.BasePublisher

encode_data()[source]
header()[source]
class Publisher(component_instance, kwargs)[source]

Bases: morse.middleware.text_datastream.BasePublisher

encode_data()[source]
header()[source]
class TextDatastreamManager(args, kwargs)[source]

Bases: morse.core.datastream.DatastreamManager

Produce text files as output for the components

morse.middleware.yarp_datastream module

class YarpDatastreamManager(args, kwargs)[source]

Bases: morse.core.datastream.DatastreamManager

Handle communication between Blender and YARP.

finalize()[source]

Close all currently opened ports and release the network.

class YarpPort(component_instance, kwargs)[source]

Bases: morse.middleware.abstract_datastream.AbstractDatastream

connect2topic(topic)[source]

Connect a yarp port to a specific yarp topic.

finalize()[source]
initialize(port_creator_fn, is_input)[source]
class YarpPublisher(component_instance, kwargs)[source]

Bases: morse.middleware.yarp_datastream.YarpPort

default(ci)[source]
encode(bottle)[source]
encode_message(bottle, data, component_name)[source]

Prepare the content of the bottle

This function can be recursively called in case of list processing

initialize()[source]
class YarpReader(component_instance, kwargs)[source]

Bases: morse.middleware.yarp_datastream.YarpPort

default(ci)[source]
initialize()[source]

morse.middleware.yarp_json_request_manager module

class YarpRequestManager[source]

Bases: morse.core.request_manager.RequestManager

Implements services to control the MORSE simulator over YARP

The syntax of requests is: >>> id component_name service [params with Python syntax]

‘id’ is an identifier set by the client to conveniently identify the request. It must be less that 80 chars in [a-zA-Z0-9].

The server answers: >>> id OK|FAIL result_in_python|error_msg

finalization()[source]
initialization()[source]
main()[source]

Read commands from the ports, and prepare the response

on_service_completion(request_id, results)[source]
post_registration(component_name, service, is_async)[source]

Register a connection of a service with YARP

morse.middleware.yarp_request_manager module

class YarpRequestManager[source]

Bases: morse.core.request_manager.RequestManager

Implements services to control the MORSE simulator over YARP

The syntax of requests is: >>> id component_name service [params with Python syntax]

‘id’ is an identifier set by the client to conveniently identify the request. It must be less that 80 chars in [a-zA-Z0-9].

The server answers: >>> id OK|FAIL result_in_python|error_msg

finalization()[source]
initialization()[source]
main()[source]

Read commands from the ports, and prepare the response

on_service_completion(request_id, results)[source]
post_registration(component_name, service, is_async)[source]

Register a connection of a service with YARP

Module contents