mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
[OP-724] Provide Actuator option to disable selected channels and use it for 7s camera boot delay
Actuator did not provide an option to completely shutdown selected channels (set PWM pulse = 0). It is useful for camera stabilization boot delay (we want few seconds of gimbal servo inactivity to calibrate gyros). It also might be useful for failsafe on some channels. This option is now available. It is used to disable camera outputs during fixed 7s delay after boot instead of setting them to minimum position. As a side effect, few bugs are fixed (ticks should be multiplied by portTICK_RATE_MS, not divided, to get time in ms). And few floating point operations were optimized out as well. ActuatorCommand.UpdateTime was promoted to uint16 because it is not unusual to have it 20000ms during flash updates (was seen on the CC after UAV settings import). So it should be 16bit as well.
This commit is contained in:
parent
8f5fb5aeb0
commit
5784ea8b36
@ -57,6 +57,8 @@
|
||||
#define FAILSAFE_TIMEOUT_MS 100
|
||||
#define MAX_MIX_ACTUATORS ACTUATORCOMMAND_CHANNEL_NUMELEM
|
||||
|
||||
#define CAMERA_BOOT_DELAY_MS 7000
|
||||
|
||||
// Private types
|
||||
|
||||
|
||||
@ -205,7 +207,7 @@ static void actuatorTask(void* parameters)
|
||||
// Check how long since last update
|
||||
thisSysTime = xTaskGetTickCount();
|
||||
if(thisSysTime > lastSysTime) // reuse dt in case of wraparound
|
||||
dT = (thisSysTime - lastSysTime) / portTICK_RATE_MS / 1000.0f;
|
||||
dT = (thisSysTime - lastSysTime) * (portTICK_RATE_MS * 0.001f);
|
||||
lastSysTime = thisSysTime;
|
||||
|
||||
FlightStatusGet(&flightStatus);
|
||||
@ -277,10 +279,15 @@ static void actuatorTask(void* parameters)
|
||||
|
||||
for(int ct=0; ct < MAX_MIX_ACTUATORS; ct++)
|
||||
{
|
||||
// During boot all camera actuators should be completely disabled (PWM pulse = 0).
|
||||
// command.Channel[i] is reused below as a channel PWM activity flag:
|
||||
// 0 - PWM disabled, >0 - PWM set to real mixer value using scaleChannel() later.
|
||||
// Setting it to 1 by default means "Rescale this channel and enable PWM on its output".
|
||||
command.Channel[ct] = 1;
|
||||
|
||||
if(mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_DISABLED) {
|
||||
// Set to minimum if disabled. This is not the same as saying PWM pulse = 0 us
|
||||
status[ct] = -1;
|
||||
command.Channel[ct] = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -289,8 +296,6 @@ static void actuatorTask(void* parameters)
|
||||
else
|
||||
status[ct] = -1;
|
||||
|
||||
|
||||
|
||||
// Motors have additional protection for when to be on
|
||||
if(mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_MOTOR) {
|
||||
|
||||
@ -322,6 +327,7 @@ static void actuatorTask(void* parameters)
|
||||
else
|
||||
status[ct] = -1;
|
||||
}
|
||||
|
||||
if( (mixers[ct].type >= MIXERSETTINGS_MIXER1TYPE_CAMERAROLL) &&
|
||||
(mixers[ct].type <= MIXERSETTINGS_MIXER1TYPE_CAMERAYAW))
|
||||
{
|
||||
@ -343,19 +349,26 @@ static void actuatorTask(void* parameters)
|
||||
}
|
||||
else
|
||||
status[ct] = -1;
|
||||
|
||||
// Disable camera actuators for CAMERA_BOOT_DELAY_MS after boot
|
||||
if (thisSysTime < (CAMERA_BOOT_DELAY_MS / portTICK_RATE_MS))
|
||||
command.Channel[ct] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < MAX_MIX_ACTUATORS; i++)
|
||||
command.Channel[i] = scaleChannel(status[i],
|
||||
|
||||
// Set real actuator output values scaling them from mixers. All channels
|
||||
// will be set except explicitly disabled (which will have PWM pulse = 0).
|
||||
for (int i = 0; i < MAX_MIX_ACTUATORS; i++)
|
||||
if (command.Channel[i])
|
||||
command.Channel[i] = scaleChannel(status[i],
|
||||
actuatorSettings.ChannelMax[i],
|
||||
actuatorSettings.ChannelMin[i],
|
||||
actuatorSettings.ChannelNeutral[i]);
|
||||
|
||||
|
||||
// Store update time
|
||||
command.UpdateTime = 1000.0f*dT;
|
||||
if(1000.0f*dT > command.MaxUpdateTime)
|
||||
command.MaxUpdateTime = 1000.0f*dT;
|
||||
command.UpdateTime = dT * 1000.0f;
|
||||
if (command.UpdateTime > command.MaxUpdateTime)
|
||||
command.MaxUpdateTime = command.UpdateTime;
|
||||
|
||||
// Update output object
|
||||
ActuatorCommandSet(&command);
|
||||
|
@ -57,7 +57,6 @@
|
||||
// Configuration
|
||||
//
|
||||
#define SAMPLE_PERIOD_MS 10
|
||||
#define BOOT_DELAY 7000
|
||||
|
||||
// Private types
|
||||
|
||||
@ -213,23 +212,20 @@ static void attitudeUpdated(UAVObjEvent* ev)
|
||||
applyFeedForward(i, dT, &attitude, &cameraStab);
|
||||
#endif
|
||||
|
||||
// set output channels (but wait BOOT_DELAY after board reset)
|
||||
// set output channels
|
||||
float output = bound((attitude + csd->inputs[i]) / cameraStab.OutputRange[i], 1.0f);
|
||||
if (thisSysTime > (portTICK_RATE_MS * BOOT_DELAY )) {
|
||||
|
||||
switch (i) {
|
||||
case CAMERASTABSETTINGS_INPUT_ROLL:
|
||||
CameraDesiredRollSet(&output);
|
||||
break;
|
||||
case CAMERASTABSETTINGS_INPUT_PITCH:
|
||||
CameraDesiredPitchSet(&output);
|
||||
break;
|
||||
case CAMERASTABSETTINGS_INPUT_YAW:
|
||||
CameraDesiredYawSet(&output);
|
||||
break;
|
||||
default:
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
switch (i) {
|
||||
case CAMERASTABSETTINGS_INPUT_ROLL:
|
||||
CameraDesiredRollSet(&output);
|
||||
break;
|
||||
case CAMERASTABSETTINGS_INPUT_PITCH:
|
||||
CameraDesiredPitchSet(&output);
|
||||
break;
|
||||
case CAMERASTABSETTINGS_INPUT_YAW:
|
||||
CameraDesiredYawSet(&output);
|
||||
break;
|
||||
default:
|
||||
PIOS_Assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
<object name="ActuatorCommand" singleinstance="true" settings="false">
|
||||
<description>Contains the pulse duration sent to each of the channels. Set by @ref ActuatorModule</description>
|
||||
<field name="Channel" units="us" type="int16" elements="10"/>
|
||||
<field name="UpdateTime" units="ms" type="uint8" elements="1"/>
|
||||
<field name="UpdateTime" units="ms" type="uint16" elements="1"/>
|
||||
<field name="MaxUpdateTime" units="ms" type="uint16" elements="1"/>
|
||||
<field name="NumFailedUpdates" units="" type="uint8" elements="1"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
|
Loading…
Reference in New Issue
Block a user