@@ -82,30 +82,30 @@ MPCTrajectory KinematicsBicycleModel::calculatePredictedTrajectoryInWorldCoordin
82
82
const auto & t = reference_trajectory;
83
83
84
84
// create initial state in the world coordinate
85
- Eigen::VectorXd state_w = [&]() {
86
- Eigen::VectorXd state = Eigen::VectorXd ::Zero (3 );
85
+ Eigen::Vector3d state_w = [&]() {
86
+ Eigen::Vector3d state = Eigen::Vector3d ::Zero ();
87
87
const auto lateral_error_0 = x0 (0 );
88
88
const auto yaw_error_0 = x0 (1 );
89
- state (0 , 0 ) = t.x .at (0 ) - std::sin (t.yaw .at (0 )) * lateral_error_0; // world-x
90
- state (1 , 0 ) = t.y .at (0 ) + std::cos (t.yaw .at (0 )) * lateral_error_0; // world-y
91
- state (2 , 0 ) = t.yaw .at (0 ) + yaw_error_0; // world-yaw
89
+ state (0 ) = t.x .at (0 ) - std::sin (t.yaw .at (0 )) * lateral_error_0; // world-x
90
+ state (1 ) = t.y .at (0 ) + std::cos (t.yaw .at (0 )) * lateral_error_0; // world-y
91
+ state (2 ) = t.yaw .at (0 ) + yaw_error_0; // world-yaw
92
92
return state;
93
93
}();
94
94
95
95
// update state in the world coordinate
96
96
const auto updateState = [&](
97
- const Eigen::VectorXd & state_w, const double & input, const double dt,
97
+ const Eigen::Vector3d & state_w, const double & input, const double dt,
98
98
const double velocity) {
99
99
const auto yaw = state_w (2 );
100
100
101
- Eigen::VectorXd dstate = Eigen::VectorXd ::Zero (4 );
101
+ Eigen::Vector3d dstate = Eigen::Vector3d ::Zero ();
102
102
dstate (0 ) = velocity * std::cos (yaw);
103
103
dstate (1 ) = velocity * std::sin (yaw);
104
104
dstate (2 ) = velocity * std::tan (input) / m_wheelbase;
105
105
106
106
// Note: don't do "return state_w + dstate * dt", which does not work due to the lazy evaluation
107
107
// in Eigen.
108
- const Eigen::VectorXd next_state = state_w + dstate * dt;
108
+ const Eigen::Vector3d next_state = state_w + dstate * dt;
109
109
return next_state;
110
110
};
111
111
0 commit comments