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

[WIP]: Rate control: introduce torque_setpoint, angular_accel_setpoint, and inertia matrix #13219

Closed
wants to merge 11 commits into from

Conversation

jlecoeur
Copy link
Contributor

@jlecoeur jlecoeur commented Oct 17, 2019

This is a first step towards more unit-aware controllers.

As of now, the output of the rate controller does not have unit (this is a normalized torque setpoint). Although this makes things simple and has always worked like it, this has a few limitations:

  • This will limit the use of actual vehicle properties in a (future) control allocation scheme.
  • There were a few requests for the possibility to provide torque setpoints in N.m.
  • Not having a model of the vehicle inertia may be problematic for applications where inertia changes over time (with fuel consumption, package delivery, etc).
  • Model-based control is difficult because of the lack of units.

I introduced several new things in this PR. I would like to hear your opinion on a few additions. (Note that with the default parameters, it should not break anything.)

  • computation of vehicle_angular_acceleration (in rad/s^2) and publication on a dedicated uORB topic.
    @dagar I did this in the sensor module although it is not a real sensor because I think this can be useful for more things than the MC controller, it is disabled by default.
    @MaEtUgR we may use this data for the D term in the rate controller instead of computing the derivative inside the controller. This may save some computation in VTOLs because both the MC and the FW controller compute rate derivatives.
  • addition of vehicle_angular_acceleration_setpoint, vehicle_thrust_setpoint, vehicle_torque_setpoint topics, with proper units.
  • the inertia matrix is included in the controller module.
    Eventually this could be moved into a separate module. Either MC or FW or VTOL controller would publish an angular acceleration setpoint and a feedforward torque setpoint. The new module would subscribe to these topics and then compute a torque setpoint based on its model of the vehicle.
  • split of the PD terms and I-FF terms (see the changes in RateControl.cpp).
    I use the P and D term to generate an angular acceleration setpoint, which is later mapped to torque via the inertia matrix. The integral and feed-forward terms are directly generating torque values (called torque_feedforward).
    If the I term was used to generate acceleration setpoints, you would have -- for an unbalanced system in equilibrium -- a steady-state angular acceleration setpoint, which does not make sense.

From there, I multiplied the P and D rate gains by 120 (roll), 120 (pitch) and 35 (yaw), and divided the inertia by the same amount.
This way the behaviour is not changed, but units are now OK (see on the graphs below how the angular acceleration somewhat matches the angular acceleration setpoint). I obtain this during steps on roll, pitch and yaw:
roll_step
pitch_step
yaw_step

The values of 120 and 35 were not chosen arbitrarily, we can in fact estimate them.
From a gazebo log, we can compute the time derivative of the vehicle angular acceleration and of the torque setpoint:
sysID
A quick eye fit gave me the inertia matrix

I = [1/120      0        0   ]
    [  0      1/120      0   ]
    [  0        0      1/35  ]

Let me know your opinion, shoot!

@dagar
Copy link
Member

dagar commented Oct 17, 2019

computation of vehicle_angular_acceleration (in rad/s^2) and publication on a dedicated uORB topic.
@dagar I did this in the sensor module although it is not a real sensor because I think this can be useful for more things than the MC controller, it is disabled by default.

One possibility I'm going to consider (if we ever manage to kill off DriverFramework - #12783) is moving the filtering to vehicle_angular_velocity and vehicle_acceleration rather than in each driver (we only need it for the primaries). Newer drivers using FIFOs (arrays of 4 or 8 raw samples) can publish that data to process downstream (#13103). I mention this now because it might be worth considering using that raw data to compute angular acceleration.

Related comment from @priseborough - PX4/PX4-ECL#621

The acceleration returned is at the sensor frame. The only way to return acceleration at the body origin would be to use angular accelerations which is problematic due to the issues associated with differentiating rate gyro noise. This was tried in the past using the downsampled data available to the EKF but the resulting data product was noisy when engine vibration was present. It may be possible if we do the differentiation and filtering in the sensor driver on the high rate data before downsampling. This rate acceleration would then be need to be added to the sensor topic used by the EKF.

@jlecoeur jlecoeur force-pushed the pr-ratectrl_torque_accel_inertia branch 2 times, most recently from ca12fbb to 4627455 Compare October 18, 2019 11:43
@jlecoeur jlecoeur force-pushed the pr-ratectrl_torque_accel_inertia branch from 4627455 to 7b76dc6 Compare October 20, 2019 17:02
@jlecoeur jlecoeur marked this pull request as ready for review October 21, 2019 09:20
@jlecoeur jlecoeur force-pushed the pr-ratectrl_torque_accel_inertia branch from 7b76dc6 to ed1b270 Compare October 25, 2019 11:55
@jlecoeur jlecoeur mentioned this pull request Nov 1, 2019
24 tasks
@zarathustr
Copy link

This may be useful for a satellite but seems not to be very necessary for the micro air vehicle. The reason is two-fold: how to measure the accurate inertia matrix; how to adapt this concept for multiple kinds of frames. I think this point is more worthy of consideration when a system identification is taken into account. By then the inertia matrix can be approximately obtained.

@jlecoeur
Copy link
Contributor Author

Hi @zarathustr, thanks for the comments. I do not agree that this is useless for small UAVs. There were numerous requests for proper units in the controller outputs. Also, there are systems with varying mass and inertia, like delivery drones, that are now being tested or even used in production and that could benefit from an inertia model. Regarding the system identification, I gave a simplified example, but there are much more advanced and accurate techniques available. Finally, you should not worry if you do not want/need or know the inertia of your robot because this is opt-in: the default inertia matrix is identity and thus has no impact.

@jlecoeur jlecoeur force-pushed the pr-ratectrl_torque_accel_inertia branch from 6e0e577 to 09bac11 Compare November 19, 2019 14:34
@jlecoeur jlecoeur requested a review from RomanBapst November 19, 2019 14:34
@jlecoeur
Copy link
Contributor Author

I cherry-picked commits from #13351

Let's try to get this in before it rots.

@RomanBapst can you check that the toque_sp and thrust_sp publication in FW and MC controllers is the same as what you have tested this morning?

@jlecoeur jlecoeur force-pushed the pr-ratectrl_torque_accel_inertia branch 3 times, most recently from 5938070 to c05d0f4 Compare November 21, 2019 18:30
@jlecoeur jlecoeur force-pushed the pr-ratectrl_torque_accel_inertia branch 2 times, most recently from 50b1bb1 to 2f392db Compare November 23, 2019 17:00
@jlecoeur
Copy link
Contributor Author

jlecoeur commented Nov 23, 2019

fmu-v2's flash overflows by 3437 bytes after a rebase to master :-(

There is not much left to remove on fmu-v2. I removed px4flow and pwm_out_sim, which is not great.

@jlecoeur jlecoeur force-pushed the pr-ratectrl_torque_accel_inertia branch from 2f392db to 22902da Compare November 24, 2019 10:42
@jlecoeur jlecoeur force-pushed the pr-ratectrl_torque_accel_inertia branch from d35d853 to e85fdb7 Compare November 25, 2019 18:04
@jlecoeur jlecoeur changed the title Rate control: introduce torque_setpoint, angular_accel_setpoint, and inertia matrix [WIP]: Rate control: introduce torque_setpoint, angular_accel_setpoint, and inertia matrix Nov 28, 2019
@jlecoeur
Copy link
Contributor Author

Holding this off for now, until work has progressed in #13351

@stale stale bot added the stale label Feb 27, 2020
@bresch bresch removed the stale label Feb 28, 2020
@stale stale bot added the stale label May 30, 2020
@bresch bresch removed the stale label May 31, 2020
@stale stale bot added the stale label Aug 29, 2020
@bresch bresch removed the stale label Oct 14, 2020
@PX4 PX4 deleted a comment from stale bot Oct 16, 2020
@PX4 PX4 deleted a comment from stale bot Oct 16, 2020
@PX4 PX4 deleted a comment from stale bot Oct 16, 2020
@LorenzMeier
Copy link
Member

I'm closing this as stale - please open a new rebased PR. Thanks!

@LorenzMeier LorenzMeier deleted the pr-ratectrl_torque_accel_inertia branch January 18, 2021 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants