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

Implement assisted autorotation for Heli’s #22871

Open
wants to merge 61 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
99adf3e
AC_Autorotation: Assisted Autorotation Implementation
Ferruccio1984 Mar 24, 2022
18df15c
Copter: Assisted Autorotation Implementation
Ferruccio1984 Mar 24, 2022
9147f2f
AP_Motors: Support for Assisted Autorotation
Ferruccio1984 Aug 29, 2023
9b09716
AC_Autorotation: fix error for autotest
bnsgeyer Dec 23, 2023
4c9e076
AC_Autorotation: fix parameter naming
bnsgeyer Dec 23, 2023
e31ea19
Copter: fix style on mode_autorotate.cpp
bnsgeyer Dec 24, 2023
4053ff8
AC_Autorotation: fix style on AC_Autorotation.cpp
bnsgeyer Dec 24, 2023
079c189
Heli: Simplify passing rangefinder measurement to autorotation
MattKear Jan 4, 2024
321bb44
AP_Motors_Heli: Add helper to get hover col angle
MattKear Jan 4, 2024
9dcec13
AC_Autorotation: Create Init function and directly access AP_Motors_H…
MattKear Jan 4, 2024
006a3b6
Copter: Pass motors ptr to autorotation object
MattKear Jan 4, 2024
3959534
Copter: Remove now unused function calls to Autorotate object
MattKear Jan 4, 2024
e7887eb
AC_Autorotation: White space changes and minor formatting
MattKear Jan 4, 2024
a9e2c26
AC_Autorotation: Fix and rename average z accel function
MattKear Jan 4, 2024
ed8d1aa
Copter: Update average z accel function name in autorotation
MattKear Jan 4, 2024
6cfd4bb
AC_Autorotation: tidy up logging
MattKear Jan 4, 2024
aa3d54a
AC_Autorotation: Consolidate controller inits
MattKear Jan 4, 2024
af175b9
Copter: Autorotation: Consolidate controller inits
MattKear Jan 4, 2024
4ce4e2c
AC_Autorotation
Ferruccio1984 Jan 20, 2024
5549244
AC_Autorotation: update name of altitude estimation function
Ferruccio1984 Jan 23, 2024
1aba9ad
AC_Autorotation: squared gravitational acc const
Ferruccio1984 Jan 23, 2024
b61eee3
AC_Autorotation: remove array zeroing of sink rate derivative
Ferruccio1984 Jan 23, 2024
b2fe6a3
Copter: move time_to_impact to local float
bnsgeyer Jan 27, 2024
ee2dff7
Copter: Autorotation mode: simplify time_to_impact
MattKear Jan 25, 2024
71c92af
AC_Autorotation: Tidy up time to impact calculation
MattKear Jan 25, 2024
651e3f7
AC_Autorotation: Add helper functions to move phase init functionaili…
MattKear Jan 25, 2024
9aece05
Copter: autorotation mode: Move phase init functions down into autoro…
MattKear Jan 25, 2024
e314f5c
Copter: autorotation mode: remove unused variables
MattKear Jan 25, 2024
e3fa52d
Copter: autorotation mode: simplify hover autorotation check
MattKear Jan 25, 2024
26659ad
Copter: Autorotation Mode: rename get_flare_status to is_flare_comple…
MattKear Jan 28, 2024
93ddcc4
AC_Autorotation: Rename get_flare_status to is_flare_complete to impr…
MattKear Jan 28, 2024
e153490
AC_Autorotation: Add flare height helper
MattKear Feb 6, 2024
ea61936
Copter: remove land detector in mode autorotate and fix for disarm delay
Ferruccio1984 Jan 29, 2024
afff5a1
AC_Autorotation: add touchdown complete check and subsequent lowering…
Ferruccio1984 Jan 29, 2024
0887aff
AC_Autorotation: Remove touch down complete bool and just use the tim…
MattKear Feb 6, 2024
ee06b79
AC_Autorotation: Let copter do all of the height above ground estimat…
MattKear Feb 6, 2024
9214267
Copter: Use copters inertial navigation interpolation of the rangefin…
MattKear Feb 6, 2024
c2b8589
Copter: Autorotation Mode: Make the hover autorotation it's own fligh…
MattKear Feb 6, 2024
ee7b895
AC_Autorotation: Add helpers for state machine logic tidy up and remo…
MattKear Feb 6, 2024
a42288d
Copter: Autorotation Mode: Rework logic machine to make it easier to …
MattKear Feb 6, 2024
29c2d35
AC_Autorotation: Make param defaults numeric values if the defines ar…
MattKear Feb 6, 2024
ad64639
AC_Autorotation: Added Comments and whitespace fixups
MattKear Feb 6, 2024
f101a21
AC_Autorotation: Fix data type for time_on_ground
MattKear Feb 6, 2024
61c6e60
Copter: Autorotation Mode: Whitespace changes, comments updated, and …
MattKear Feb 6, 2024
0798ca6
Copter: Autorotation Mode: Use standard earth_to_body2D velocity rota…
MattKear Feb 7, 2024
ba3fbaf
AC_Autorotation: Add options param and give roll-yaw control scheme o…
MattKear Feb 7, 2024
a1b0725
Copter: Autorotation mode: Make control schemes for roll and yaw opti…
MattKear Feb 7, 2024
3384684
AC_Autorotation: Remove sink derivative and only use filtered accel.
MattKear Feb 7, 2024
64829ac
Copter: Autorotation Mode: Remove calls to update derive sink rate
MattKear Feb 7, 2024
72553f7
Copter: Autorotation mode: Simplify rpm warning message code structur…
MattKear Feb 7, 2024
7fddf29
Copter: Autorotation Mode: Update comments and white space change
MattKear Feb 7, 2024
bbebd62
AC_Autorotation: update comments
MattKear Feb 7, 2024
a895d15
AC_Autorotation: Remove unused variables
MattKear Feb 7, 2024
aaee063
AC_Autorotation: fix options param index
MattKear Feb 14, 2024
9e110c9
Copter: Always update the ground distance in the autorotation library…
MattKear Feb 14, 2024
7fd07b4
AP_Motors: Heli: Add helper to calculated norm collective from a giv…
MattKear Feb 14, 2024
533e202
AC_Autorotation: Simplify bad RPM handling, leaving to RPM lib to det…
MattKear Feb 14, 2024
6547e24
Copter: Autorotation mode: remove bad rpm handling
MattKear Feb 14, 2024
6f3eff1
AP_Motors: temporary fix to prevent I-term decay during autorotations
Ferruccio1984 Feb 16, 2024
2cde571
AP_Motors: return collective land position
Ferruccio1984 Feb 16, 2024
241959e
AC_Autorotation: fix for post touchdown disarming
Ferruccio1984 Feb 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ArduCopter/Parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ ParametersG2::ParametersG2(void)
,mode_systemid_ptr(&copter.mode_systemid)
#endif
#if MODE_AUTOROTATE_ENABLED == ENABLED
,arot()
,arot(copter.inertial_nav, copter.ahrs)
#endif
#if HAL_BUTTON_ENABLED
,button_ptr(&copter.button)
Expand Down
18 changes: 7 additions & 11 deletions ArduCopter/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,13 @@
//////////////////////////////////////////////////////////////////////////////
// Autorotate - autonomous auto-rotation - helicopters only
#ifndef MODE_AUTOROTATE_ENABLED
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#if FRAME_CONFIG == HELI_FRAME
#ifndef MODE_AUTOROTATE_ENABLED
# define MODE_AUTOROTATE_ENABLED ENABLED
#endif
#else
# define MODE_AUTOROTATE_ENABLED DISABLED
#endif
#else
# define MODE_AUTOROTATE_ENABLED DISABLED
#endif
#if FRAME_CONFIG == HELI_FRAME
#ifndef MODE_AUTOROTATE_ENABLED
# define MODE_AUTOROTATE_ENABLED ENABLED
#endif
#else
# define MODE_AUTOROTATE_ENABLED DISABLED
#endif
#endif

//////////////////////////////////////////////////////////////////////////////
Expand Down
15 changes: 14 additions & 1 deletion ArduCopter/heli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,19 @@ void Copter::heli_update_rotor_speed_targets()
// to autorotation flight mode if manual collective is not being used.
void Copter::heli_update_autorotation()
{
#if MODE_AUTOROTATE_ENABLED == ENABLED
// Always update the ground distance to prevent a race on init
if (motors->armed() && g2.arot.is_enable()) {
// Get height above ground. If using a healthy LiDaR below func will return an interpolated
// distance based on inertial measurement. If LiDaR is unhealthy and terrain is available
// we will get a terrain database estimate. Otherwise we will get height above home.
int32_t gnd_dist = flightmode->get_alt_above_ground_cm(false);

// set the height in the autorotation controller
g2.arot.set_ground_distance(gnd_dist);
}
#endif

// check if flying and interlock disengaged
if (!ap.land_complete && !motors->get_interlock()) {
#if MODE_AUTOROTATE_ENABLED == ENABLED
Expand All @@ -204,7 +217,7 @@ void Copter::heli_update_autorotation()
// set autonomous autorotation flight mode
set_mode(Mode::Number::AUTOROTATE, ModeReason::AUTOROTATION_START);
}
// set flag to facilitate both auto and manual autorotations
// set flag to facilitate auto autorotation
heli_flags.in_autorotation = true;
motors->set_in_autorotation(heli_flags.in_autorotation);
motors->set_enable_bailout(true);
Expand Down
4 changes: 2 additions & 2 deletions ArduCopter/mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,13 @@ void Mode::make_safe_ground_handling(bool force_throttle_unlimited)
/*
get a height above ground estimate for landing
*/
int32_t Mode::get_alt_above_ground_cm(void)
int32_t Mode::get_alt_above_ground_cm(bool use_psc_case)
{
int32_t alt_above_ground_cm;
if (copter.get_rangefinder_height_interpolated_cm(alt_above_ground_cm)) {
return alt_above_ground_cm;
}
if (!pos_control->is_active_xy()) {
if (!pos_control->is_active_xy() && use_psc_case) {
return copter.current_loc.alt;
}
Comment on lines +618 to 620
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect we can just remove this whole section. I don't understand why it would just return current loc rather than trying to get the terrain value. As far as I can tell the only user that is not in position control is landing gear.

In anycase, removing this section means you can also remove the new bool.

if (copter.current_loc.get_alt_cm(Location::AltFrame::ABOVE_TERRAIN, alt_above_ground_cm)) {
Expand Down
34 changes: 12 additions & 22 deletions ArduCopter/mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Mode {
virtual bool set_speed_up(float speed_xy_cms) {return false;}
virtual bool set_speed_down(float speed_xy_cms) {return false;}

int32_t get_alt_above_ground_cm(void);
int32_t get_alt_above_ground_cm(bool use_psc_case=true);

// pilot input processing
void get_pilot_desired_lean_angles(float &roll_out_cd, float &pitch_out_cd, float angle_max_cd, float angle_limit_cd) const;
Expand Down Expand Up @@ -1934,39 +1934,29 @@ class ModeAutorotate : public Mode {
uint32_t _bail_time_start_ms; // Time at start of bail out
float _target_climb_rate_adjust;// Target vertical acceleration used during bail out phase
float _target_pitch_adjust; // Target pitch rate used during bail out phase
uint32_t _touchdown_time_ms;
bool _hover_autorotation; // bool to determine if we should enter the hover autorotation or not

enum class Autorotation_Phase {
ENTRY,
HOVER_ENTRY,
SS_GLIDE,
FLARE,
TOUCH_DOWN,
BAIL_OUT } phase_switch;

enum class Navigation_Decision {
USER_CONTROL_STABILISED,
STRAIGHT_AHEAD,
INTO_WIND,
NEAREST_RALLY} nav_pos_switch;

// --- Internal flags ---
struct controller_flags {
bool entry_initial : 1;
bool ss_glide_initial : 1;
bool flare_initial : 1;
bool touch_down_initial : 1;
bool straight_ahead_initial : 1;
bool level_initial : 1;
bool break_initial : 1;
bool bail_out_initial : 1;
bool bad_rpm : 1;
bool entry_init : 1;
bool hover_entry_init : 1;
bool ss_glide_init : 1;
bool flare_init : 1;
bool touch_down_init : 1;
bool bail_out_init : 1;
bool bad_rpm : 1;
} _flags;

struct message_flags {
bool bad_rpm : 1;
} _msg_flags;

//--- Internal functions ---
void warning_message(uint8_t message_n); //Handles output messages to the terminal
uint32_t _last_bad_rpm_ms;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its a little odd having this bad rpm time stamp in a different structure to the bad_rpm flag. Maybe combine:

    struct {
        uint32_t last_ms;
        bool bad;
    } _rpm;


};
#endif
Loading
Loading