-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmy_pendulum.h
More file actions
47 lines (43 loc) · 1.54 KB
/
my_pendulum.h
File metadata and controls
47 lines (43 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <rl_tools/rl/environments/environments.h>
template <typename T>
struct MyPendulumParameters {
constexpr static T G = 10;
constexpr static T MAX_SPEED = 8;
constexpr static T MAX_TORQUE = 2;
constexpr static T DT = 0.05;
constexpr static T M = 1;
constexpr static T L = 1;
constexpr static T INITIAL_STATE_MIN_ANGLE = -rl_tools::math::PI<T>;
constexpr static T INITIAL_STATE_MAX_ANGLE = rl_tools::math::PI<T>;
constexpr static T INITIAL_STATE_MIN_SPEED = -1;
constexpr static T INITIAL_STATE_MAX_SPEED = 1;
};
template <typename T_T, typename T_TI, typename T_PARAMETERS = MyPendulumParameters<T_T>>
struct MyPendulumSpecification{
using T = T_T;
using TI = T_TI;
using PARAMETERS = T_PARAMETERS;
};
template <typename T, typename TI>
struct MyPendulumState{
static constexpr TI DIM = 2;
T theta;
T theta_dot;
};
template <typename TI>
struct MyPendulumFourierObservation{
static constexpr TI DIM = 3; // cos(theta), sin(theta), theta_dot
};
template <typename T_SPEC>
struct MyPendulum: rl_tools::rl::environments::Environment<typename T_SPEC::T, typename T_SPEC::TI>{
using SPEC = T_SPEC;
using T = typename SPEC::T;
using TI = typename SPEC::TI;
using Parameters = typename SPEC::PARAMETERS;
using State = MyPendulumState<T, TI>;
using Observation = MyPendulumFourierObservation<TI>;
using ObservationPrivileged = Observation;
static constexpr TI OBSERVATION_DIM = 3;
static constexpr TI ACTION_DIM = 1;
static constexpr TI EPISODE_STEP_LIMIT = 200;
};