Implementation of Cart Pole task. More...
Classes | |
| class | State |
| Implementation of the state of Cart Pole. More... | |
Public Types | |
| enum | Action { backward , forward , size } |
| Implementation of action of Cart Pole. More... | |
Public Member Functions | |
| CartPole (const double gravity=9.8, const double massCart=1.0, const double massPole=0.1, const double length=0.5, const double forceMag=10.0, const double tau=0.02, const double thetaThresholdRadians=12 *2 *3.1416/360, const double xThreshold=2.4, const double doneReward=0.0) | |
| Construct a Cart Pole instance using the given constants. More... | |
| State | InitialSample () const |
| Initial state representation is randomly generated within [-0.05, 0.05]. More... | |
| bool | IsTerminal (const State &state) const |
| Whether given state is a terminal state. More... | |
| double | Sample (const State &state, const Action &action, State &nextState) const |
| Dynamics of Cart Pole instance. More... | |
| double | Sample (const State &state, const Action &action) const |
| Dynamics of Cart Pole. More... | |
Implementation of Cart Pole task.
Definition at line 26 of file cart_pole.hpp.
| enum Action |
Implementation of action of Cart Pole.
| Enumerator | |
|---|---|
| backward | |
| forward | |
| size | |
Definition at line 87 of file cart_pole.hpp.
|
inline |
Construct a Cart Pole instance using the given constants.
| gravity | The gravity constant. |
| massCart | The mass of the cart. |
| massPole | The mass of the pole. |
| length | The length of the pole. |
| forceMag | The magnitude of the applied force. |
| tau | The time interval. |
| thetaThresholdRadians | The maximum angle. |
| xThreshold | The maximum position. |
Definition at line 108 of file cart_pole.hpp.
|
inline |
Initial state representation is randomly generated within [-0.05, 0.05].
Definition at line 192 of file cart_pole.hpp.
References CartPole::State::State().
|
inline |
Whether given state is a terminal state.
| state | The desired state. |
Definition at line 203 of file cart_pole.hpp.
References CartPole::State::Angle(), and CartPole::State::Position().
Referenced by CartPole::Sample().
Dynamics of Cart Pole instance.
Get reward and next state based on current state and current action.
| state | The current state. |
| action | The current action. |
| nextState | The next state. |
It is important to note that if the cartpole is falling down, it should be penalized.
When done is false, it means that the cartpole has fallen down. For this case the reward is 1.0.
Definition at line 139 of file cart_pole.hpp.
References CartPole::State::Angle(), CartPole::State::AngularVelocity(), CartPole::IsTerminal(), CartPole::State::Position(), and CartPole::State::Velocity().
Referenced by CartPole::Sample().
Dynamics of Cart Pole.
Get reward based on current state and current action.
| state | The current state. |
| action | The current action. |
Definition at line 181 of file cart_pole.hpp.
References CartPole::Sample().