-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NotifySetpointStop odd behavior #464
Comments
This seems more like a firmware issue, rather than a Crazyswarm problem? I personally haven't tried switching between modes recently. |
I just thought I'd note it in case anyone else is trying to use it or if someone else is using this successfully. I'm just landing with low-level control (using |
Thanks for doing these detailed experiments. I implemented the firmware for |
Before discussing, I will repost some code for convenience. I have added comments and removed some concurrency-related stuff for simplicity. First, here is the timeout logic in commander.c: if ((currentTime - setpoint->timestamp) > COMMANDER_WDT_TIMEOUT_SHUTDOWN) {
// enableHighLevel is controlled by the param system -
// it's always true if you use the default Crazyswarm launch file.
if (enableHighLevel) {
crtpCommanderHighLevelGetSetpoint(setpoint, state);
}
if (!enableHighLevel || crtpCommanderHighLevelIsStopped()) {
memcpy(setpoint, &nullSetpoint, sizeof(nullSetpoint));
}
} else if ((currentTime - setpoint->timestamp) > COMMANDER_WDT_TIMEOUT_STABILIZE) {
xQueueOverwrite(priorityQueue, &priorityDisable);
// Leveling ...
setpoint->mode.x = modeDisable;
setpoint->mode.y = modeDisable;
setpoint->mode.roll = modeAbs;
setpoint->mode.pitch = modeAbs;
setpoint->mode.yaw = modeVelocity;
setpoint->attitude.roll = 0;
setpoint->attitude.pitch = 0;
setpoint->attitudeRate.yaw = 0;
// Keep Z as it is
} and here is what happens when uint32_t currentTime = xTaskGetTickCount();
// Note: this MIN has no effect unless currentTime is very small, i.e. we just rebooted.
// In normal operation we can assume:
// timeSetback == COMMANDER_WDT_TIMEOUT_SHUTDOWN - M2T(remainValidMillisecs).
int timeSetback = MIN(
COMMANDER_WDT_TIMEOUT_SHUTDOWN - M2T(remainValidMillisecs),
currentTime
);
tempSetpoint.timestamp = currentTime - timeSetback; So essentially, we are dictating the time at which the first On the other hand, if the timeout period is longer than Remember, the only purpose of Now, moving on to your experiments. Keep in mind that my interpretations might be wrong, since this part of the firmware is complicated.
In summary: I think there is probably at least one firmware bug related to I think this part of the firmware is bug-prone because there are too many different subsystems interacting. I would like to replace several parts of the firmware with a unified state machine that deals with low-level setpoint timeout, high/low-level switching, and idle/active transition in the high-level commander (takeoff/land) in one place. Maybe free-fall, tumble, and not-flying detection could also be subsumed. I am also not sure why the param Edit: The notion of "priority" for setpoints is another factor that's complicated to reconcile with timeout, low/high switching, etc. |
From the Regarding the reported times, I tried repeating the experiments several times to make sure that they were right. So, I think the reported 0.5 sec in 6 and 7 are correct. I am almost certain it wasn't 2 sec (which is the value in |
For your application, why not |
High-level commands have additional time over-head that we didn't want (they are slower than the low-level commands). We could just send the drone its final location repeatedly, but we thought maybe we can also avoid that if |
The firmware changes in bitcraze/crazyflie-firmware#903 should have made Now the |
I was testing out
NotifySetpointStop()
but noticed some strange behavior.cmdPosition
followed byNotifySetpointStop(100)
, sleeping for 0.1sec, thenland
: lands after 0.1 seccmdPosition
followed byNotifySetpointStop(1000)
, sleeping for 1sec, thenland
: cf starts to drift, but then land kicks in and the cf lands normallycmdPosition
followed byNotifySetpointStop(5000)
, sleeping for 5sec, thenland
: once NotifySetpointStop is called, the propellers just stop immediately and the drone crash lands. 5 seconds later, the drone hovers motors start again and the drone hovers at landing height then lands properly. (The motors stopping was also noted in PR #202)cmdPosition
followed byNotifySetpointStop(5000)
thenland
: even though the cf should still be in low-level control mode for 5 seconds, the drone lands normally.cmdPosition
followed byNotifySetpointStop(100)
thenland
: the drone lands normally. (this is how it's used in other crazyswarm)cmdPosition
followed byland
: The drone drifts a bit for about 0.5 second then lands where it should have landed before driftingcmdPosition
followed by sleep for 5sec thenland
: The drone drifts a bit for about 0.5 second then the motors stop and it crash lands. Whenland
is called, the drone hovers again and lands in it's place.NotifySetpointStop
doesn't seem to be doing what it should, at least not always. When the "remainValidMillisecs" argument is large, it seems to cause the propellers to stop if a high-level command is not received immediately. Varying the duration "remainValidMillisecs" doesn't seem to be effective.Does the cf usually use 100ms as the default timeout before switching to high-level control (even if NotifySetpointStop is not called)?
The text was updated successfully, but these errors were encountered: