Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
rigid_body_model.cpp
Go to the documentation of this file.
2
4 const Eigen::VectorXd& dynamic_state) const {
5 if (dynamic_state.size() != 2) {
6 throw std::invalid_argument(
7 "Dynamic state for Rigid Body Load Transfer Model must contain exactly two elements: "
8 "lateral and longitudinal accelerations.");
9 }
10
11 // Accelerations at the CG
12 double longitudinal_acceleration = dynamic_state(0);
13 double lateral_acceleration = dynamic_state(1);
14
15 double mass = this->car_parameters_->mass;
16 double g = 9.8065; // m/s^2 TODO: make this a constant in the car parameters (maybe?)
17 double cog_height = this->car_parameters_->cog_height;
18 double wheelbase = this->car_parameters_->wheelbase;
19 double front_weight_distribution =
20 this->car_parameters_->dist_cg_2_rear_axis / this->car_parameters_->wheelbase;
21 double rear_weight_distribution = 1.0 - front_weight_distribution;
22 double track_width = this->car_parameters_->track_width;
23
24 // Static load per wheel
25 double Fz_total = mass * g;
26 double front_wheel_static_load = front_weight_distribution * Fz_total / 2.0;
27 double rear_wheel_static_load = rear_weight_distribution * Fz_total / 2.0;
28
29 // Weight transfer for each axle
30 double longitudinal_transfer = (mass * longitudinal_acceleration * cog_height) / wheelbase;
31 double lateral_transfer = (mass * lateral_acceleration * cog_height) / track_width;
32
33 Eigen::Vector4d loads;
34
35 loads(0) = front_wheel_static_load - longitudinal_transfer / 2.0 - lateral_transfer / 2.0;
36 loads(1) = front_wheel_static_load - longitudinal_transfer / 2.0 + lateral_transfer / 2.0;
37 loads(2) = rear_wheel_static_load + longitudinal_transfer / 2.0 - lateral_transfer / 2.0;
38 loads(3) = rear_wheel_static_load + longitudinal_transfer / 2.0 + lateral_transfer / 2.0;
39
40 return loads;
41}
std::shared_ptr< common_lib::car_parameters::CarParameters > car_parameters_
Eigen::Vector4d compute_loads(const Eigen::VectorXd &dynamic_state) const override
Computes loads on the tires based on the dynamic state of the vehicle.