mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-21 20:53:52 +08:00
colcon build/test / build-test (push) Waiting to run
Cygwin Build / build (push) Waiting to run
ESP32 Build / build (esp32buzz, 10) (push) Waiting to run
ESP32 Build / build (esp32s3empty, 10) (push) Waiting to run
Macos Build / build (CubeOrange) (push) Waiting to run
Macos Build / build (sitl) (push) Waiting to run
QURT Build / build (push) Waiting to run
test ccache / build (10, chibios) (push) Waiting to run
test chibios / build (CubeOrange-ODID, 10, chibios) (push) Waiting to run
test chibios / build (CubeOrange-PPP, 10, chibios) (push) Waiting to run
test chibios / build (CubeOrange-bootloader, 10, chibios) (push) Waiting to run
test chibios / build (CubeRed-EKF2, 10, chibios) (push) Waiting to run
test chibios / build (CubeRedPrimary-bootloader, 10, chibios) (push) Waiting to run
test chibios / build (MatekF405-Wing, 10, chibios) (push) Waiting to run
test chibios / build (Pixhawk6X-PPPGW, 10, chibios) (push) Waiting to run
test chibios / build (SOHW, 10, chibios) (push) Waiting to run
test chibios / build (build-options-defaults-test, 10, chibios) (push) Waiting to run
test chibios / build (configure-all, 10, chibios) (push) Waiting to run
test chibios / build (fmuv2-plane, 10, chibios) (push) Waiting to run
test chibios / build (fmuv3, 10, chibios) (push) Waiting to run
test chibios / build (fmuv3-bootloader, 10, chibios) (push) Waiting to run
test chibios / build (iofirmware, 10, chibios) (push) Waiting to run
test chibios / build (new-check, 10, chibios) (push) Waiting to run
test chibios / build (periph-build, 10, chibios) (push) Waiting to run
test chibios / build (revo-bootloader, 10, chibios) (push) Waiting to run
test chibios / build (revo-mini, 10, chibios) (push) Waiting to run
test chibios / build (signing, 10, chibios) (push) Waiting to run
test chibios / build (stm32f7, 10, chibios) (push) Waiting to run
test chibios / build (stm32h7, 10, chibios) (push) Waiting to run
test chibios / build (stm32h7-debug, 10, chibios) (push) Waiting to run
test dds / build (sitl) (push) Waiting to run
test dds / build (stm32h7) (push) Waiting to run
test Linux SBC / build (bbbmini, armhf) (push) Waiting to run
test Linux SBC / build (bebop, armhf) (push) Waiting to run
test Linux SBC / build (bhat, armhf) (push) Waiting to run
test Linux SBC / build (canzero, armhf) (push) Waiting to run
test Linux SBC / build (erlebrain2, armhf) (push) Waiting to run
test Linux SBC / build (linux, base) (push) Waiting to run
test Linux SBC / build (navigator, armhf-musl) (push) Waiting to run
test Linux SBC / build (navigator64, aarch64) (push) Waiting to run
test Linux SBC / build (navio, armhf) (push) Waiting to run
test Linux SBC / build (navio2, armhf) (push) Waiting to run
test Linux SBC / build (pxf, armhf) (push) Waiting to run
test Linux SBC / build (pxfmini, armhf) (push) Waiting to run
test replay / build (replay, base) (push) Waiting to run
test replay / build (replay, clang) (push) Waiting to run
test scripts / build (astyle-cleanliness) (push) Waiting to run
test scripts / build (check_autotest_options) (push) Waiting to run
test scripts / build (logger_metadata) (push) Waiting to run
test scripts / build (param_parse) (push) Waiting to run
test scripts / build (python-cleanliness) (push) Waiting to run
test scripts / build (validate_board_list) (push) Waiting to run
test blimp / build (base) (push) Waiting to run
test blimp / build (clang) (push) Waiting to run
test blimp / autotest (sitltest-blimp) (push) Blocked by required conditions
test copter / build (base) (push) Waiting to run
test copter / build (clang) (push) Waiting to run
test copter / autotest (sitltest-copter-tests1a) (push) Blocked by required conditions
test copter / autotest (sitltest-copter-tests1b) (push) Blocked by required conditions
test copter / autotest (sitltest-copter-tests1c) (push) Blocked by required conditions
test copter / autotest (sitltest-copter-tests1d) (push) Blocked by required conditions
test copter / autotest (sitltest-copter-tests1e) (push) Blocked by required conditions
test copter / autotest (sitltest-copter-tests2a) (push) Blocked by required conditions
test copter / autotest (sitltest-copter-tests2b) (push) Blocked by required conditions
test copter / build-gcc-heli (push) Waiting to run
test copter / autotest-heli (sitltest-heli) (push) Blocked by required conditions
test ap_periph / build-gcc-ap_periph (push) Waiting to run
test ap_periph / autotest-can (sitltest-can) (push) Blocked by required conditions
test plane / build (base) (push) Waiting to run
test plane / build (clang) (push) Waiting to run
test plane / autotest (sitltest-plane-tests1a) (push) Blocked by required conditions
test plane / autotest (sitltest-plane-tests1b) (push) Blocked by required conditions
test plane / autotest (sitltest-quadplane) (push) Blocked by required conditions
test rover / build (base) (push) Waiting to run
test rover / build (clang) (push) Waiting to run
test rover / autotest (sitltest-balancebot) (push) Blocked by required conditions
test rover / autotest (sitltest-rover) (push) Blocked by required conditions
test rover / autotest (sitltest-sailboat) (push) Blocked by required conditions
test sub / build (base) (push) Waiting to run
test sub / build (clang) (push) Waiting to run
test sub / autotest (sitltest-sub) (push) Blocked by required conditions
test tracker / build (base) (push) Waiting to run
test tracker / build (clang) (push) Waiting to run
test tracker / autotest (sitltest-tracker) (push) Blocked by required conditions
test unit tests and sitl building / build (examples, base) (push) Waiting to run
test unit tests and sitl building / build (examples, clang) (push) Waiting to run
test unit tests and sitl building / build (sitl, base) (push) Waiting to run
test unit tests and sitl building / build (sitl, clang) (push) Waiting to run
test unit tests and sitl building / build (unit-tests, base) (push) Waiting to run
test unit tests and sitl building / build (unit-tests, clang) (push) Waiting to run
test scripting / test-scripting (push) Has been cancelled
103 lines
3.7 KiB
C++
103 lines
3.7 KiB
C++
#include "mode.h"
|
|
#include "Plane.h"
|
|
|
|
#if HAL_QUADPLANE_ENABLED
|
|
|
|
bool ModeQStabilize::_enter()
|
|
{
|
|
quadplane.throttle_wait = false;
|
|
return true;
|
|
}
|
|
|
|
void ModeQStabilize::update()
|
|
{
|
|
// set nav_roll and nav_pitch using sticks
|
|
// Beware that QuadPlane::tailsitter_check_input (called from Plane::read_radio)
|
|
// may alter the control_in values for roll and yaw, but not the corresponding
|
|
// radio_in values. This means that the results for norm_input would not necessarily
|
|
// be correct for tailsitters, so get_control_in() must be used instead.
|
|
// normalize control_input to [-1,1]
|
|
const float roll_input = (float)plane.channel_roll->get_control_in() / plane.channel_roll->get_range();
|
|
const float pitch_input = (float)plane.channel_pitch->get_control_in() / plane.channel_pitch->get_range();
|
|
|
|
// then scale to target angles in centidegrees
|
|
if (plane.quadplane.tailsitter.active()) {
|
|
// tailsitters are different
|
|
set_tailsitter_roll_pitch(roll_input, pitch_input);
|
|
return;
|
|
}
|
|
|
|
if (!plane.quadplane.option_is_set(QuadPlane::OPTION::INGORE_FW_ANGLE_LIMITS_IN_Q_MODES)) {
|
|
// by default angles are also constrained by forward flight limits
|
|
set_limited_roll_pitch(roll_input, pitch_input);
|
|
} else {
|
|
// use angle max for both roll and pitch
|
|
plane.nav_roll_cd = roll_input * plane.quadplane.aparm.angle_max;
|
|
plane.nav_pitch_cd = pitch_input * plane.quadplane.aparm.angle_max;
|
|
}
|
|
}
|
|
|
|
// quadplane stabilize mode
|
|
void ModeQStabilize::run()
|
|
{
|
|
const uint32_t now = AP_HAL::millis();
|
|
if (quadplane.tailsitter.in_vtol_transition(now)) {
|
|
// Tailsitters in FW pull up phase of VTOL transition run FW controllers
|
|
Mode::run();
|
|
return;
|
|
}
|
|
|
|
plane.quadplane.assign_tilt_to_fwd_thr();
|
|
|
|
// special check for ESC calibration in QSTABILIZE
|
|
if (quadplane.esc_calibration != 0) {
|
|
quadplane.run_esc_calibration();
|
|
plane.stabilize_roll();
|
|
plane.stabilize_pitch();
|
|
return;
|
|
}
|
|
|
|
// normal QSTABILIZE mode
|
|
float pilot_throttle_scaled = quadplane.get_pilot_throttle();
|
|
quadplane.hold_stabilize(pilot_throttle_scaled);
|
|
|
|
// Stabilize with fixed wing surfaces
|
|
plane.stabilize_roll();
|
|
plane.stabilize_pitch();
|
|
|
|
// Center rudder
|
|
output_rudder_and_steering(0.0);
|
|
}
|
|
|
|
// set the desired roll and pitch for a tailsitter
|
|
void ModeQStabilize::set_tailsitter_roll_pitch(const float roll_input, const float pitch_input)
|
|
{
|
|
// separate limit for roll, if set
|
|
if (plane.quadplane.tailsitter.max_roll_angle > 0) {
|
|
// roll param is in degrees not centidegrees
|
|
plane.nav_roll_cd = plane.quadplane.tailsitter.max_roll_angle * 100.0f * roll_input;
|
|
} else {
|
|
plane.nav_roll_cd = roll_input * plane.quadplane.aparm.angle_max;
|
|
}
|
|
|
|
// angle max for tailsitter pitch
|
|
plane.nav_pitch_cd = pitch_input * plane.quadplane.aparm.angle_max;
|
|
|
|
plane.quadplane.transition->set_VTOL_roll_pitch_limit(plane.nav_roll_cd, plane.nav_pitch_cd);
|
|
}
|
|
|
|
// set the desired roll and pitch for normal quadplanes, also limited by forward flight limits
|
|
void ModeQStabilize::set_limited_roll_pitch(const float roll_input, const float pitch_input)
|
|
{
|
|
plane.nav_roll_cd = roll_input * MIN(plane.roll_limit_cd, plane.quadplane.aparm.angle_max);
|
|
// pitch is further constrained by PTCH_LIM_MIN/MAX which may impose
|
|
// tighter (possibly asymmetrical) limits than Q_ANGLE_MAX
|
|
if (pitch_input > 0) {
|
|
plane.nav_pitch_cd = pitch_input * MIN(plane.aparm.pitch_limit_max*100, plane.quadplane.aparm.angle_max);
|
|
} else {
|
|
plane.nav_pitch_cd = pitch_input * MIN(-plane.pitch_limit_min*100, plane.quadplane.aparm.angle_max);
|
|
}
|
|
}
|
|
|
|
#endif
|