48 #ifndef ILQGAMES_DYNAMICS_SINGLE_PLAYER_UNICYCLE_4D_H 49 #define ILQGAMES_DYNAMICS_SINGLE_PLAYER_UNICYCLE_4D_H 51 #include <ilqgames/dynamics/single_player_dynamical_system.h> 52 #include <ilqgames/utils/types.h> 63 VectorXf Evaluate(Time t,
const VectorXf& x,
const VectorXf& u)
const;
66 void Linearize(Time t,
const VectorXf& x,
const VectorXf& u,
67 Eigen::Ref<MatrixXf> A, Eigen::Ref<MatrixXf> B)
const;
70 float DistanceBetween(
const VectorXf& x0,
const VectorXf& x1)
const;
73 std::vector<Dimension> PositionDimensions()
const {
return {kPxIdx, kPyIdx}; }
76 static const Dimension kNumXDims;
77 static const Dimension kPxIdx;
78 static const Dimension kPyIdx;
79 static const Dimension kThetaIdx;
80 static const Dimension kVIdx;
83 static const Dimension kNumUDims;
84 static const Dimension kOmegaIdx;
85 static const Dimension kAIdx;
90 inline VectorXf SinglePlayerUnicycle4D::Evaluate(Time t,
const VectorXf& x,
91 const VectorXf& u)
const {
93 xdot(kPxIdx) = x(kVIdx) * std::cos(x(kThetaIdx));
94 xdot(kPyIdx) = x(kVIdx) * std::sin(x(kThetaIdx));
95 xdot(kThetaIdx) = u(kOmegaIdx);
96 xdot(kVIdx) = u(kAIdx);
101 inline void SinglePlayerUnicycle4D::Linearize(Time t,
const VectorXf& x,
103 Eigen::Ref<MatrixXf> A,
104 Eigen::Ref<MatrixXf> B)
const {
105 const float ctheta = std::cos(x(kThetaIdx)) * time::kTimeStep;
106 const float stheta = std::sin(x(kThetaIdx)) * time::kTimeStep;
108 A(kPxIdx, kThetaIdx) += -x(kVIdx) * stheta;
109 A(kPxIdx, kVIdx) += ctheta;
111 A(kPyIdx, kThetaIdx) += x(kVIdx) * ctheta;
112 A(kPyIdx, kVIdx) += stheta;
114 B(kThetaIdx, kOmegaIdx) = time::kTimeStep;
115 B(kVIdx, kAIdx) = time::kTimeStep;
118 inline float SinglePlayerUnicycle4D::DistanceBetween(
const VectorXf& x0,
119 const VectorXf& x1)
const {
121 const float dx = x0(kPxIdx) - x1(kPxIdx);
122 const float dy = x0(kPyIdx) - x1(kPyIdx);
123 return dx * dx + dy * dy;