Skip to content
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

Simulation and testing problem (inconsistent behavior) #198

Closed
a3g34n opened this issue Apr 22, 2022 · 27 comments
Closed

Simulation and testing problem (inconsistent behavior) #198

a3g34n opened this issue Apr 22, 2022 · 27 comments

Comments

@a3g34n
Copy link

a3g34n commented Apr 22, 2022

Hello,

I am having a problem with simulating the model on Gazebo. When I try to take off the drone take-offs successfully but soon it starts to oscillate then gets out of control and crashes. I tried both my own log files and the example default log file supplied from the data-driven-dynamics repo. I am sending command take-off from qgroundcontrol.
Thank you)))

@a3g34n a3g34n changed the title Simulation and testing problem (inconsistent behavior) and can't test the functionality of the parametric mode Simulation and testing problem (inconsistent behavior) Apr 22, 2022
@manumerous
Copy link
Contributor

Thank you for reporting this issue. :) We are happy to help you and to further improve the pipeline.
For this we might need some more information. Could you share the full results file you obtain when using the default log? it should be located in the model_results folder.

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

quadrotor_model.zip
I build the data-driven-dynamics to PX4-Autopilot/build/px4_sitl_default/data-driven-dynamics

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

Should I open any different log file setting from pixhawk parameters on my quad? Or standart log files are enough?

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Apr 22, 2022

@AEGEAN99 Could you also share the full log displayed on your terminal?

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

of course here my termina when training:
`make estimate-model model=quadrotor_model log=resources/quadrotor_model.ulg
python3 Tools/parametric_model/generate_parametric_model.py
--config /home/a3g34n/PX4-Autopilot/build/px4_sitl_default/data-driven-dynamics-master/Tools/parametric_model/configs/quadrotor_model.yaml
--data_selection False
--plot True
resources/quadrotor_model.ulg
Visual Data selection enabled: False
===============================================================================
Data Processing
===============================================================================
Initializing of configuration successful.
Resample frequency: 250.0 Hz
Loading uLog file: resources/quadrotor_model.ulg
Loading topics:
actuator_outputs
vehicle_local_position
vehicle_attitude
vehicle_angular_velocity
sensor_combined
Starting data resampling of topic types: dict_keys(['actuator_outputs', 'vehicle_local_position', 'vehicle_attitude', 'vehicle_angular_velocity', 'sensor_combined'])
Resampling |################################| 6/5
Resampling |################################| 7/5Initializing of configuration successful.
-------------------------------------------------------------------------------
Initialized dataframe with the following columns:
['timestamp', 'u0', 'u1', 'u2', 'u3', 'vx', 'vy', 'vz', 'q0', 'q1', 'q2', 'q3', 'ang_vel_x', 'ang_vel_y', 'ang_vel_z', 'ang_acc_b_x', 'ang_acc_b_y', 'ang_acc_b_z', 'acc_b_x', 'acc_b_y', 'acc_b_z']
Data contains 14775 timestamps.
Computing force features for rotor: front right rotor
Computing moment features for rotor: front right rotor
Computing force features for rotor: back left rotor
Computing moment features for rotor: back left rotor
Computing force features for rotor: front left rotor
Computing moment features for rotor: front left rotor
Computing force features for rotor: back right rotor
Computing moment features for rotor: back right rotor
Cramer-Rao Bounds for force parameters:
vertical_rot_drag_lin 0.012782946245478023
vertical_rot_thrust_lin 0.02641080802919156
vertical_rot_thrust_quad 0.011493031809214254
c_d_fuselage_x 0.013983358667215987
c_d_fuselage_y 0.01915150130118305
c_d_fuselage_z 0.09617539023560966
Cramer-Rao Bounds for moment parameters:
vertical_c_m_leaver_quad 0.6704594437261402
vertical_c_m_leaver_lin 0.43084225232492834
vertical_c_m_drag_z_quad 0.12862700319155235
vertical_c_m_drag_z_lin 0.911563984500324
vertical_c_m_rolling 1.1950003635205881
===============================================================================
Preparing Model Features
===============================================================================
===============================================================================
Initialize Optimizer
QPOptimizer
===============================================================================
Define and solve problem:
min_c (X * c -y)^T * (X * c -y)
s.t. G * c <= h
Initialized with the following coefficients:
['vertical_rot_drag_lin', 'vertical_rot_thrust_lin', 'vertical_rot_thrust_quad', 'vertical_c_m_leaver_quad', 'vertical_c_m_leaver_lin', 'vertical_c_m_drag_z_quad', 'vertical_c_m_drag_z_lin', 'vertical_c_m_rolling', 'c_d_fuselage_x', 'c_d_fuselage_y', 'c_d_fuselage_z']
Fixed Coefficients: Value
-------------------------------------------------------------------------------
Bounded Coefficients: (Min Value, Max Value)
vertical_rot_drag_lin: (0.0, 2.0)
vertical_rot_thrust_lin: (-5.0, 0.0)
vertical_rot_thrust_quad: (0.0, 50.0)
vertical_c_m_leaver_quad: (0.0, 2.0)
vertical_c_m_leaver_lin: (-1.0, 0.0)
vertical_c_m_drag_z_quad: (0.0, 2.0)
vertical_c_m_drag_z_lin: (-1.0, 0.0)
vertical_c_m_rolling: (0.0, 2.0)
c_d_fuselage_x: (0.0, 2.0)
c_d_fuselage_y: (0.0, 2.0)
c_d_fuselage_z: (0.0, 2.0)
[ 1.59066672e-01 -1.38275472e-01 4.19292061e+00 3.39425013e-01
1.88560297e-20 5.07582893e-01 -3.12479704e-02 7.30058131e-22
2.08259718e-03 1.08326852e-02 -6.22803436e-13]
===============================================================================
Optimization Results
===============================================================================
Optimal Coefficients
-------------------------------------------------------------------------------
c_d_fuselage_x: 0.002082597182204064
c_d_fuselage_y: 0.010832685190091253
c_d_fuselage_z: -6.228034359331524e-13
vertical_c_m_drag_z_lin: -0.03124797041333541
vertical_c_m_drag_z_quad: 0.5075828926443368
vertical_c_m_leaver_lin: 1.885602973253947e-20
vertical_c_m_leaver_quad: 0.33942501322805907
vertical_c_m_rolling: 7.300581311503944e-22
vertical_rot_drag_lin: 0.15906667162903768
vertical_rot_thrust_lin: -0.13827547174291024
vertical_rot_thrust_quad: 4.19292060688978

  -------------------------------------------------------------------------------
                              Optimization Metrics                               
  -------------------------------------------------------------------------------
  R2: 0.9876949185774294
  RMSE: 0.609447037495574
  
  -------------------------------------------------------------------------------
  Complete results saved to: 
  model_results/multirotor_model_2022-04-22-16-07-16.yaml

`

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

and figures
Figure_1
Figure_2
Figure_3
Figure_5
:

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Apr 22, 2022

@AEGEAN99 Could you try with the "LinearRegressor" Instead of the "QPOptimiser"?

also might help if you updte to latest master

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

Actually I dont know how to change optimizer. Should I download the latest master PX4-Autopilot? Or should I install the version in your repo?

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Apr 22, 2022

@AEGEAN99 Sorry I modified my initial response.

No, the latest master of this repo

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

okay I am trying now

@Jaeyoung-Lim
Copy link
Member

@AEGEAN99 The plots remind me of a problem that I fixed a while ago: #193 Probably worth checking if the version you are using has the changes included

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

still not working,
Here is latest one with qpoptimizer
Figure_1
Figure_2
Figure_3
Figure_5
Residual_Visualization

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

And here latest with linearRegressor
Figure_1
Figure_2
Figure_3
Figure_5
Residual_Visualization

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

This happens much more slower

crash.mp4

@Jaeyoung-Lim
Copy link
Member

@AEGEAN99 Ah, now it is working.

Could you try

make estimate-model model=quadrotor_model log=resources/quadrotor_model_trajectory.csv

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

with linearRegressor?

@Jaeyoung-Lim
Copy link
Member

@AEGEAN99 Yes, it is basically just swapping the log

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

It is working but has small oscillations like vibration

good.mp4

n

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

Here is the figures of the model. Are they satisfying?
And have you determined the problem? Thank you:DD
Figure_1
Figure_2
Figure_3
Figure_5
Residual_Visualization

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Apr 22, 2022

@AEGEAN99 Yes, so this means that it has successfully estimated the dynamics.

I am not sure why the vehicle is oscillating, but probably coming from the fact that the moment parameter estimation is not perfect.

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

But when I try the quadrotor_model.csv it agin crashes

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

What should I do for my own log files

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Apr 22, 2022

@AEGEAN99 Yes, because it does not contain enough information - as you can see in the logs there is no angular excitation of the system and the system is unable to successfully estimate the correct parameters

Same for your own logs - You need a log that has enough information to estimate the parameters.

@manumerous Probably we should remove the degenerate logs?

@manumerous
Copy link
Contributor

Thanks for taking over Jay!

Yes I agree with you. I will quickly make a PR and put the trajectory log as our default log. That is indeed confusing.

Furthermore I think this issue points towards the fact that we need to improve the user feedback on the estimated parameters.

@AEGEAN99 as Jay already pointed out estimating the angular dynamics is usually harder than the linear ones. Can you try to fly some maneuvers where you have a lot of angular acceleration and try the pipeline again?

@manumerous
Copy link
Contributor

Adressed in #199

@a3g34n
Copy link
Author

a3g34n commented Apr 22, 2022

Thank you so much!! I will try flying the drone next weeks and update this comment. I hope that works. Thank you for your all effort))))))

@manumerous
Copy link
Contributor

manumerous commented Apr 23, 2022

Thanks for reporting!
Feel free to close the issue if your problem is solved.

@a3g34n a3g34n closed this as completed Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants