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

Evaluation with identified model #172

Closed
Jaeyoung-Lim opened this issue Oct 30, 2021 · 10 comments
Closed

Evaluation with identified model #172

Jaeyoung-Lim opened this issue Oct 30, 2021 · 10 comments
Labels
bug Something isn't working

Comments

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Oct 30, 2021

Description
Previously discussed with @manumerous, we wanted to try and see if identifying a model through a flight log that was already using estimated parameters (so that we know the groundtruth dynamics) to evaluate this pipeline

Experiment Setup

make estimate-model
Tools/sitl_run.sh -m iris -s iris_aerodynamics

Start the lissajous trajectory excitation with Jaeyoung-Lim/mavros_controllers#193

Results
The estimated parameters does not seem to be consistent with the previous model that the trajectory was generated from. The vehicle is not able to fly with Jaeyoung-Lim/mavros_controllers#193, which the model was originally trained on.

This can be interpreted in different ways, but I think this means that while the model estimated is good enough to "fly" the vehicle in auto modes, but the estimated dynamics seem to be inconsistent with the ground truth model that the stability of the nonlinear geometric controller has become unstable

Other comments
I had to jump through a lot of hoops to get this setup working.

The following is general notes what I needed to do to get this working

  • When starting this repository from a roslaunch file, the data driven dynamics plugin does not start properly. Therefore I had to run the simulation from this repo and run the ros package separately. Might be related to one of the GAZEBO_PATH_* environment variables used through a different route in ROS
  • The gazebo plugin assumes that the estimated parameter file is called model_results/quadrotor_model.yml. The process that needs to happen is that you first estimate the model, rename the file to model_results/quadrotor_model.yml since the dates are included in the filename.
  • When the above happens it is very unclear whether the gazebo plugin is not loaded because of a general installation problem or because it can't find the yaml file. This can be fixed by throwing with the appropriate messages
@Jaeyoung-Lim Jaeyoung-Lim added the bug Something isn't working label Nov 9, 2021
@pascalau
Copy link
Collaborator

I identified the issue for the incorrect parameter estimation. The actuator input for feature calculation is given in rpm and normalized using the function normalize_actuators() which assumes that the rpm is bounded between 1000 and 2000 rpm. And normalizes this range between [0,1]. The resulting actuator input has a mean of around 0.5. During simulation I observed that the actuator input also has a range between [0,1] but a mean of 0.7 which means that the a actuator input value of 0 corresponds to 0 rpm and 1 to 2000 rpm. I don't now what program/node publishes the actuator input, but setting the lower bound of normalize_actuators() to 0 instead of 1000 allows the regression to estimate more or less the original values.

@pascalau
Copy link
Collaborator

parameters.zip
Here are the parameters for the simulation and the estimated parameters from the log.

@Jaeyoung-Lim
Copy link
Member Author

Jaeyoung-Lim commented Dec 15, 2021

@pascalau Awesome work!

normalize_actuators() to 0 instead of 1000 allows the regression to estimate more or less the original values.

Is this regarding

?

@manumerous It seems like @pascalau solved the problem!

@pascalau
Copy link
Collaborator

Does anyone now what provides actuator_input to the plugin and how these values are mapped to rotor rpm?

@pascalau
Copy link
Collaborator

Is this regarding

Yes

@Jaeyoung-Lim
Copy link
Member Author

Jaeyoung-Lim commented Dec 15, 2021

@pascalau So on the simulation side, the thrust is being calculated by the rotor velocity (RPM) in the gazebo_motor_model plugin in

https://github.com/PX4/PX4-SITL_gazebo/blob/27298574ce33a79ba6cfc31ed4604974605e7257/src/gazebo_motor_model.cpp#L201

This message comes from the gazebo_mavlink_interface, which receives the normalized actuator commands from PX4 and scales them to rpm commands

https://github.com/PX4/PX4-SITL_gazebo/blob/27298574ce33a79ba6cfc31ed4604974605e7257/src/gazebo_mavlink_interface.cpp#L1115-L1124

The relevant parameters such as input offset and input scaling are defined in the sdf file as is

<channel name='rotor1'>
<input_index>0</input_index>
<input_offset>0</input_offset>
<input_scaling>2</input_scaling>
<zero_position_disarmed>0</zero_position_disarmed>
<zero_position_armed>0</zero_position_armed>
<joint_control_type>velocity</joint_control_type>
</channel>

I know this is a bit convoluted but hope you can navigate through the problem :)

@pascalau
Copy link
Collaborator

pascalau commented Dec 15, 2021

If I see this correctly the model used for the simulation is:
https://github.com/PX4/PX4-SITL_gazebo/blob/27298574ce33a79ba6cfc31ed4604974605e7257/models/iris/iris.sdf.jinja#L353-L369
Which implies that the range [0,1] should be mapped to [0,2200] because of the inputscaling of 2 and the maxRotVelocity of 1100.

@Jaeyoung-Lim
Copy link
Member Author

Jaeyoung-Lim commented Dec 15, 2021

@pascalau Ah your right the pre-estimation model is that one and your probably right.

So basically the estimated models all had the wrong input scaling and that is where the difference of behavior was coming from

@pascalau
Copy link
Collaborator

A max_output value of 2200 does not lead to the same parameters as the groundtruth. I'm not sure if I am missing something.

@manumerous
Copy link
Contributor

That is very cool! Good catch!

I had a quick look at the parameters and they seem to be close enough as you said.

If it is true that the iris has a max output of 2200 it would be good to add the min/max output values to the config of each vehicle. This way the normalization could be adapted to each vehicles need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants