morse.helpers package

Submodules

morse.helpers.components module

add_data(name, default_value, type='', doc='(no documentation available yet)', level='all')[source]

Defines a new data field for this component, either for export (sensors) or for import (actuators).

Note

Several fields with the same name may be present if they belong to different ‘abstraction levels’.

Parameters:
  • name – name of the field
  • default_value – initial value of the field
  • type – indicative type value, currently only used for documentation
  • doc – description of the field
  • level – (default: all) abstraction level this field belong to. Only useful when levels are defined for the component with add_level statements.
add_level(name, classname, doc='(no documentation available yet)', default=False)[source]

Defines an abstraction level for a component.

Abstraction levels are predefined subsets of the component output or input, defining a particular functional level for your component.

Note

Two special level names are reserved: all and default. You can not use them.

Parameters:
  • name – name of the level
  • classpath – classpath (ie, module path + classname) that implements the level, or None to use the current class.
  • doc – short description of the level.
add_property(python_name, default_value, name, type='', doc='(no documentation available yet)')[source]

Add a property to the current class of component

Parameters:
  • python_name – name of the Python variable. It will be dynamically added to the component Python script.
  • default_value – the default value
  • name (string) – the name of the property. If used in the Blender logic bricks, it must match the Blender name.
  • type – type of the property, for documentation
  • doc – description of the property.

morse.helpers.controller module

A collection of simple controllers

For now, implement only a simple PID controller

class PIDController(kp=1.0, kd=1.0, ki=1.0, limits_integrator=10.0)[source]

Bases: object

reset()[source]
setpoint
update(measured_value)[source]
clamp(n, smallest, largest)[source]

morse.helpers.coordinates module

class CoordinateConverter(latitude, longitude, altitude, angle_east_blender_x)[source]

Bases: object

Allow to convert coordinates from Geodetic to LTP to ECEF-r …

A = 6378137.0
A2 = 40680631590769.0
ECC = 0.08181919191
ECC2 = 0.00669438016480541
ECC4 = 4.481472579094011e-05
F = 0.0033528106647474805
R = 6378137.0
angle_against_geographic_north(orientation)[source]

Return the angle against geographic_north, as returned by a compass, i.e. between [0, 2 pi], clockwise

blender_to_ltp(xt)[source]
ecef_to_geocentric(xt)[source]
ecef_to_geodetic(xe)[source]

converts point in ECEF-r coordinates into Geodetic (GPS) via Vermeille’s method

ecef_to_ltp(xt)[source]

converts point in ECEF-r coordinates to LTP(Blender)

geocentric_to_ecef(xt)[source]
geodetic_to_ecef(P)[source]

converts gps-data(radians) to ECEF-r coordinates

geodetic_to_geocentric(lat, h)[source]

Convert geodetic latitude to geocentric latitude

Param:latitude geodetic latitude in degree
Param:h height against sea level in meter
Returns:geocentric latitude in degree
geodetic_to_ltp(xe)[source]
static instance()[source]
ltp_to_blender(xt)[source]
ltp_to_ecef(xt)[source]

converts point in LTP(Blender) to ECEF-r coordinates

ltp_to_geodetic(xe)[source]

morse.helpers.filt2 module

class Filt2(wn=1.0, ksi=1.0)[source]

Bases: object

filtre du second ordre Yann

init()[source]
setParam(wn, ksi)[source]
simulate(u, dt)[source]

morse.helpers.joints module

class Joint6DoF(obj1, obj2, pos_pivot=[0.0, 0.0, 0.0], rot_pivot=[0.0, 0.0, 0.0], may_collide=False)[source]

Bases: object

angular_spring(axis, spring, damping)[source]
angular_velocity(axis, velocity)[source]
euler_angle(axis)[source]
free_rotation_dof(axis)[source]
free_translation_dof(axis)[source]
limit_rotation_dof(axis, min_value, max_value)[source]
limit_translation_dof(axis, min_value, max_value)[source]
linear_spring(axis, spring, damping)[source]
linear_velocity(axis, velocity)[source]
lock_rotation_dof(axis)[source]
lock_translation_dof(axis)[source]
pos(axis)[source]

morse.helpers.loading module

Loading Helpers for ‘classpath’ configuration

create_instance(classpath, *args, **kwargs)[source]

Creates an instances of a class.

create_instance_level(classpath, level, *args, **kwargs)[source]

Creates an instances of a class from a component abstration level.

get_class(classpath)[source]

Returns the class object from a full classpath (like toto.tata.MyTata)

load_module_attribute(module_name, attribute_name)[source]

Dynamically import a Python attribute.

morse.helpers.morse_logging module

class MorseFormatter(*args, **kwargs)[source]

Bases: logging.Formatter

format(record)[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

morse.helpers.morse_math module

normalise_angle(angle)[source]

Force the given angle to be between PI and -PI

This function expects an angle given in radians It will reduce the input angle to be less than PI, and give it the correct sign.

Using new method proposed by David Hodo: hododav@tigermail.auburn.edu

rotation_direction(current_angle, target_angle, tolerance, speed)[source]

Test the direction in which a rotation should be made

Using the current angle of a component and the next desired angle. Angles are expected in radians

morse.helpers.passive_objects module

active_objects()[source]

Returns all active objects in current scene, ie objects that have their ‘Object’ property set to True.

details(obj)[source]

Returns a dictionary containing the differents properties for a given active object.

If the object is not active (ie, it has no ‘Object’ property, or the property is set to False), None is returned.

If no label is available, it defaults to the Blender name. The description field may be an empty string. If no type is available, it defaults to ‘Object’. If the graspable flag is not present, it defaults to False.

Parameters:name – the Blender name of the object.
Returns:a dictionary {‘label’:string, ‘description’:string, ‘type’:string, ‘graspable’:bool}
graspable_objects()[source]

Returns all objects in current scene that have the ‘Graspable’ property set to True, amongst active objects.

label(obj)[source]

Returns the label of a given active object.

If the object is not active (ie, it has no ‘Object’ property, or the property is set to False), None is returned.

If no label is available, it defaults to the Blender name.

Parameters:name – the Blender name of the object.
Returns:the label
obj_from_label(label)[source]

Returns the label of a given active object.

If the object is not active (ie, it has no ‘Object’ property, or the property is set to False), None is returned.

If no label is available, it defaults to the Blender name.

Parameters:name – the Blender name of the object.
Returns:the label

morse.helpers.statistics module

Statistics helper for Morse usage

class Stats[source]

Bases: object

A simple class to compute basic statistics on some values, computed incrementaly

update(x)[source]
variance

morse.helpers.transformation module

class Transformation3d(obj)[source]

Bases: object

Transformation3d represents a generic 3D transformation. It is used by each component of the simulator to know their position in the world. Blender does not propose such an interface, only some rotation matrix and translation vector.

Internally, we store an internal 4x4 matrix, and use it to compute transformation. the euler representation is then calculated on base of matrix (euler ZYX convention)

Note : Blender store its matrix in column major mode …

distance(t3d)[source]

Compute the 3d distance between two transformations.

nor self, nor t3d are modified by the call of this method

distance_2d(t3d)[source]

Compute the 2d distance between two transformations.

nor self, nor t3d are modified by the call of this method

pitch

Returns Euler Y axis, in radian

roll

Returns Euler X axis, in radian

rotation

Returns the rotation as a unit quaternion

rotation_matrix

Returns the rotation as a 3x3 matrix

transformation3d_with(t3d)[source]

Compute the transformation between itself and another transformation t3d. In other words, A.transformation3d_with(B) returns inv(A) * B.

self is not modified by the call of this function

translation
update(obj)[source]

Update the transformation3D to reflect the transformation between obj (a blender object) and the blender world origin

update_Y_forward(obj)[source]

Update the transformation3D to reflect the transformation between obj (a blender object) and the blender world origin. In this case, the robot moves forwar along the Y axis.

Change the values of yaw, pitch, roll for Blender vehicles Robots that use the Blender vehicle constraints move in the direction of the Y axis, contrary to most of the MORSE components that move along the X axis.

x

Return the translation along the x-axis

y

Return the translation along the y-axis

yaw

Returns Euler Z axis, in radian

z

Return the translation along the z-axis

morse.helpers.velocity module

angular_velocities(prev, now, dt)[source]

Return angular velocities between two poses

Parameters:
  • prev – the precedent pose, as a Transformation3d
  • now – the current pose, as a Transformation3d
  • dt – time elapsed between the two poses acquisition, in sec

See https://www.astro.rug.nl/software/kapteyn/_downloads/attitude.pdf for equation description

linear_velocities(prev, now, dt)[source]

Return angular velocities between two poses

Parameters:
  • prev – the precedent pose, as a Transformation3d
  • now – the current pose, as a Transformation3d
  • dt – time elapsed between the two poses acquisition, in sec

Module contents