Mechanical Loads
Available Mechanical Loads:
MechanicalLoad Base Class
- class gym_electric_motor.physical_systems.mechanical_loads.MechanicalLoad(state_names=None, j_load=0.0, load_initializer=None)[source]
Bases:
RandomComponent
The MechanicalLoad is the base class for all the mechanical systems attached to the electrical motors rotor.
It contains an mechanical ode system as well as the state names, limits and nominal values of the mechanical quantities. The only required state is ‘omega’ as the rotational speed of the motor shaft in rad/s. ConstantSpeedLoad can be initialized with the initializer as an class parameter by instantiation. ExternalSpeedLoad takes the first value of the SpeedProfile as initial value.
Initialization is given by initializer(dict). Can be a constant state value or random value in given interval. dict should be like:
- { ‘states’(dict): with state names and initial values
- ‘interval’(array like): boundaries for each state
(only for random init), shape(num states, 2)
‘random_init’(str): ‘uniform’ or ‘normal’ ‘random_params(tuple): mue(float), sigma(int)
- Example initializer(dict) for constant initialization:
{ ‘states’: {‘omega’: 16.0}}
- Example initializer(dict) for random initialization:
{ ‘random_init’: ‘normal’}
- Parameters:
- initialize(state_space, state_positions, nominal_state, **__)[source]
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.
- 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:
- 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(t, mechanical_state, torque)[source]
Calculation of the derivatives of the mechanical-ODE for each of the mechanical states.
- next_generator()
Sets a new reference generator for a new episode.
- reset(state_space, state_positions, nominal_state, **__)[source]
Reset the motors state to a new initial state. (Default 0)
- 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)
- set_j_rotor(j_rotor)[source]
- Parameters:
j_rotor (float) – The moment of inertia of the rotor shaft of the motor.
- HAS_JACOBIAN = False
Parameter indicating if the class is implementing the optional jacobian function
- OMEGA_IDX = 0
- 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.
- property nominal_values
Returns: dict(float): Mapping of the motor states to their nominal values
- property random_generator
The random generator that has to be used to draw the random numbers.
- property seed_sequence
The base seed sequence that generates the sub generators and sub seeds at every environment reset.
- property state_names
Returns: list(str): Names of the states in the mechanical-ODE.