ethz-asl / data-driven-dynamics

Data Driven Dynamics Modeling for Aerial Vehicles
Other
91 stars 13 forks source link

models: implement simple fixedwing model #209

Closed sjschlapbach closed 1 year ago

sjschlapbach commented 1 year ago

This pull request introduces a modified model for a fixedwing standard plane with linear lift model (function of angle of attack and elevator input) and quadratic drag model.

An additional "--normalization" flag was introduced to have the ability to disable normalization when using simulation data or the new flight log standards with setpoints. The model can be run with the same makefile command as mentioned in the README:

make estimate-model model=fixedwing_longitudinal_model log=resources/elevator_ramp_zero_thrust.csv

For VTOL configurations (with different PX4 setpoint topics for the correct control surfaces and thrust quantities), use the following configuration:

make estimate-model model=vtol_longitudinal_model log=LOG_PATH
Jaeyoung-Lim commented 1 year ago

@sjschlapbach I think I am getting a different issue as you have showed in the meeting.

Is this consistent of what you are expecting in this branch?

-------------------------------------------------------------------------------
Complete results saved to: 
model_results/simple_fixedwing_model_2022-12-01-15-48-51.yaml
-------------------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jaeyoung/.local/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2898, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 70, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 101, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1675, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1683, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'measured_force_x'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "Tools/parametric_model/generate_parametric_model.py", line 131, in <module>
    start_model_estimation(**vars(arg_list))
  File "Tools/parametric_model/generate_parametric_model.py", line 114, in start_model_estimation
    model.plot_model_predicitons()
  File "/home/jaeyoung/dev/data-driven-dynamics/Tools/parametric_model/src/models/dynamics_model.py", line 572, in plot_model_predicitons
    "measured_force_x", "measured_force_y", "measured_force_z", 'blue')
  File "/home/jaeyoung/dev/data-driven-dynamics/Tools/parametric_model/src/models/dynamics_model.py", line 537, in plot_scatter
    ax.scatter(self.data_df[dataframe_x], self.data_df[dataframe_y],
  File "/home/jaeyoung/.local/lib/python3.6/site-packages/pandas/core/frame.py", line 2906, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/home/jaeyoung/.local/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2900, in get_loc
    raise KeyError(key) from err
KeyError: 'measured_force_x'
Makefile:34: recipe for target 'estimate-model' failed
make: *** [estimate-model] Error 1

To reproduce:

make estimate-model model=fixedwing_longitudinal_model log=resources/elevator_ramp_zero_thrust.csv 
sjschlapbach commented 1 year ago

@sjschlapbach I think I am getting a different issue as you have showed in the meeting.

Is this consistent of what you are expecting in this branch?

-------------------------------------------------------------------------------
Complete results saved to: 
model_results/simple_fixedwing_model_2022-12-01-15-48-51.yaml
-------------------------------------------------------------------------------
...

To reproduce:

make estimate-model model=fixedwing_longitudinal_model log=resources/elevator_ramp_zero_thrust.csv 

Plotting currently doesn't work for this model, but the estimation can still be run with the following command:

python3 Tools/parametric_model/generate_parametric_model.py --plot False --config Tools/parametric_model/configs/fixedwing_longitudinal_model.yaml resources/elevator_ramp_zero_thrust.csv
Jaeyoung-Lim commented 1 year ago

Before I review the PR, would it be possible to address the CI failures? e.g.

Starting data resampling of topic types:  dict_keys(['actuator_outputs', 'vehicle_local_position', 'vehicle_attitude', 'vehicle_angular_velocity', 'sensor_combined'])
Traceback (most recent call last):
  File "Tools/parametric_model/generate_parametric_model.py", line 133, in <module>
    start_model_estimation(**vars(arg_list))
  File "Tools/parametric_model/generate_parametric_model.py", line 74, in start_model_estimation
    model = getattr(models, model_class)(config, normalization=normalization)
TypeError: __init__() got an unexpected keyword argument 'normalization'
make: *** [Makefile:34: estimate-model] Error 1
Jaeyoung-Lim commented 1 year ago

@sjschlapbach Could we try to separate the changes we want to merge?

Some things need to happen for this to get merged

sjschlapbach commented 1 year ago

@sjschlapbach How was the quadrotor_model data generated? They seem to have been modifield

@Jaeyoung-Lim The new flight time computation (in dataframe_tools) is based on the vehicle_status/landed topic, which was missing from the csv files (as it was not used before). To ensure that the estimation still works with these logs, I added the landed column and filled it with zeros.

Jaeyoung-Lim commented 1 year ago

@sjschlapbach Thanks!

Bombs away!