mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-23 00:04:02 -04:00
Tiltrotor: add transtion class
This commit is contained in:
parent
ce5b81869d
commit
9073d16b09
@ -92,7 +92,7 @@ void Tiltrotor::setup()
|
||||
enable.set_and_save(1);
|
||||
}
|
||||
|
||||
if (!enabled()) {
|
||||
if (enable <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -115,6 +115,14 @@ void Tiltrotor::setup()
|
||||
SRV_Channels::set_range(SRV_Channel::k_tiltMotorRearRight, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
transition = new Tiltrotor_Transition(quadplane, motors, *this);
|
||||
if (!transition) {
|
||||
AP_BoardConfig::allocation_error("tiltrotor transition");
|
||||
}
|
||||
quadplane.transition = transition;
|
||||
|
||||
setup_complete = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -248,7 +256,7 @@ void Tiltrotor::continuous_update(void)
|
||||
}
|
||||
|
||||
if (quadplane.assisted_flight &&
|
||||
quadplane.transition_state >= QuadPlane::TRANSITION_TIMER) {
|
||||
transition->transition_state >= Tiltrotor_Transition::TRANSITION_TIMER) {
|
||||
// we are transitioning to fixed wing - tilt the motors all
|
||||
// the way forward
|
||||
slew(1);
|
||||
@ -600,4 +608,30 @@ void Tiltrotor::update_yaw_target(void)
|
||||
}
|
||||
transition_yaw_set_ms = now;
|
||||
}
|
||||
|
||||
bool Tiltrotor_Transition::update_yaw_target(float& yaw_target_cd)
|
||||
{
|
||||
if (!(tiltrotor.is_vectored() &&
|
||||
transition_state <= TRANSITION_TIMER)) {
|
||||
return false;
|
||||
}
|
||||
tiltrotor.update_yaw_target();
|
||||
yaw_target_cd = tiltrotor.transition_yaw_cd;
|
||||
return true;
|
||||
}
|
||||
|
||||
// return true if we should show VTOL view
|
||||
bool Tiltrotor_Transition::show_vtol_view() const
|
||||
{
|
||||
bool show_vtol = quadplane.in_vtol_mode();
|
||||
|
||||
if (!show_vtol && tiltrotor.is_vectored() && transition_state <= TRANSITION_TIMER) {
|
||||
// we use multirotor controls during fwd transition for
|
||||
// vectored yaw vehicles
|
||||
return true;
|
||||
}
|
||||
|
||||
return show_vtol;
|
||||
}
|
||||
|
||||
#endif // HAL_QUADPLANE_ENABLED
|
||||
|
@ -15,17 +15,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <AP_Param/AP_Param.h>
|
||||
#include "transition.h"
|
||||
|
||||
class QuadPlane;
|
||||
class AP_MotorsMulticopter;
|
||||
class Tiltrotor_Transition;
|
||||
class Tiltrotor
|
||||
{
|
||||
friend class QuadPlane;
|
||||
friend class Plane;
|
||||
friend class Tiltrotor_Transition;
|
||||
public:
|
||||
|
||||
Tiltrotor(QuadPlane& _quadplane, AP_MotorsMulticopter*& _motors);
|
||||
|
||||
bool enabled() const { return enable > 0;}
|
||||
bool enabled() const { return (enable > 0) && setup_complete;}
|
||||
|
||||
void setup();
|
||||
|
||||
@ -81,8 +85,30 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
bool setup_complete;
|
||||
|
||||
// refences for convenience
|
||||
QuadPlane& quadplane;
|
||||
AP_MotorsMulticopter*& motors;
|
||||
|
||||
Tiltrotor_Transition* transition;
|
||||
|
||||
};
|
||||
|
||||
// Transition for separate left thrust quadplanes
|
||||
class Tiltrotor_Transition : public SLT_Transition
|
||||
{
|
||||
friend class Tiltrotor;
|
||||
public:
|
||||
|
||||
Tiltrotor_Transition(QuadPlane& _quadplane, AP_MotorsMulticopter*& _motors, Tiltrotor& _tiltrotor):SLT_Transition(_quadplane, _motors), tiltrotor(_tiltrotor) {};
|
||||
|
||||
bool update_yaw_target(float& yaw_target_cd) override;
|
||||
|
||||
bool show_vtol_view() const override;
|
||||
|
||||
private:
|
||||
|
||||
Tiltrotor& tiltrotor;
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user