Browse Source

Tiltrotor: add transtion class

gps-1.3.1
Iampete1 3 years ago committed by Andrew Tridgell
parent
commit
9073d16b09
  1. 38
      ArduPlane/tiltrotor.cpp
  2. 28
      ArduPlane/tiltrotor.h

38
ArduPlane/tiltrotor.cpp

@ -92,7 +92,7 @@ void Tiltrotor::setup()
enable.set_and_save(1); enable.set_and_save(1);
} }
if (!enabled()) { if (enable <= 0) {
return; return;
} }
@ -115,6 +115,14 @@ void Tiltrotor::setup()
SRV_Channels::set_range(SRV_Channel::k_tiltMotorRearRight, 1000); 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 && 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 // we are transitioning to fixed wing - tilt the motors all
// the way forward // the way forward
slew(1); slew(1);
@ -600,4 +608,30 @@ void Tiltrotor::update_yaw_target(void)
} }
transition_yaw_set_ms = now; 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 #endif // HAL_QUADPLANE_ENABLED

28
ArduPlane/tiltrotor.h

@ -15,17 +15,21 @@
#pragma once #pragma once
#include <AP_Param/AP_Param.h> #include <AP_Param/AP_Param.h>
#include "transition.h"
class QuadPlane; class QuadPlane;
class AP_MotorsMulticopter; class AP_MotorsMulticopter;
class Tiltrotor_Transition;
class Tiltrotor class Tiltrotor
{ {
friend class QuadPlane; friend class QuadPlane;
friend class Plane; friend class Plane;
friend class Tiltrotor_Transition;
public: public:
Tiltrotor(QuadPlane& _quadplane, AP_MotorsMulticopter*& _motors); Tiltrotor(QuadPlane& _quadplane, AP_MotorsMulticopter*& _motors);
bool enabled() const { return enable > 0;} bool enabled() const { return (enable > 0) && setup_complete;}
void setup(); void setup();
@ -81,8 +85,30 @@ public:
private: private:
bool setup_complete;
// refences for convenience // refences for convenience
QuadPlane& quadplane; QuadPlane& quadplane;
AP_MotorsMulticopter*& motors; 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…
Cancel
Save