Constant Speed Load

Class Description

class gym_electric_motor.physical_systems.mechanical_loads.ConstantSpeedLoad(omega_fixed=0, load_initializer=None, **kwargs)[source]

Constant speed mechanical load system which will always set the speed to a predefined value.

Parameters:

omega_fixed (float)) – Fix value for the speed in rad/s.

HAS_JACOBIAN = True

Parameter indicating if the class is implementing the optional jacobian function

get_state_space(omega_range)
Parameters:

omega_range (Tuple(int,int)) – Lower and upper values the motor can generate for omega normalized to (-1, 1)

Returns:

Lowest and highest possible values for all states normalized to (-1, 1)

Return type:

Tuple(dict,dict)

initialize(state_space, state_positions, nominal_state, **__)

Initializes the state of the load on an episode start.

Values can be given as a constant or sampled random out of a statistical distribution. Initial value is in range of the nominal values or a given interval.

Parameters:
  • nominal_state (list) – nominal values for each state given from physical system

  • state_space (gymnasium.spaces.Box) – normalized state space boundaries

  • state_positions (dict) – indexes of system states

property initializer

Returns: dict: The motors initial state and additional initializer parameters

property j_total

Returns: float: Total moment of inertia affecting the motor shaft.

property limits

Returns: dict(float): Mapping of the motor states to their limit values.

mechanical_jacobian(t, mechanical_state, torque)[source]

Calculation of the jacobians of the mechanical-ODE for each of the mechanical state.

Overriding this method is optional for each subclass. If it is overridden, the parameter HAS_JACOBIAN must also be set to True. Otherwise, the jacobian will not be called.

Parameters:
  • t (float) – Current time of the system.

  • mechanical_state (ndarray(float)) – Current state of the mechanical system.

  • torque (float) – Generated input torque by the electrical motor.

Returns:

[0]: Derivatives of the mechanical_state-odes over the mechanical_states shape:(states x states) [1]: Derivatives of the mechanical_state-odes over the torque shape:(states,)

Return type:

Tuple(ndarray, ndarray)

mechanical_ode(*_, **__)[source]

Calculation of the derivatives of the mechanical-ODE for each of the mechanical states.

Parameters:
  • t (float) – Current time of the system.

  • mechanical_state (ndarray(float)) – Current state of the mechanical system.

  • torque (float) – Generated input torque by the electrical motor.

Returns:

Derivatives of the mechanical state for the given input torque.

Return type:

ndarray(float)

next_generator()

Sets a new reference generator for a new episode.

property nominal_values

Returns: dict(float): Mapping of the motor states to their nominal values

property omega_fixed

Returns: float: Constant value for omega in rad/s.

property random_generator

The random generator that has to be used to draw the random numbers.

reset(state_space, state_positions, nominal_state, **__)

Reset the motors state to a new initial state. (Default 0)

Parameters:
  • nominal_state (list) – nominal values for each state given from physical system

  • state_space (gymnasium.Box) – normalized state space boundaries

  • state_positions (dict) – indexes of system states

Returns:

The initial motor states.

Return type:

numpy.ndarray(float)

seed(seed=None)

The function to set the seed.

This function is called by within the global seed call of the environment. The environment passes the sub-seed to this component that is generated based on the source-seed of the env.

Parameters:

seed ((np.random.SeedSequence, None)) – Seed sequence to derive new seeds and reference generators at every episode start. Default: None (a new SeedSequence is generated).

Returns:

A list containing all seeds within this RandomComponent. In general, this list has length 1. If the RandomComponent holds further RandomComponent instances, the list has to contain also these entropies. The entropy of this instance has to be placed always at first place.

Return type:

List(int)

property seed_sequence

The base seed sequence that generates the sub generators and sub seeds at every environment reset.

set_j_rotor(j_rotor)
Parameters:

j_rotor (float) – The moment of inertia of the rotor shaft of the motor.

property state_names

Returns: list(str): Names of the states in the mechanical-ODE.