Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Trad Heli: [GSoC] Autonomous Autorotation - SITL only #12108
This PR is to merge the work done so far on the autonomous autorotation controller. So far the Entry, Glide, and Bail Out phases have been developed to the point of being ready to incorporate into master. As it is incomplete, this flight mode has been made SITL only. Development is ongoing, however I would like for this to be merged into master at this stage to effectively act as a 'space saver' in the code and help me keep on top of maintaining the currency of the code with master.
Here is a demo of the functionality and brief explaination of how to use the flight mode using Real Flight 8.
Switching into this flight mode is different to 'normal' flight modes. This diagram illustrates the switchology.
This library holds all of the functions and parameters that are bespoke to the autorotation flight mode. Future autorotation functions will be stored here. The main two functions are update_hs_glide_controller() and get_rpm().
update_hs_glide_controller() is the head speed controller. This manipulates the collective position to achieve and maintain head speed. It utilises a simple P-term controller and a following trim. The following trim applys a LPF to the previous collective setting to control the rate at which the trim can change. During the entry phase the trim changes much quicker to achieve a sensible trim position. The trim is slowed down during the glide. This allows for fine tuning adjustments and reduces sensitivity to transient effects such as gusting winds.
get_rpm() interfaces with the RPM library, getting the correct RPM instance to be used for measuring the main rotor head speed. It also conducts sensor health monitoring and relays to the head speed controller if the sensor can be trusted or not. A demonstration of the sensor switching and the controller behaviour with poor RPM sensor health can be seen here:
The parameters are as follows:
AROT_ENABLE - Enables the autorotation mode and displays the AROT parameters.
AROT_HS_P - P gain for the head speed controller. This parameter should need tuning. It should work for all helis.
AROT_HS_SP - Set Point for the head speed controller. This is the target RPM for the main rotor. Start by using the hover head speed
AROT_TARG_SP - Target forward speed (cm/s). This is the target speed passed to the speed height controller.
AROT_COL_FILT_E - The low pass filter cut off frequency (Hz), applied to the collective during the entry phase. This shouldn't need tuning.
AROT_COL_FILT_G - The low pass filter cut off frequency (Hz), applied to the collective during the glide phase. This shouldn't need tuning.
AROT_AS_ACC_MAX - The maximum forward acceleration applied to the speed-height controller (cm/s/s).
AROT_BAIL_TIME - The time in seconds between initiating the bail out phase and hand over to the new flight mode.
AROT_HS_SENSOR - The RPM sensor instance to be used to measure main rotor head speed. 0 - RPM Sensor 1, 1 - RPM sensor 2. Must be 0 in SITL with real flight.
Speed Height Library
This library holds the functions for the forward speed/pitch control. This library was cherry-picked from @bnsgeyer 's L1-nav controller. I have modified it slightly. I moved the forward speed calculation into its own function, to allow it to be used by mode_autorotation.cpp. I removed the D-term as it is unnecessary/doesn't contribute must to this controller. The controller uses the PID library to convert the desired velocity into a desired acceleration. The acceleration is then limited to prevent over pitching and ensure smooth transitions. The acceleration is then converted into a pitch target using a little geometry. The pitch target is retrieved by mode_autorotation.cpp and passed to the attitude controller.
The parameters are as follows:
SPDHGT_VEL_P - P term gain
SPDHGT_VEL_I - I term gain
SPDHGT_VEL_D - D term gain. Not used but shows up as part of the PID library.
SPDHGT_VEL_FF - Feed forward term gain
SPDHGT_VEL_IMAX - I term limit.
SPDHGT_VEL_FLTT - Target filter
SPDHGT_VEL_FLTE - Error filter
SPDHGT_VEL_FLTD - D term filter. Not used but shows up as part of the PID library.
rmackay9 left a comment
In general this looks pretty good. I've made a significant number of comments but most of them are non-functional formatting and style changes so hopefully they will be easy-ish to take care of. Some of my comments can be ignored of course if you and BillG don't agree. Txs!
Thank you for the review @rmackay9. There is a lot in there to help me learn, so I appricate you taking the time to explain things. I will get those changes implemented. I am also working on getting the parameters moved over to G2. Having a few difficulties with getting that working at the moment, but I am working through it.
I have been trying to move my parameters over to the G2 class as requested by @tridge . The parameters now show up but won't load defaults. I am completely stumped on this one, and have been working on it for ages. @rmackay9 @tridge @peterbarker would any of you have time to look over what I am doing and point me in the right direction please? Any advice is greatly received.
On Mon, 7 Oct 2019, Matt Kear wrote: I have been trying to move my parameters over to the G2 class as requested by @tridge . The parameters now show up but won't load defaults. I am completely stumped on this one, and have been working on it for ages. @rmackay9 @tridge @peterbarker would any of you have time to look over what I am doing and point me in the right direction please? Any advice is greatly received.
I think the problem might be that you're missing a call to setup_object_defaults Peter