Base Env
cbfpy.envs.base_env
Base Environment
This is a convenient structure for building demo environments to test CBFs. However, it is not necessary to use this.
For instance, going back to the CBF usage pseudocode,
while True:
z = get_state()
z_des = get_desired_state()
u_nom = nominal_controller(z, z_des)
u = cbf.safety_filter(z, u_nom)
apply_control(u)
step()
get_state
, get_desired_state
, apply_control
, and step
methods in
any derived environments.
BaseEnv
Bases: ABC
Simulation environment Abstract Base Class for testing CBFs
Any environment inheriting from this class should implement the following methods:
step
: Run a single simulation stepget_state
: Get the current state of the robotget_desired_state
: Get the desired state of the robotapply_control
: Apply a control input to the robot
Source code in cbfpy/envs/base_env.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
step()
abstractmethod
Runs a single simulation step for the environment
This should update any dynamics and visuals
Source code in cbfpy/envs/base_env.py
36 37 38 39 40 41 42 |
|
get_state()
abstractmethod
Returns the current state of the environment
Returns:
Name | Type | Description |
---|---|---|
ArrayLike |
ArrayLike
|
State, shape (n,) |
Source code in cbfpy/envs/base_env.py
44 45 46 47 48 49 50 51 |
|
get_desired_state()
abstractmethod
Returns the desired state of the environment
Returns:
Name | Type | Description |
---|---|---|
ArrayLike |
ArrayLike
|
Desired state, shape (n,) |
Source code in cbfpy/envs/base_env.py
53 54 55 56 57 58 59 60 |
|
apply_control(u)
abstractmethod
Applies the control input to the environment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
u |
ArrayLike
|
Control, shape (m,) |
required |
Source code in cbfpy/envs/base_env.py
62 63 64 65 66 67 68 69 |
|