upkie 6.1.0
Open-source wheeled biped robots
Loading...
Searching...
No Matches
upkie.envs.wrappers.add_lag_to_action.AddLagToAction Class Reference

Model lag by applying a low-pass filter to the action of an environment. More...

Public Member Functions

def __init__ (self, env, Union[float, gym.spaces.Box] time_constant)
 Initialize wrapper. More...
 
def reset (self, **kwargs)
 Reset the environment. More...
 
Tuple[np.ndarray, float, bool, bool, dict] step (self, np.ndarray action)
 Step the environment. More...
 

Public Attributes

 filtered_action
 Wrapped action after low-pass filtering.
 
 time_constant
 Cutoff period in seconds of a low-pass filter applied to the action.
 
 time_constant_box
 Box space from which the time constant is sampled at every reset of the environment.
 

Detailed Description

Model lag by applying a low-pass filter to the action of an environment.

Note that there is a difference between "delay" and "lag":

  • Delay is a fixed time interval corresponding to the time it takes the input to affect the output, e.g. output(t + delay) = input(t).
  • Lag is a phase shift in the system's response. It can be thought of as a gradual response to input changes where the output does not immediately match the input, e.g. d/dt{output}(t) = lag * (input(t) - output(t)).

In this wrapper, we model lag where the output (action forward to the wrapped environment) is a low-pass filtered version of the input (action passed to step).

Constructor & Destructor Documentation

◆ __init__()

def upkie.envs.wrappers.add_lag_to_action.AddLagToAction.__init__ (   self,
  env,
Union[float, gym.spaces.Box]  time_constant 
)

Initialize wrapper.

Parameters
envEnvironment to wrap.
time_constantCutoff period in seconds of the low-pass filter applied to the action. If a Box is provided, couple of lower and upper bounds for the action: a new time constant is sampled uniformly at random between these bounds at every reset of the environment.

Member Function Documentation

◆ reset()

def upkie.envs.wrappers.add_lag_to_action.AddLagToAction.reset (   self,
**  kwargs 
)

Reset the environment.

Parameters
kwargsKeyword arguments forwarded to the wrapped environment.

◆ step()

Tuple[np.ndarray, float, bool, bool, dict] upkie.envs.wrappers.add_lag_to_action.AddLagToAction.step (   self,
np.ndarray   action 
)

Step the environment.

Parameters
actionAction from the agent.
Returns
Tuple with (observation, reward, terminated, truncated,info). See upkie.envs.upkie_base_env.UpkieBaseEnv.step for details.

The documentation for this class was generated from the following file: