17 #include "double_cart_pole.h" 19 #include <third_party/box2d/box2d.h> 24 static constexpr
float kCartHalfWidth = 0.2f;
25 static constexpr
float kCartHalfHeight = 0.05f;
26 static constexpr
float kPoleHalfWidth = 0.02f;
27 static constexpr
float kGroundY = 0.1f;
30 World(
float initial_angle_1,
float initial_angle_2,
const DoubleCartPole* domain);
37 float cartDistance()
const {
return cart_->GetPosition().x; }
38 float cartVelocity()
const {
return cart_->GetLinearVelocity().x; }
39 float pole1Angle()
const {
return pole_1_->GetAngle(); }
40 float pole1AngularVelocity()
const {
return pole_1_->GetAngularVelocity(); }
41 float pole2Angle()
const {
return pole_2_->GetAngle(); }
42 float pole2AngularVelocity()
const {
return pole_2_->GetAngularVelocity(); }
45 void moveCart(
float force);
47 const DoubleCartPole* domain()
const {
return domain_; }
49 b2World* box2dWorld() {
return &b2_world_; }
52 b2Body* createPole(
float length,
float density,
float initial_angle);
53 b2Body* createCart(
float density,
float friction);
54 void createHinge(b2Body* cart, b2Body* pole);
59 b2Body* cart_ =
nullptr;
60 b2Body* pole_1_ =
nullptr;
61 b2Body* pole_2_ =
nullptr;
63 const DoubleCartPole* domain_ =
nullptr;