Conversation
skrifana
commented
Aug 30, 2025
- Creation of aeroshell class that accounts for drag and down force calculations
- Includes basic regression tests for the motor model and extended aeroshell model
joshuaRiefman
left a comment
There was a problem hiding this comment.
Very good! Just some suggestions
|
|
||
| """ | ||
| # Lookup table mapping wind angle to lift values for a wind speed of 60 km/hr. Comes from CFD simulation in the google drive. Positive sign convention as it is directed towards the ground, and is taken as the negative of lift | ||
| angle_to_lift = { |
There was a problem hiding this comment.
maybe change the name to downforce?
|
|
||
|
|
||
|
|
||
| class AeroshellWithDownForce(Aeroshell): |
There was a problem hiding this comment.
A lot of this code is the exact same as aeroshell.py except swapping the lookup tables. You might be able to generalize the calculate_drag_force and calculate_down_force functions into a calculate_aerodynamic_force and then you just pass in the necessary lookup table.
I haven't looked or thought about this too closely so it may not be possible, but worth a thought.
The reason for doing this is just to have less copying of code which makes maintaining (and testing) code easier.
# Conflicts: # physics/models/motor/basic_motor.py
| The look up table data comes from a CFD carried out by the Aeroshell team - https://docs.google.com/spreadsheets/d/1D1ydUj-6aG-gBzlq2zTr8WgdxVIGQ9PqUZPuLfDphcg/edit?usp=sharing | ||
|
|
||
| """ | ||
| angle_to_unscaled_drag = { |
There was a problem hiding this comment.
Make these be inputs to the constructor
| """ | ||
| # Lookup table mapping wind angle to drag values for a wind speed of 60 km/hr. Comes from CFD simulation in the google drive. | ||
|
|
||
| if force_type == "drag": |
There was a problem hiding this comment.
Make the table be the input, not force_type
| } | ||
|
|
||
| @staticmethod | ||
| def calculate_aero_force(wind_speeds, wind_attack_angles, required_speed_ms, force_type): |
There was a problem hiding this comment.
Add helpers like calculate_downforce and calculate_drag_force which call this
| Drag force refers to the resistive force that affects the vehicles. This is considered by both the wind and motion of the car | ||
| Down force refers to negative lift force i.e. acting against the normal force at every tick | ||
|
|
||
| :param np.ndarray wind_speeds: (float[N]) speeds of wind in m/s, where > 0 means against the direction of the vehicle |
There was a problem hiding this comment.
Redo documentation to reflect updated class structure
|
|
||
| """ | ||
|
|
||
| def __init__(self, drag_lookup, down_lookup): |
There was a problem hiding this comment.
Type hint these variables
|
|
||
| return drag_forces | ||
|
|
||
| def calculate_drag(self, wind_speeds, wind_attack_angles, required_speed_ms): |
There was a problem hiding this comment.
Add docstrings and type hints
| values = np.array(list(lookup_table.values())) | ||
| func = make_interp_spline(angles, values, k=3) | ||
| force_ref = func(wind_attack_angles) | ||
| wind_drag = direction * force_ref * (wind_speeds ** 2) / (16.667 ** 2) |
There was a problem hiding this comment.
Make magic numbers into constants
| values = np.array(list(lookup_table.values())) | ||
| func = make_interp_spline(angles, values, k=3) | ||
| force_ref = func(wind_attack_angles) | ||
| wind_drag = direction * force_ref * (wind_speeds ** 2) / (16.667 ** 2) |
There was a problem hiding this comment.
Generalize name of variable (since its not necessarily drag)