53 #ifndef ILQGAMES_DYNAMICS_SINGLE_PLAYER_CAR_6D_H 54 #define ILQGAMES_DYNAMICS_SINGLE_PLAYER_CAR_6D_H 56 #include <ilqgames/dynamics/single_player_dynamical_system.h> 57 #include <ilqgames/utils/types.h> 66 inter_axle_distance_(inter_axle_distance) {}
69 VectorXf Evaluate(Time t,
const VectorXf& x,
const VectorXf& u)
const;
72 void Linearize(Time t,
const VectorXf& x,
const VectorXf& u,
73 Eigen::Ref<MatrixXf> A, Eigen::Ref<MatrixXf> B)
const;
76 float DistanceBetween(
const VectorXf& x0,
const VectorXf& x1)
const;
79 std::vector<Dimension> PositionDimensions()
const {
return {kPxIdx, kPyIdx}; }
82 static const Dimension kNumXDims;
83 static const Dimension kPxIdx;
84 static const Dimension kPyIdx;
85 static const Dimension kThetaIdx;
86 static const Dimension kPhiIdx;
87 static const Dimension kVIdx;
88 static const Dimension kAIdx;
91 static const Dimension kNumUDims;
92 static const Dimension kOmegaIdx;
93 static const Dimension kJerkIdx;
97 const float inter_axle_distance_;
102 inline VectorXf SinglePlayerCar6D::Evaluate(Time t,
const VectorXf& x,
103 const VectorXf& u)
const {
104 VectorXf xdot(xdim_);
105 xdot(kPxIdx) = x(kVIdx) * std::cos(x(kThetaIdx));
106 xdot(kPyIdx) = x(kVIdx) * std::sin(x(kThetaIdx));
107 xdot(kThetaIdx) = (x(kVIdx) / inter_axle_distance_) * std::tan(x(kPhiIdx));
108 xdot(kPhiIdx) = u(kOmegaIdx);
109 xdot(kVIdx) = x(kAIdx);
110 xdot(kAIdx) = u(kJerkIdx);
115 inline void SinglePlayerCar6D::Linearize(Time t,
const VectorXf& x,
117 Eigen::Ref<MatrixXf> A,
118 Eigen::Ref<MatrixXf> B)
const {
119 const float ctheta = std::cos(x(kThetaIdx)) * time::kTimeStep;
120 const float stheta = std::sin(x(kThetaIdx)) * time::kTimeStep;
121 const float cphi = std::cos(x(kPhiIdx));
122 const float tphi = std::tan(x(kPhiIdx));
124 A(kPxIdx, kThetaIdx) += -x(kVIdx) * stheta;
125 A(kPxIdx, kVIdx) += ctheta;
127 A(kPyIdx, kThetaIdx) += x(kVIdx) * ctheta;
128 A(kPyIdx, kVIdx) += stheta;
130 A(kThetaIdx, kPhiIdx) +=
131 x(kVIdx) * time::kTimeStep / (inter_axle_distance_ * cphi * cphi);
132 A(kThetaIdx, kVIdx) += tphi * time::kTimeStep / inter_axle_distance_;
134 A(kVIdx, kAIdx) += time::kTimeStep;
136 B(kPhiIdx, kOmegaIdx) = time::kTimeStep;
137 B(kAIdx, kJerkIdx) = time::kTimeStep;
140 inline float SinglePlayerCar6D::DistanceBetween(
const VectorXf& x0,
141 const VectorXf& x1)
const {
143 const float dx = x0(kPxIdx) - x1(kPxIdx);
144 const float dy = x0(kPyIdx) - x1(kPyIdx);
145 return dx * dx + dy * dy;