-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
[WIP] flighttask static method to check if data is available #10317
Conversation
With the current Flighttask architecture it is possible to enter a state where the commander demands to switch to a task (for instance It would be beneficial to check for the required data of a specific task before instantiating that particular task. One possible solution could be to add a To see what I mean, I would do the following test (first with master, then with this branch):
Using the master, FlightTaskAuto will be instantiated, but due to an invalid triplet the activation fails. The previous state of FlightTask is lost as well. With this branch, the vehicle will remain in the old flighttask state. |
What about adding a 2nd slot (TaskUnion) for the next task, and not fully switch until it's active and happy? If there's a failure it should be reported (position controller status) so that commander can enter a proper failsafe state. I'm still thinking about different ways we could tie this all together coherently in a modular fashion. |
In the AUTO example you mentioned are you expecting the position setpoint triplet to continue to be invalid in any case? Here we can do a better job with a separate mission status coming from navigator. Navigator mission can still check this while inactive and with feedback the state machine can block the transition to mission in the first place. |
That would require to have a second instance. This is possible and definitely an option, but I would prefer to find a better solution instead of having two flighttasks instantiated. But then again, if there is no better solution, then this option is the way to go. However, have you looked at my suggestion?
Not in this case, otherwise it would never enter Simple example:
No. The triplet will be valid after a few loops.
In this particular case that could work. However it does not solve the general handling of consuming data from different threads. |
Yes I looked at your solution. It's okay if it solves the immediate problem, but I would try to minimize all of this custom generated code. Having a 2nd slot might also be interesting for cleanly transitioning between FlightTasks.
I'm aware, and what I was proposing was an attempted solution to both this and an actual failure case. Activating a FlightTask can depend on certain data with an overall timeout. |
Seems like a second TaskUnion is the best solution for now, and then keep switching between them. |
And why that? I don't see why that is the case, since we haven't searched for alternatives yet. Let's step back for a second. I will try to write down the pros and cons of the two approaches that we have right now, but I actually was hoping to gather first a couple more solutions before evaluating the pros and cons. Second unionAdvantage
Disadvantage
Static methodAdvantage
Disadvantage
|
What about having the FlightTask (eg FlightTaskAuto) activate immediately, but do something safe and continuous in the interim until all the necessary data is available (updated valid position setpoint triplet)? The local position validity checks you're doing are redundant and could be dropped. Again, if the data doesn't become available in some generous period the MPC should publish a failure status (not a mode change) to commander, which would then activate the failsafe. Then we need to take a look at all of these cases overall and lock it down (state machine) so that potentially invalid transitions are prevented in the first place (eliminating the need to fallback to the previous FlightTask as much as possible).
This is actually kind of problematic. If you change a mode like that it could be difficult or even impossible to discern from a mode change that came in from mavlink or rc. Regardless of the outcome of this discussion let's create an issue to change this. |
That would mean that every FlightTask that has race conditions needs its own "in the meantime failsafe", right? I guess that's undesired. And if we would put a general "in the meantime failsafe" into FlightTask, we just move it from the position controller, no? Edit |
It's a different side to the same problem. You either try to handle the dependencies upfront and not use the task until everything is ready, or handle it within the task itself. Not ideal either way. In some cases I could see handling it explicitly in the new task being better than continuing with whatever setpoints you already had. Currently a TaskUnion is 760 bytes of memory. Having a second instance isn't great, but we can handle that even on fmu-v2. The problem we kept hitting on px4fmu-v2 (and will hit again soon) is limited flash (code space). Generating code can end up using more flash than you might expect. |
I also don't think that this is a good idea, because then every Flighttask needs to have such a logic. I still think it is better to have an implementation that allows for checking first (let's assume it is done with a second union), and then if it fails, we need to define what should happen. In the legacy code, if the triplets were not valid but auto was requested, then all the velocity setpoints were just set to 0. However, that was actually never really defined officially nor discussed what the desired behavior should be, but rather was added because it was not handled at all. Now we have the chance to define it once and for all. There are several options:
In all three options feedback can be sent back to the commander. The commander then needs to decide if he wants to continue to request a specific mode or not. This decision, however, is not something very simple to make. While the commander receives the feedback, the mc_pos_control would execute one of the options above (or something else). I also want to emphasize that the last option does not overwrite the commander nor does it replace the commander state-machine. It just handles that case similar to the legacy code where the setpoints were set to 0. |
I agree, I was just trying to brainstorm possible alternatives that wouldn't require an additional slot. Having the current active FlightTask fully available while constructing the next could be useful. For example you could initialize the relevant setpoints based on what the previous was actually doing. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Closing as stale. |
No description provided.