morse.middleware package¶
Subpackages¶
- morse.middleware.hla package
- morse.middleware.mavlink package
- morse.middleware.moos package
- Submodules
- morse.middleware.moos.abstract_moos module
- morse.middleware.moos.gps module
- morse.middleware.moos.gyroscope module
- morse.middleware.moos.imu module
- morse.middleware.moos.light module
- morse.middleware.moos.motion module
- morse.middleware.moos.pose module
- morse.middleware.moos.sick module
- Module contents
- morse.middleware.pocolibs package
- Subpackages
- morse.middleware.pocolibs.actuators package
- morse.middleware.pocolibs.overlays package
- Submodules
- morse.middleware.pocolibs.overlays.fingers module
- morse.middleware.pocolibs.overlays.platine_overlay module
- morse.middleware.pocolibs.overlays.rflex_overlay module
- morse.middleware.pocolibs.overlays.stereopixel_overlay module
- morse.middleware.pocolibs.overlays.velodyne_overlay module
- morse.middleware.pocolibs.overlays.viam_overlay module
- Module contents
- morse.middleware.pocolibs.sensors package
- Submodules
- morse.middleware.pocolibs.sensors.human_posture module
- morse.middleware.pocolibs.sensors.platine_posture module
- morse.middleware.pocolibs.sensors.pom module
- morse.middleware.pocolibs.sensors.stereopixel module
- morse.middleware.pocolibs.sensors.target module
- morse.middleware.pocolibs.sensors.velodyne module
- morse.middleware.pocolibs.sensors.viam module
- morse.middleware.pocolibs.sensors.viman module
- Module contents
- Module contents
- Subpackages
- morse.middleware.pprzlink package
- morse.middleware.ros package
- Subpackages
- Submodules
- morse.middleware.ros.abstract_ros module
- morse.middleware.ros.accelerometer module
- morse.middleware.ros.battery module
- morse.middleware.ros.clock module
- morse.middleware.ros.depth_camera module
- morse.middleware.ros.destination module
- morse.middleware.ros.force_torque module
- morse.middleware.ros.gps module
- morse.middleware.ros.imu module
- morse.middleware.ros.infrared module
- morse.middleware.ros.jido_posture module
- morse.middleware.ros.jointstate module
- morse.middleware.ros.jointtrajectorycontrollers module
- morse.middleware.ros.kuka_jointstate module
- morse.middleware.ros.kuka_jointstate_pub module
- morse.middleware.ros.laserscanner module
- morse.middleware.ros.light module
- morse.middleware.ros.motion_vw module
- morse.middleware.ros.motion_xyw module
- morse.middleware.ros.odometry module
- morse.middleware.ros.orientation module
- morse.middleware.ros.platine module
- morse.middleware.ros.pose module
- morse.middleware.ros.ptu_posture module
- morse.middleware.ros.quadrotor_dynamic module
- morse.middleware.ros.read_asctec_ctrl_input module
- morse.middleware.ros.read_pose module
- morse.middleware.ros.read_twist module
- morse.middleware.ros.rotorcraft_attitude module
- morse.middleware.ros.semantic_camera module
- morse.middleware.ros.static_tf module
- morse.middleware.ros.tfMessage module
- morse.middleware.ros.velocity module
- morse.middleware.ros.video_camera module
- morse.middleware.ros.waypoint2D module
- Module contents
- morse.middleware.sockets package
- morse.middleware.yarp package
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
¶
-
morse.middleware.hla_datastream module¶
-
class
HLABaseNode
(klass, fom, node_name, federation, sync_point, sync_register, time_sync, timestep, lookahead)[source]¶ Bases:
object
-
class
HLADatastreamManager
(args, kwargs)[source]¶ Bases:
morse.core.datastream.DatastreamManager
External communication using sockets.
morse.middleware.mavlink_datastream module¶
-
class
MavlinkDatastreamManager
(args, kwargs)[source]¶ Bases:
morse.core.datastream.DatastreamManager
External communication using Mavlink protocol
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
PocolibsDataStreamInput
(component_instance, kwargs)[source]¶ Bases:
morse.middleware.abstract_datastream.AbstractDatastream
-
class
PocolibsDataStreamOutput
(component_instance, kwargs)[source]¶ Bases:
morse.middleware.abstract_datastream.AbstractDatastream
-
class
PocolibsDatastreamManager
(args, kwargs)[source]¶ Bases:
morse.core.datastream.DatastreamManager
Handle communication between Blender and Pocolibs.
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¶
-
initialization
()[source]¶ This method is meant to be overloaded by middlewares to perform specific initializations.
Must return True is the initialization is successful, False in other cases.
-
main
()[source]¶ This is the main method of the RequestManagerClass: it reads external incoming requests, dispatch them through the
on_incoming_request()
method, and write back answers.Subclasses are expected to overload this method.
-
on_service_completion
(intern_rqst_id, result)[source]¶ This method is called when a asynchronous request completes.
Subclasses are expected to overload this method with code to notify the original request emitter.
Parameters: - request_id (uuid) – the request id, as return by
on_incoming_request()
when processing an asynchronous request - result – the service execution result.
- request_id (uuid) – the request id, as return by
-
post_registration
(component, service, is_async)[source]¶ This method is meant to be overloaded by middlewares that have specific initializations to do when a new service is exposed.
Parameters: - component_name (string) – name of the component that declare this service
- service_name (string) – Name of the service (if not overloaded in the @service decorator, should be the Python function name that implement the service)
- is_async (boolean) – If true, means that the service is asynchronous.
Returns: True if the registration succeeded.
Return type: boolean
-
morse.middleware.pprzlink_datastream module¶
-
class
PprzlinkDatastreamManager
(args, kwargs)[source]¶ Bases:
morse.core.datastream.DatastreamManager
External communication using PPRZLINK protocol over IVY
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:
object
Implements a minimal action state machine.
See http://www.ros.org/wiki/actionlib/DetailedDescription for the possible states.
-
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]¶ This method is meant to be overloaded by middlewares to perform specific finalizations.
Must return True is the finalization is successful, False in other cases.
-
initialization
()[source]¶ This method is meant to be overloaded by middlewares to perform specific initializations.
Must return True is the initialization is successful, False in other cases.
-
main
()[source]¶ This is the main method of the RequestManagerClass: it reads external incoming requests, dispatch them through the
on_incoming_request()
method, and write back answers.Subclasses are expected to overload this method.
-
on_service_completion
(request_id, result)[source]¶ This method is called when a asynchronous request completes.
Subclasses are expected to overload this method with code to notify the original request emitter.
Parameters: - request_id (uuid) – the request id, as return by
on_incoming_request()
when processing an asynchronous request - result – the service execution result.
- request_id (uuid) – the request id, as return by
-
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()
andros_service()
decorators. If none is set, the action/service is discarded.
-
-
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>
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]¶ Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
-
-
class
SocketDatastreamManager
(args, kwargs)[source]¶ Bases:
morse.core.datastream.DatastreamManager
External communication using sockets.
-
class
SocketPublisher
(component_instance, kwargs)[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 inmorse.core.status
.-
initialization
()[source]¶ This method is meant to be overloaded by middlewares to perform specific initializations.
Must return True is the initialization is successful, False in other cases.
-
main
()[source]¶ This is the main method of the RequestManagerClass: it reads external incoming requests, dispatch them through the
on_incoming_request()
method, and write back answers.Subclasses are expected to overload this method.
-
on_service_completion
(request_id, results)[source]¶ This method is called when a asynchronous request completes.
Subclasses are expected to overload this method with code to notify the original request emitter.
Parameters: - request_id (uuid) – the request id, as return by
on_incoming_request()
when processing an asynchronous request - result – the service execution result.
- request_id (uuid) – the request id, as return by
-
post_registration
(component, service, is_async)[source]¶ This method is meant to be overloaded by middlewares that have specific initializations to do when a new service is exposed.
Parameters: - component_name (string) – name of the component that declare this service
- service_name (string) – Name of the service (if not overloaded in the @service decorator, should be the Python function name that implement the service)
- is_async (boolean) – If true, means that the service is asynchronous.
Returns: True if the registration succeeded.
Return type: boolean
-
morse.middleware.text_datastream module¶
-
class
BasePublisher
(component_instance, kwargs)[source]¶ Bases:
morse.middleware.abstract_datastream.AbstractDatastream
-
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.
-
class
YarpPort
(component_instance, kwargs)[source]¶ Bases:
morse.middleware.abstract_datastream.AbstractDatastream
-
class
YarpPublisher
(component_instance, kwargs)[source]¶ Bases:
morse.middleware.yarp_datastream.YarpPort
-
default
(ci)[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.
-
-
class
YarpReader
(component_instance, kwargs)[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]¶ This method is meant to be overloaded by middlewares to perform specific finalizations.
Must return True is the finalization is successful, False in other cases.
-
initialization
()[source]¶ This method is meant to be overloaded by middlewares to perform specific initializations.
Must return True is the initialization is successful, False in other cases.
-
on_service_completion
(request_id, results)[source]¶ This method is called when a asynchronous request completes.
Subclasses are expected to overload this method with code to notify the original request emitter.
Parameters: - request_id (uuid) – the request id, as return by
on_incoming_request()
when processing an asynchronous request - result – the service execution result.
- request_id (uuid) – the request id, as return by
-
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]¶ This method is meant to be overloaded by middlewares to perform specific finalizations.
Must return True is the finalization is successful, False in other cases.
-
initialization
()[source]¶ This method is meant to be overloaded by middlewares to perform specific initializations.
Must return True is the initialization is successful, False in other cases.
-
on_service_completion
(request_id, results)[source]¶ This method is called when a asynchronous request completes.
Subclasses are expected to overload this method with code to notify the original request emitter.
Parameters: - request_id (uuid) – the request id, as return by
on_incoming_request()
when processing an asynchronous request - result – the service execution result.
- request_id (uuid) – the request id, as return by
-