-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/sim tire #531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat/sim tire #531
Conversation
HugoNogueira05
commented
Jan 18, 2026
- Added TireModel class
- Created FSFEUP02Model class
- Tested initialization of both classes
- Created config file for both classes
- Implemented lateral and longitudinal pacejka with zero speed normalization
|
@HugoNogueira05 Fix conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acho que não há necessidade de criar tantas structs, princialemnte a de parameter, uma struct com os parametros tds do vehicle model é suficiente acho eu, depois essa struct é passada à classe do vehicle model que cria tds estas sub-classes. Ter demasiadas structs pode tornar ainda mais confuso, principalmente, se as tivermos espalhadas pelas classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Não metas os tests com full path, home/ws/... isso funciona agora que estamos no workspace, mas por exemplo no carro não passa. E acho que é desnecessário esse tipo de testes
|
DiogoProPrayer
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
O código está bastante pouco legível. Não existe outro nome para as variáveis para além destas siglas com 3 letras? Algumas soluções que sugiro é eliminar estas nomenclaturas com abreviaturas tão curtas, comentar mais o código para se compreender o que está a ser calculado em cada passo ou separar em funções que digam no seu nome o que está a ser calculado. É preferível o código se mais extenso do que depois alguém no futuro querer ler e não perceber nada do que está a acontecer. Se não for assim vai ser impossível dar debug a isto no futuro.
Para além disso temos imensos parâmetros a 0 ou 1, não pode ser o caso de termos aqui imensos parâmetros inúteis? Tudo o que for inutil acho que se pode, e deveria, remover, a não ser que seja algo que possamos ter interesse em utilizar no futuro.
|
|
||
| struct TireParameters { | ||
| // ---------------- configuration values | ||
| double Amu = 1.0; // VD uses 1 but the pacejka book suggests 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qual é o efeito deste parâmetro?
| double RIM_WIDTH = 0.152; // Rim width | ||
|
|
||
| // ---------------- operating conditions | ||
| double INFLPRES = 220000; // Actual inflation pressure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Qual é a unidade disto? Sei que a pressão que usamos no 02 é 10PSI
| float d_bleft = model_config["tire"]["d_bleft"].as<float>(); | ||
| float d_bright = model_config["tire"]["d_bright"].as<float>(); | ||
| float d_fleft = model_config["tire"]["d_fleft"].as<float>(); | ||
| float d_fright = model_config["tire"]["d_fright"].as<float>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isto está nos parâmetros? aparece que foi apagado
| bool TireModel::calculateTireState(float slip_angle, float slip_ratio) { | ||
| internal_vals.Fz0_prime = | ||
| vehicle_model_params.tire_parameters.LFZO * vehicle_model_state.force.fz; | ||
| internal_vals.dfz = | ||
| (vehicle_model_state.force.fz - internal_vals.Fz0_prime) / internal_vals.Fz0_prime; | ||
| internal_vals.epsilong = vehicle_model_params.tire_parameters.PECP1 * | ||
| (1 + vehicle_model_params.tire_parameters.PECP2 * internal_vals.dfz); | ||
| internal_vals.Vc_prime = sqrt(vehicle_model_state.velocity.vx * vehicle_model_state.velocity.vx + | ||
| vehicle_model_state.velocity.vy * vehicle_model_state.velocity.vy); | ||
| internal_vals.phi = (1 / internal_vals.Vc_prime) * | ||
| (vehicle_model_state.yaw_rate - (1 - internal_vals.epsilong) * | ||
| vehicle_model_state.angular_speed * | ||
| sin(internal_vals.camber_angle)); | ||
| internal_vals.gamma_star = | ||
| internal_vals.camber_angle * vehicle_model_params.camber_scaling_factor; | ||
| double Byp = vehicle_model_params.tire_parameters.PDYP1 * | ||
| (1 + vehicle_model_params.tire_parameters.PDYP2 * internal_vals.dfz) * | ||
| cos(atan(vehicle_model_params.tire_parameters.PDYP3 * tan(slip_angle))); | ||
| internal_vals.zeta2 = cos(atan( | ||
| Byp * | ||
| (vehicle_model_params.tire_parameters.UNLOADED_RADIUS * abs(internal_vals.phi) + | ||
| vehicle_model_params.tire_parameters.PDYP4 * | ||
| sqrt(vehicle_model_params.tire_parameters.UNLOADED_RADIUS * abs(internal_vals.phi))))); | ||
| internal_vals.zeta3 = | ||
| cos(atan(vehicle_model_params.tire_parameters.PKYP1 * | ||
| (vehicle_model_params.effective_tire_r * vehicle_model_params.effective_tire_r) * | ||
| (internal_vals.phi * internal_vals.phi))); | ||
| internal_vals.Kya = | ||
| vehicle_model_params.tire_parameters.PKY1 * internal_vals.Fz0_prime * | ||
| (1 + vehicle_model_params.tire_parameters.PPY1 * internal_vals.dpi) * | ||
| (1 - vehicle_model_params.tire_parameters.PKY3 * abs(internal_vals.gamma_star)) * | ||
| sin(vehicle_model_params.tire_parameters.PKY4 * | ||
| atan((vehicle_model_state.force.fz / internal_vals.Fz0_prime) / | ||
| ((vehicle_model_params.tire_parameters.PKY2 + | ||
| vehicle_model_params.tire_parameters.PKY5 * internal_vals.gamma_star * | ||
| internal_vals.gamma_star) * | ||
| (1 + vehicle_model_params.tire_parameters.PPY2 * internal_vals.dpi)))) * | ||
| internal_vals.zeta3 * vehicle_model_params.tire_parameters.LKY; | ||
| internal_vals.Vcx = (vehicle_model_state.velocity.vx * cos(vehicle_model_state.steering_angle)) + | ||
| (vehicle_model_state.velocity.vy + | ||
| vehicle_model_state.yaw_rate * internal_vals.distance_to_CG) * | ||
| sin(vehicle_model_state.steering_angle); | ||
| double Bxp = vehicle_model_params.tire_parameters.PDXP1 * | ||
| (1 + vehicle_model_params.tire_parameters.PDXP2 * internal_vals.dfz) * | ||
| cos(atan(vehicle_model_params.tire_parameters.PDXP3 * slip_ratio)); | ||
| internal_vals.zeta1 = cos(atan(Bxp * vehicle_model_params.effective_tire_r * internal_vals.phi)); | ||
| internal_vals.LMUY_prime = vehicle_model_params.tire_parameters.Amu * | ||
| vehicle_model_params.tire_parameters.LMUY / | ||
| (1 + (vehicle_model_params.tire_parameters.Amu - 1) * | ||
| vehicle_model_params.tire_parameters.LMUY); | ||
| internal_vals.SVyg = vehicle_model_state.force.fz * | ||
| (vehicle_model_params.tire_parameters.PVY3 + | ||
| vehicle_model_params.tire_parameters.PVY4 * internal_vals.dfz) * | ||
| internal_vals.gamma_star * vehicle_model_params.tire_parameters.LKYC * | ||
| internal_vals.LMUY_prime * internal_vals.zeta2; | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Este código aqui não é legível de todo haha. Deves separar em funções mais simples ou comentar de forma a ser compreensível o que está a acontecer. Como os nomes dos parâmetros estão todos abreviados é impossível compreender.


