@@ -83,29 +83,25 @@ MPCTrajectory KinematicsBicycleModel::calculatePredictedTrajectoryInWorldCoordin
83
83
84
84
// create initial state in the world coordinate
85
85
Eigen::VectorXd state_w = [&]() {
86
- Eigen::VectorXd state = Eigen::VectorXd::Zero (4 );
86
+ Eigen::VectorXd state = Eigen::VectorXd::Zero (3 );
87
87
const auto lateral_error_0 = x0 (0 );
88
88
const auto yaw_error_0 = x0 (1 );
89
89
state (0 , 0 ) = t.x .at (0 ) - std::sin (t.yaw .at (0 )) * lateral_error_0; // world-x
90
90
state (1 , 0 ) = t.y .at (0 ) + std::cos (t.yaw .at (0 )) * lateral_error_0; // world-y
91
91
state (2 , 0 ) = t.yaw .at (0 ) + yaw_error_0; // world-yaw
92
- state (3 , 0 ) = x0 (2 ); // steering
93
92
return state;
94
93
}();
95
94
96
95
// update state in the world coordinate
97
96
const auto updateState = [&](
98
- const Eigen::VectorXd & state_w, const Eigen::MatrixXd & input,
99
- const double dt, const double velocity) {
97
+ const Eigen::VectorXd & state_w, const double & input, const double dt ,
98
+ const double velocity) {
100
99
const auto yaw = state_w (2 );
101
- const auto steer = state_w (3 );
102
- const auto desired_steer = input (0 );
103
100
104
101
Eigen::VectorXd dstate = Eigen::VectorXd::Zero (4 );
105
102
dstate (0 ) = velocity * std::cos (yaw);
106
103
dstate (1 ) = velocity * std::sin (yaw);
107
- dstate (2 ) = velocity * std::tan (steer) / m_wheelbase;
108
- dstate (3 ) = -(steer - desired_steer) / m_steer_tau;
104
+ dstate (2 ) = velocity * std::tan (input) / m_wheelbase;
109
105
110
106
// Note: don't do "return state_w + dstate * dt", which does not work due to the lazy evaluation
111
107
// in Eigen.
@@ -117,7 +113,7 @@ MPCTrajectory KinematicsBicycleModel::calculatePredictedTrajectoryInWorldCoordin
117
113
const auto DIM_U = getDimU ();
118
114
119
115
for (size_t i = 0 ; i < reference_trajectory.size (); ++i) {
120
- state_w = updateState (state_w, Uex. block (i * DIM_U, 0 , DIM_U, 1 ), dt, t.vx .at (i));
116
+ state_w = updateState (state_w, Uex (i * DIM_U, 0 ), dt, t.vx .at (i));
121
117
mpc_predicted_trajectory.push_back (
122
118
state_w (0 ), state_w (1 ), t.z .at (i), state_w (2 ), t.vx .at (i), t.k .at (i), t.smooth_k .at (i),
123
119
t.relative_time .at (i));
0 commit comments