CraneFMU

class py_crane.crane_fmu.CraneFMU(degrees: bool = False, u_length: str = 'm', u_time: str = 's', **kwargs: Any)

Bases: Model, Crane

The FMU definition and packaging of a Crane object built from stiff booms.

Defines the FMI interface of a Crane using the component_model and the PythonFMU packages. The crane should first be instantiated and then the booms added, using CraneFMU.add_boom().

With respect to Crane and Boom refer to the dedicated modules Crane and Boom where the available arguments, properties and methods are listed and explained. Here only the additional FMU interface definition is documented.

CraneFMU defines the attributes Crane.velocity, Crane.d_velocity, Crane.angular, Crane.d_angular, Crane.d2_angular, Crane.force and Crane.torque as interface variables to make them accessible in simulations.

Additional methods CraneFMU.add_boom(), CraneFMU.ensure_boom(), CraneFMU.exit_initialization_mode() and CraneFMU.do_step() are used automatically in the background and should not be a concern for users of the module. Most of the interface variables are defined in BoomFMU.

Note

CraneFMU is still an abstract crane. It needs another extension to define concrete booms and interfaces. See MobileCrane on how this can be done.

Parameters:
  • u_length (str) – Definition of the common crane length units. Default: meters

  • u_time (str) – Definition of the common crane time units. Default: seconds

  • **kwargs (Any) – Arguments forwarded to Crane (and sub-class Model) The arguments name, description, author and version should be remembered, since they are required by the Model sub-class.

__init__(degrees: bool = False, u_length: str = 'm', u_time: str = 's', **kwargs: Any)

Initialize the crane object.

Methods

__init__([degrees, u_length, u_time])

Initialize the crane object.

add_boom(*args, **kwargs)

Add a boom to the crane.

add_derivative(dername, basename)

Add the derivative of basename to the dict of virtual derivatives.

add_variable(*args, **kwargs)

Add a variable, automatically including the owner model in the instantiation call.

boom_by_name(name)

Retrieve a boom object by name.

booms(*[, reverse])

Iterate through the booms.

build([script, project_files, dest, ...])

Build the FMU, resulting in the model-name.fmu file.

calc_statics_dynamics([dt])

Run calc_statics_dynamics() on all booms in reverse order, to get all Boom._c_m_sub and dynamics updated.

check_flags(flags)

Check and collect provided flags dictionary and return the non-default flags.

dirty_do()

Run on_set on all dirty variables.

dirty_ensure(var)

Ensure that the variable var is registered in self._dirty.

do_step(current_time, step_size)

Do a simulation step of size 'step_size at time 'currentTime.

ensure_boom(boom)

Ensure that the boom is registered before structured variables are added to it.

ensure_requirements(existing_file, temp_file)

Return the path to the component-model requirements file.

enter_initialization_mode()

exit_initialization_mode()

Initialize the model after initial variables are set.

get_boolean(vrs)

get_integer(vrs)

get_real(vrs)

get_string(vrs)

log(msg[, status, category, debug])

Log a message to the FMU logger.

make_copyright_license([copyright, license])

Prepare a copyright notice (one line) and a license text (without copyright line).

owner_hierarchy(parent)

Analyse the parent of a variable down to the Model and return the owners as list.

ref_to_var(vr)

Find Variable and sub-index (for compound variable), based on a value_reference value.

register_variable(var[, nested])

Register a variable as FMU interface.

rot([rpy])

Get/Set a new absolute rotation through an Euler angle.

rotate(rpy[, absolute])

Set the orientation to a new value according to ISO 1151–2 (roll,pitch,yaw) - rotations.

set_boolean(vrs, values)

set_integer(vrs, values)

set_real(vrs, values)

set_string(vrs, values)

setup_experiment([start_time, stop_time, ...])

Minimum version of setup_experiment, just setting the start_time.

terminate()

to_crane_angle_default(rpy)

Transform the given extrinsic euler angles into the the coordinate system used by the crane.

to_xml([model_options])

Build the XML FMI2 modelDescription.xml tree.

variable_by_name(name)

Return Variable object related to name, or None, if not found.

vars_iter([key])

Iterate over model variables ('vars').

xml_unit_definitions()

Make the xml element for the unit definitions used in the model.

Attributes

angular

Get the current euler angle of the crane (internally stored as Rot).

boom0

d_angular

Get the current angular velocity (euler angles).

dirty

instances

log_categories

position

units

velocity

to_crane_angle

add_boom(*args: Any, **kwargs: Any) BoomFMU

Add a boom to the crane. Overrides Crane.add_boom() to ensure that BoomFMU is added.

This method represents the recommended way to contruct a crane and then add the booms. The model and anchor0 parameters are automatically added to the boom when it is instantiated.

Parameters:
  • *args – all Boom positional parameters, excluding model and anchor0

  • **kwargs – all Boom keyword parameters, excluding model and anchor0

do_step(current_time: float, step_size: float) bool

Do a simulation step of size ‘step_size at time ‘currentTime. Note: this is only the generic part of this function. Models should call this first through super().do_step and then do their own stuff.

ensure_boom(boom: BoomFMU)

Ensure that the boom is registered before structured variables are added to it. Otherwise their owner does not exist.

exit_initialization_mode()

Initialize the model after initial variables are set. It is important that the crane wire is stabilized after initial boom settings, otherwise it would perform wild initial movements.