Interface
cartpole.common
Limits
Constraints of cart state, used for control and cartpole parametrization.
ATTRIBUTE | DESCRIPTION |
---|---|
cart_position |
max absolute cart position (m)
TYPE:
|
cart_velocity |
max absolute cart velocity (m/s)
TYPE:
|
cart_acceleration |
max absolute cart acceleration (m/s^2)
TYPE:
|
Source code in cartpole/common.py
stronger(other: Limits) -> bool
Check if this limit is stronger (more restrictive) than the other.
Source code in cartpole/common.py
Parameters
CartPole dynamics parameters. Parameters are defined and matter only for simulation.
For more information see: https://cartpole.robotics-lab.ru/dynamics-and-control
ATTRIBUTE | DESCRIPTION |
---|---|
gravity |
gravity constant (default 9.8 m/s^2)
TYPE:
|
friction_coef |
inner system parameters
TYPE:
|
mass_coef |
inner system parameters
TYPE:
|
Source code in cartpole/common.py
make(mass: float, inertia: float, length: float, friction: float = 0.0, gravity: float = 9.81) -> Parameters
staticmethod
Create parameters from physical properties.
PARAMETER | DESCRIPTION |
---|---|
mass |
pole mass (kg)
TYPE:
|
inertia |
pole moment of inertia (kg*m^2)
TYPE:
|
length |
distance from the pivot to the center of mass (m)
TYPE:
|
friction |
friction coefficient (N*s/m)
TYPE:
|
gravity |
gravity constant (m/s^2)
TYPE:
|
Source code in cartpole/common.py
Config
CartPole configuration.
ATTRIBUTE | DESCRIPTION |
---|---|
hardware_limits |
hardware limits
TYPE:
|
control_limits |
control limits
TYPE:
|
parameters |
dynamics parameters (defined only for simulation)
TYPE:
|
Source code in cartpole/common.py
to_yaml() -> str
to_yaml_file(file_path: str) -> None
from_yaml(yaml_str: str) -> Config
staticmethod
from_yaml_file(file_path: str) -> Config
staticmethod
Error
CartPole system error codes.
ATTRIBUTE | DESCRIPTION |
---|---|
NO_ERROR |
no error
|
NEED_RESET |
reset system before use (make homing)
|
CART_POSITION_OVERFLOW |
cart position is out of control limit
|
CART_VELOCITY_OVERFLOW |
cart velocity is out of control limit
|
CART_ACCELERATION_OVERFLOW |
cart acceleration is out of control limit
|
HARDWARE |
some hardware error (specific for real device)
|
Source code in cartpole/common.py
State
System state.
ATTRIBUTE | DESCRIPTION |
---|---|
cart_position |
cart position (m)
TYPE:
|
cart_velocity |
cart velocity (m/s)
TYPE:
|
cart_acceleration |
cart acceleration (m/s^2)
TYPE:
|
pole_angle |
absolute accumulated pole angle (rad)
TYPE:
|
pole_angular_velocity |
pole angular velocity (rad/s)
TYPE:
|
stamp |
system time stamp (s)
TYPE:
|
error |
system error code
TYPE:
|
Source code in cartpole/common.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
validate(config: Config) -> None
Validates state against limits.
Source code in cartpole/common.py
copy() -> State
as_tuple() -> tuple[float, float, float, float]
Returns tuple (cart_position, pole_angle, cart_velocity, pole_angular_velocity).
Source code in cartpole/common.py
torch4() -> torch.Tensor
Target
Control command, used to set desired cart acceleration.
-
Only acceleration is specified, cart moves with target acceleration.
-
Velocity is specified, but position is not. Cart reaches velocity, with target acceleration (absolute value needed). If acceleration is not specified, used control limit as a default.
-
Position is specified. Cart reaches position with target velocity/accleration, using bang-bang strategy. If velocity/accleration is not specified (absolute value needed), use control limit as a default.
ATTRIBUTE | DESCRIPTION |
---|---|
position |
desired cart position (m)
TYPE:
|
velocity |
desired cart velocity (m/s)
TYPE:
|
acceleration |
desired cart acceleration (m/s^2)
TYPE:
|
Source code in cartpole/common.py
acceleration_or(default: float) -> float
velocity_or(default: float) -> float
validate(config: Config) -> None
Validates target against limits.
Source code in cartpole/common.py
CartPoleBase
The class specifies a interface of the CartPole (device or simulation). A pole is attached by an joint to a cart, which moves along guide axis. The pendulum is initially at rest state. The goal is to maintain it in upright pose by increasing and reducing cart's acceleration.
This environment is some variation of the cart-pole problem described by Barto, Sutton, and Anderson. A pole is at starting position 0 with no velocity and acceleration.
Source code in cartpole/common.py
get_config() -> Config
set_config(config: Config) -> None
Sets new configuration for the device. Real device ignore hardware limits and parameters.
reset(state: State = State()) -> None
Resets the device to the state. It must be called at the beginning of any session. For real device only position may be set.
get_state() -> State
get_info() -> BaseModel
set_target(target: Target) -> State
advance(delta: float) -> None
Advance system by delta seconds (has means only for simulation).
Parameters: delta: float time step in seconds