morse.middleware package

Subpackages

Submodules

morse.middleware.abstract_datastream module

class AbstractDatastream(component_instance, kwargs)[source]

Bases: builtins.object

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

component_name[source]
data[source]
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, lookahead)[source]

Bases: builtins.object

finalize()[source]

Close all open HLA connections.

init_time()[source]
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, lookahead)[source]

Bases: hla.rti.FederateAmbassador

advance_time()[source]
announceSynchronizationPoint(label, tag)[source]
attributeOwnershipAcquisitionNotification(obj, attr)[source]
attribute_handle(name, obj_handle)[source]
delete_object(name)[source]
discoverObjectInstance(obj, objectclass, name)[source]
federationSynchronized(label)[source]
get_attributes(obj_name)[source]
get_object(name)[source]
initialize_time_regulation()[source]
object_handle(name)[source]
publish_attributes(name, obj_handle, attr_handles)[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: builtins.object

exception InvalidRead(value)[source]

Bases: builtins.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: builtins.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

class RosAction(manager, component, action, rostype)[source]

Bases: builtins.object

Implements a minimal action state machine.

See http://www.ros.org/wiki/actionlib/DetailedDescription for the possible states.

get_id_from_internal_id(morse_id)[source]
getstatus(id)[source]
manage_internal_id(morse_id)[source]

Check if this ROS action manager manages the given internal request ID.

This is used by RosRequestManager to dispatch the service ‘on completion’ event.

on_cancel(goal_id)[source]
on_goal(goal)[source]
on_result(morse_id, state, result)[source]
publish_result(goal_id, result)[source]
set_internal_id(id, morse_id)[source]
setstatus(id, status)[source]
class RosRequestManager[source]

Bases: morse.core.request_manager.RequestManager

add_ros_handler(component_name, service_name)[source]

Dynamically creates custom ROS->MORSE dispatchers for ROS services only.

ROS actions are dealt with in the RosAction class.

finalization()[source]
initialization()[source]
main()[source]
on_service_completion(request_id, result)[source]
post_registration(component_name, service_name, is_async)[source]

We create here ROS services (for synchronous services) and ROS actions (for asynchronous services).

In order not to interfere with neither ROS own service wrapping mechanism or MORSE service invokation mechanisms, we create here, ‘on the fly’, handlers for each service exposed through ROS.

ROS requires type for the services/actions. Those can be set with the ros_action() and ros_service() decorators. If none is set, the action/service is discarded.

register_ros_action(method, component_name, service_name)[source]
register_ros_service(method, component_name, service_name)[source]
ros_action(fn=None, type=None, name=None)[source]

The @ros_action decorator.

This decorator is very similar to the standard morse.core.services.async_service() decorator. It sets a class method to be a asynchronous service, exposed as a ROS action of type type.

This decorator can only be used on methods in classes inheriting from morse.core.object.Object.

Parameters:
  • fn (callable) – [automatically set by Python to point to the decorated function]
  • type (class) – you MUST set this parameter to define the type of the ROS action.
  • name (string) – by default, the name of the service is the name of the method. You can override it by setting the ‘name’ argument. Your ROS action will appear as /component_instance/<name>/...
ros_service(fn=None, type=None, component=None, name=None)[source]

The @ros_service decorator.

This decorator is very similar to the standard morse.core.services.service() decorator. It sets a free function or class method to be a (synchronous) service, exposed as a ROS service of type type.

This decorator works both with free function and for methods in classes inheriting from morse.core.object.Object. In the former case, you must specify a component (your service will belong to this namespace), in the later case, it is automatically set to the name of the corresponding MORSE component.

Parameters:
  • fn (callable) – [automatically set by Python to point to the decorated function]
  • type (class) – you MUST set this parameter to define the type of the ROS action.
  • component (string) – you MUST set this parameter to define the name of the component which export the service ONLY for free functions. Cf explanation above.
  • name (string) – by default, the name of the service is the name of the method. You can override it by setting the ‘name’ argument. Your ROS service will appear as /<name>
ros_timer(callable_obj, frequency)[source]

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