4 const Eigen::VectorXd& cg_velocities)
const {
5 const double vx = cg_velocities(0);
6 const double vy = cg_velocities(1);
7 const double omega = cg_velocities(2);
10 ->dist_cg_2_rear_axis;
14 ->dist_cg_2_rear_axis;
16 double rear_wheel_velocity = sqrt(pow(vx, 2) + pow(vy - omega * lr, 2));
17 double rear_wheels_rpm =
18 60 * rear_wheel_velocity / (M_PI * this->
car_parameters_->wheel_diameter);
20 rear_wheels_rpm = -rear_wheels_rpm;
23 double front_wheel_velocity = sqrt(pow(vx, 2) + pow(vy + omega * lf, 2));
24 double front_wheels_rpm =
25 60 * front_wheel_velocity / (M_PI * this->
car_parameters_->wheel_diameter);
27 front_wheels_rpm = -front_wheels_rpm;
29 double v = sqrt(pow(vx, 2) + pow(vy, 2));
30 double steering_angle =
31 (std::fabs(v) <= 1e-2) ? 0 : atan(omega * (this->
car_parameters_->wheelbase) / v);
32 double motor_rpm = 60 * this->
car_parameters_->gear_ratio * rear_wheel_velocity /
35 motor_rpm = -motor_rpm;
38 Eigen::VectorXd observations = Eigen::VectorXd::Zero(6);
39 observations << front_wheels_rpm, front_wheels_rpm, rear_wheels_rpm, rear_wheels_rpm,
40 steering_angle, motor_rpm;
45 const Eigen::VectorXd& cg_velocities)
const {
46 Eigen::MatrixXd jacobian = Eigen::MatrixXd::Zero(6, 3);
47 double vx = cg_velocities(0);
48 double vy = cg_velocities(1);
49 double omega = cg_velocities(2);
51 ->dist_cg_2_rear_axis;
54 ->dist_cg_2_rear_axis;
55 double rear_wheel_velocity = sqrt(pow(vx, 2) + pow(vy - omega * lr, 2));
56 double front_wheel_velocity = sqrt(pow(vx, 2) + pow(vy + omega * lf, 2));
58 const double epsilon = 1e-2;
59 if (std::fabs(rear_wheel_velocity) < epsilon || std::fabs(front_wheel_velocity) < epsilon) {
60 jacobian(5, 0) = epsilon;
64 double sign = (vx < 0) ? -1.0 : 1.0;
65 jacobian(0, 0) = std::max(
66 0.0, sign * 60 * vx / (M_PI * this->
car_parameters_->wheel_diameter * front_wheel_velocity));
67 jacobian(0, 1) = sign * 60 * (vy + omega * lf) /
69 jacobian(0, 2) = sign * 60 * lf * (vy + omega * lf) /
71 jacobian(1, 0) = jacobian(0, 0);
72 jacobian(1, 1) = jacobian(0, 1);
73 jacobian(1, 2) = jacobian(0, 2);
76 sign * 60 * vx / (M_PI * this->
car_parameters_->wheel_diameter * rear_wheel_velocity);
77 jacobian(2, 1) = sign * 60 * (vy - omega * lr) /
79 jacobian(2, 2) = sign * 60 * (-lr) * (vy - omega * lr) /
81 jacobian(3, 0) = jacobian(2, 0);
82 jacobian(3, 1) = jacobian(2, 1);
83 jacobian(3, 2) = jacobian(2, 2);
87 jacobian(5, 1) = sign * this->
car_parameters_->gear_ratio * 60 * (vy - omega * lr) /
89 jacobian(5, 2) = sign * this->
car_parameters_->gear_ratio * 60 * (-lr) * (vy - omega * lr) /
92 double v = sqrt(pow(vx, 2) + pow(vy, 2));
93 if (std::fabs(v) > epsilon) {
94 jacobian(4, 0) = -((omega * L) / (v * v + (omega * L) * (omega * L))) * (vx / v);
95 jacobian(4, 1) = -((omega * L) / (v * v + (omega * L) * (omega * L))) * (vy / v);
96 jacobian(4, 2) = (L * v) / (v * v + (omega * L) * (omega * L));