mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-03 11:24:10 +01:00
Flight: Tweaked the throttle handling and VTOL use of it to make sure engines can be shut off easily in stabilization mode.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1593 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
56131476ef
commit
e90e714c2b
@ -292,6 +292,9 @@ static int32_t mixerVTOL(const ActuatorSettingsData* settings, const ActuatorDes
|
|||||||
VTOLStatusGet(&vtolStatus);
|
VTOLStatusGet(&vtolStatus);
|
||||||
|
|
||||||
const int vtolMin = -1;
|
const int vtolMin = -1;
|
||||||
|
int vtolMax = 1;
|
||||||
|
if(desired->Throttle < 0)
|
||||||
|
vtolMax = -1;
|
||||||
|
|
||||||
if(((settings->VTOLMotorN != ACTUATORSETTINGS_VTOLMOTORN_NONE) +
|
if(((settings->VTOLMotorN != ACTUATORSETTINGS_VTOLMOTORN_NONE) +
|
||||||
(settings->VTOLMotorNE != ACTUATORSETTINGS_VTOLMOTORS_NONE) +
|
(settings->VTOLMotorNE != ACTUATORSETTINGS_VTOLMOTORS_NONE) +
|
||||||
@ -308,7 +311,7 @@ static int32_t mixerVTOL(const ActuatorSettingsData* settings, const ActuatorDes
|
|||||||
vtolStatus.MotorN = bound(desired->Throttle * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_THROTTLE] +
|
vtolStatus.MotorN = bound(desired->Throttle * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_THROTTLE] +
|
||||||
desired->Pitch * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_PITCH] +
|
desired->Pitch * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_PITCH] +
|
||||||
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_ROLL] +
|
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_ROLL] +
|
||||||
desired->Yaw * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_YAW],vtolMin,1);
|
desired->Yaw * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_YAW],vtolMin,vtolMax);
|
||||||
cmd->Channel[settings->VTOLMotorN] = scaleChannel(vtolStatus.MotorN,
|
cmd->Channel[settings->VTOLMotorN] = scaleChannel(vtolStatus.MotorN,
|
||||||
settings->ChannelMax[settings->VTOLMotorN],
|
settings->ChannelMax[settings->VTOLMotorN],
|
||||||
settings->ChannelMin[settings->VTOLMotorN],
|
settings->ChannelMin[settings->VTOLMotorN],
|
||||||
@ -318,7 +321,7 @@ static int32_t mixerVTOL(const ActuatorSettingsData* settings, const ActuatorDes
|
|||||||
vtolStatus.MotorNE = bound(desired->Throttle * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_THROTTLE] +
|
vtolStatus.MotorNE = bound(desired->Throttle * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_THROTTLE] +
|
||||||
desired->Pitch * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_PITCH] +
|
desired->Pitch * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_PITCH] +
|
||||||
desired->Roll * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_ROLL] +
|
desired->Roll * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_ROLL] +
|
||||||
desired->Yaw * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_YAW],vtolMin,1);
|
desired->Yaw * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_YAW],vtolMin,vtolMax);
|
||||||
cmd->Channel[settings->VTOLMotorNE] = scaleChannel(vtolStatus.MotorNE,
|
cmd->Channel[settings->VTOLMotorNE] = scaleChannel(vtolStatus.MotorNE,
|
||||||
settings->ChannelMax[settings->VTOLMotorNE],
|
settings->ChannelMax[settings->VTOLMotorNE],
|
||||||
settings->ChannelMin[settings->VTOLMotorNE],
|
settings->ChannelMin[settings->VTOLMotorNE],
|
||||||
@ -328,7 +331,7 @@ static int32_t mixerVTOL(const ActuatorSettingsData* settings, const ActuatorDes
|
|||||||
vtolStatus.MotorE = bound(desired->Throttle * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_THROTTLE] +
|
vtolStatus.MotorE = bound(desired->Throttle * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_THROTTLE] +
|
||||||
desired->Pitch * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_PITCH] +
|
desired->Pitch * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_PITCH] +
|
||||||
desired->Roll * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_ROLL] +
|
desired->Roll * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_ROLL] +
|
||||||
desired->Yaw * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_YAW],vtolMin,1);
|
desired->Yaw * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_YAW],vtolMin,vtolMax);
|
||||||
cmd->Channel[settings->VTOLMotorE] = scaleChannel(vtolStatus.MotorE,
|
cmd->Channel[settings->VTOLMotorE] = scaleChannel(vtolStatus.MotorE,
|
||||||
settings->ChannelMax[settings->VTOLMotorE],
|
settings->ChannelMax[settings->VTOLMotorE],
|
||||||
settings->ChannelMin[settings->VTOLMotorE],
|
settings->ChannelMin[settings->VTOLMotorE],
|
||||||
@ -338,7 +341,7 @@ static int32_t mixerVTOL(const ActuatorSettingsData* settings, const ActuatorDes
|
|||||||
vtolStatus.MotorSE = bound(desired->Throttle * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_THROTTLE] +
|
vtolStatus.MotorSE = bound(desired->Throttle * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_THROTTLE] +
|
||||||
desired->Pitch * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_PITCH] +
|
desired->Pitch * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_PITCH] +
|
||||||
desired->Roll * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_ROLL] +
|
desired->Roll * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_ROLL] +
|
||||||
desired->Yaw * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_YAW],vtolMin,1);
|
desired->Yaw * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_YAW],vtolMin,vtolMax);
|
||||||
cmd->Channel[settings->VTOLMotorSE] = scaleChannel(vtolStatus.MotorSE,
|
cmd->Channel[settings->VTOLMotorSE] = scaleChannel(vtolStatus.MotorSE,
|
||||||
settings->ChannelMax[settings->VTOLMotorSE],
|
settings->ChannelMax[settings->VTOLMotorSE],
|
||||||
settings->ChannelMin[settings->VTOLMotorSE],
|
settings->ChannelMin[settings->VTOLMotorSE],
|
||||||
@ -348,7 +351,7 @@ static int32_t mixerVTOL(const ActuatorSettingsData* settings, const ActuatorDes
|
|||||||
vtolStatus.MotorS = bound(desired->Throttle * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_THROTTLE] +
|
vtolStatus.MotorS = bound(desired->Throttle * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_THROTTLE] +
|
||||||
desired->Pitch * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_PITCH] +
|
desired->Pitch * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_PITCH] +
|
||||||
desired->Roll * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_ROLL] +
|
desired->Roll * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_ROLL] +
|
||||||
desired->Yaw * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_YAW],vtolMin,1);
|
desired->Yaw * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_YAW],vtolMin,vtolMax);
|
||||||
cmd->Channel[settings->VTOLMotorS] = scaleChannel(vtolStatus.MotorS,
|
cmd->Channel[settings->VTOLMotorS] = scaleChannel(vtolStatus.MotorS,
|
||||||
settings->ChannelMax[settings->VTOLMotorS],
|
settings->ChannelMax[settings->VTOLMotorS],
|
||||||
settings->ChannelMin[settings->VTOLMotorS],
|
settings->ChannelMin[settings->VTOLMotorS],
|
||||||
@ -358,7 +361,7 @@ static int32_t mixerVTOL(const ActuatorSettingsData* settings, const ActuatorDes
|
|||||||
vtolStatus.MotorSW = bound(desired->Throttle * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_THROTTLE] +
|
vtolStatus.MotorSW = bound(desired->Throttle * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_THROTTLE] +
|
||||||
desired->Pitch * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_PITCH] +
|
desired->Pitch * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_PITCH] +
|
||||||
desired->Roll * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_ROLL] +
|
desired->Roll * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_ROLL] +
|
||||||
desired->Yaw * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_YAW],vtolMin,1);
|
desired->Yaw * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_YAW],vtolMin,vtolMax);
|
||||||
cmd->Channel[settings->VTOLMotorSW] = scaleChannel(vtolStatus.MotorSW,
|
cmd->Channel[settings->VTOLMotorSW] = scaleChannel(vtolStatus.MotorSW,
|
||||||
settings->ChannelMax[settings->VTOLMotorSW],
|
settings->ChannelMax[settings->VTOLMotorSW],
|
||||||
settings->ChannelMin[settings->VTOLMotorSW],
|
settings->ChannelMin[settings->VTOLMotorSW],
|
||||||
@ -368,7 +371,7 @@ static int32_t mixerVTOL(const ActuatorSettingsData* settings, const ActuatorDes
|
|||||||
vtolStatus.MotorW = bound(desired->Throttle * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_THROTTLE] +
|
vtolStatus.MotorW = bound(desired->Throttle * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_THROTTLE] +
|
||||||
desired->Pitch * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_PITCH] +
|
desired->Pitch * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_PITCH] +
|
||||||
desired->Roll * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_ROLL] +
|
desired->Roll * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_ROLL] +
|
||||||
desired->Yaw * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_YAW],vtolMin,1);
|
desired->Yaw * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_YAW],vtolMin,vtolMax);
|
||||||
cmd->Channel[settings->VTOLMotorW] = scaleChannel(vtolStatus.MotorW,
|
cmd->Channel[settings->VTOLMotorW] = scaleChannel(vtolStatus.MotorW,
|
||||||
settings->ChannelMax[settings->VTOLMotorW],
|
settings->ChannelMax[settings->VTOLMotorW],
|
||||||
settings->ChannelMin[settings->VTOLMotorW],
|
settings->ChannelMin[settings->VTOLMotorW],
|
||||||
@ -378,7 +381,7 @@ static int32_t mixerVTOL(const ActuatorSettingsData* settings, const ActuatorDes
|
|||||||
vtolStatus.MotorNW = bound(desired->Throttle * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_THROTTLE] +
|
vtolStatus.MotorNW = bound(desired->Throttle * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_THROTTLE] +
|
||||||
desired->Pitch * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_PITCH] +
|
desired->Pitch * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_PITCH] +
|
||||||
desired->Roll * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_ROLL] +
|
desired->Roll * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_ROLL] +
|
||||||
desired->Yaw * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_YAW],vtolMin,1);
|
desired->Yaw * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_YAW],vtolMin,vtolMax);
|
||||||
cmd->Channel[settings->VTOLMotorNW] = scaleChannel(vtolStatus.MotorNW,
|
cmd->Channel[settings->VTOLMotorNW] = scaleChannel(vtolStatus.MotorNW,
|
||||||
settings->ChannelMax[settings->VTOLMotorNW],
|
settings->ChannelMax[settings->VTOLMotorNW],
|
||||||
settings->ChannelMin[settings->VTOLMotorNW],
|
settings->ChannelMin[settings->VTOLMotorNW],
|
||||||
|
@ -250,6 +250,9 @@ static void manualControlTask(void* parameters)
|
|||||||
{
|
{
|
||||||
attitude.Yaw = (cmd.Yaw*180.0);
|
attitude.Yaw = (cmd.Yaw*180.0);
|
||||||
}
|
}
|
||||||
|
if(cmd.Throttle < 0)
|
||||||
|
attitude.Throttle = -1;
|
||||||
|
else
|
||||||
attitude.Throttle = cmd.Throttle*stabSettings.ThrottleMax;
|
attitude.Throttle = cmd.Throttle*stabSettings.ThrottleMax;
|
||||||
AttitudeDesiredSet(&attitude);
|
AttitudeDesiredSet(&attitude);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
function [q gyro accel time] = analyzeINSGPS(fn)
|
function [q gyro accel rpy time] = analyzeINSGPS(fn)
|
||||||
% Analyzes data collected from SerialLogger while DUMP_FRIENDLY
|
% Analyzes data collected from SerialLogger while DUMP_FRIENDLY
|
||||||
% enabled in AHRS
|
% enabled in AHRS
|
||||||
%
|
%
|
||||||
@ -50,15 +50,37 @@ accel = cat(1,data.accel);
|
|||||||
gyro = cat(1,data.gyro);
|
gyro = cat(1,data.gyro);
|
||||||
time = (1:size(q,1)) / 50;
|
time = (1:size(q,1)) / 50;
|
||||||
|
|
||||||
h(1) = subplot(311);
|
rpy = Quaternion2RPY(q);
|
||||||
|
|
||||||
|
h(1) = subplot(411);
|
||||||
plot(time,q)
|
plot(time,q)
|
||||||
ylabel('Quaternion');
|
ylabel('Quaternion');
|
||||||
h(2) = subplot(312);
|
h(2) = subplot(412);
|
||||||
|
plot(time,rpy);
|
||||||
|
ylabel('RPY'); legend('Roll','Pitch','Yaw');
|
||||||
|
h(3) = subplot(413);
|
||||||
plot(time,accel);
|
plot(time,accel);
|
||||||
ylabel('m/s')
|
ylabel('m/s')
|
||||||
h(3) = subplot(313);
|
h(4) = subplot(414);
|
||||||
plot(time,gyro);
|
plot(time,gyro);
|
||||||
ylabel('rad/sec');
|
ylabel('rad/sec');
|
||||||
xlabel('Time (s)')
|
xlabel('Time (s)')
|
||||||
|
|
||||||
linkaxes(h,'x');
|
linkaxes(h,'x');
|
||||||
|
|
||||||
|
function rpy = Quaternion2RPY(q)
|
||||||
|
|
||||||
|
RAD2DEG = 180/pi;
|
||||||
|
|
||||||
|
qs = q .* q;
|
||||||
|
|
||||||
|
R13 = 2*(q(:,1).*q(:,4) -q(:,1).*q(:,3)); %2*(q[1]*q[3]-q[0]*q[2]);
|
||||||
|
R11 = qs(:,1) + qs(:,2) - qs(:,3) - qs(:,4); %q0s+q1s-q2s-q3s;
|
||||||
|
R12 = 2*(q(:,2).*q(:,3) + q(:,1).*q(:,4)); %2*(q[1]*q[2]+q[0]*q[3]);
|
||||||
|
R23 = 2*(q(:,3).*q(:,4) + q(:,1) .* q(:,2)); %2*(q[2]*q[3]+q[0]*q[1]);
|
||||||
|
R33 = qs(:,1)-qs(:,2)-qs(:,3)+qs(:,4); %q0s-q1s-q2s+q3s;
|
||||||
|
|
||||||
|
rpy(:,2)=RAD2DEG*asin(-R13); % pitch always between -pi/2 to pi/2
|
||||||
|
rpy(:,3)=RAD2DEG*atan2(R12,R11);
|
||||||
|
rpy(:,1)=RAD2DEG*atan2(R23,R33);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user