49 #ifndef ILQGAMES_DYNAMICS_SINGLE_PLAYER_UNICYCLE_5D_H 50 #define ILQGAMES_DYNAMICS_SINGLE_PLAYER_UNICYCLE_5D_H 52 #include <ilqgames/dynamics/single_player_dynamical_system.h> 53 #include <ilqgames/utils/types.h> 64 VectorXf Evaluate(Time t,
const VectorXf& x,
const VectorXf& u)
const;
67 void Linearize(Time t,
const VectorXf& x,
const VectorXf& u,
68 Eigen::Ref<MatrixXf> A, Eigen::Ref<MatrixXf> B)
const;
71 float DistanceBetween(
const VectorXf& x0,
const VectorXf& x1)
const;
74 std::vector<Dimension> PositionDimensions()
const {
return {kPxIdx, kPyIdx}; }
77 static const Dimension kNumXDims;
78 static const Dimension kPxIdx;
79 static const Dimension kPyIdx;
80 static const Dimension kThetaIdx;
81 static const Dimension kVIdx;
82 static const Dimension kSIdx;
85 static const Dimension kNumUDims;
86 static const Dimension kOmegaIdx;
87 static const Dimension kAIdx;
92 inline VectorXf SinglePlayerUnicycle5D::Evaluate(Time t,
const VectorXf& x,
93 const VectorXf& u)
const {
95 xdot(kPxIdx) = x(kVIdx) * std::cos(x(kThetaIdx));
96 xdot(kPyIdx) = x(kVIdx) * std::sin(x(kThetaIdx));
97 xdot(kThetaIdx) = u(kOmegaIdx);
98 xdot(kVIdx) = u(kAIdx);
99 xdot(kSIdx) = x(kVIdx);
104 inline void SinglePlayerUnicycle5D::Linearize(Time t,
const VectorXf& x,
106 Eigen::Ref<MatrixXf> A,
107 Eigen::Ref<MatrixXf> B)
const {
108 const float ctheta = std::cos(x(kThetaIdx)) * time::kTimeStep;
109 const float stheta = std::sin(x(kThetaIdx)) * time::kTimeStep;
111 A(kPxIdx, kThetaIdx) += -x(kVIdx) * stheta;
112 A(kPxIdx, kVIdx) += ctheta;
114 A(kPyIdx, kThetaIdx) += x(kVIdx) * ctheta;
115 A(kPyIdx, kVIdx) += stheta;
117 A(kSIdx, kVIdx) += time::kTimeStep;
119 B(kThetaIdx, kOmegaIdx) = time::kTimeStep;
120 B(kVIdx, kAIdx) = time::kTimeStep;
123 inline float SinglePlayerUnicycle5D::DistanceBetween(
const VectorXf& x0,
124 const VectorXf& x1)
const {
126 const float dx = x0(kPxIdx) - x1(kPxIdx);
127 const float dy = x0(kPyIdx) - x1(kPyIdx);
128 return dx * dx + dy * dy;