-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add simple FSM support to ORBIT_EXECUTION_STATUS message in common.xml #1622
Add simple FSM support to ORBIT_EXECUTION_STATUS message in common.xml #1622
Conversation
message_definitions/v1.0/common.xml
Outdated
<entry value="1" name="ORBIT_EXECUTION_STATE_STARTED"> | ||
<description>Vehicle started following orbit track.</description> | ||
</entry> | ||
<entry value="2" name="ORBIT_EXECUTION_STATE_FINISHED"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the ORBIT_EXECUTION_STATUS is only sent out while the orbit is in progress. So this will be sent out at most one time (and of course the recipient might miss it). Is the inference that ORBIT_EXECUTION_STATUS will always be sent out at the point it leaves the orbit? IF so the protocol would need to state this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the ORBIT_EXECUTION_STATUS is only sent out while the orbit is in progress
Yes.
So this will be sent out at most one time (and of course the recipient might miss it). Is the inference that ORBIT_EXECUTION_STATUS will always be sent out at the point it leaves the orbit?
A proper implementation should send telemetry of orbit status as long as the vehicle is conducting orbit action. Therefore it will not be sent out at most one time. The vehicle should start hovering on wherever it is once the orbiting action finishes, i.e. in ORBIT_EXECUTION_STATE_FINISHED
, but orbit flight task would be still active. Between FINISHED and flight task update time window, telemetry is still kept published with the state info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tahsinkose The problem is that there is no such thing/concept as the orbit "finishing" - at least not related to these messages or PX4 (and I am pretty sure ArduPilot too). The only concept I know in mavlink of an orbit finishing is the loiter command for a fixed wing vehicle, which will finish after either time or a certain number of turns.
What we have is two WIP messages:
- MAV_CMD_DO_ORBIT - This starts the orbit. There is no mechanism to stop the orbit. This does not mention ORBIT_EXECUTION_STATUS
- ORBIT_EXECUTION_STATUS - says it is emitted while orbit is happening.
I would expect ORBIT_EXECUTION_STATUS
to stop being emitted when you stop orbiting. When that happens would depend on how the orbit is implemented in a particular flight stack - so if the flight stack supports the idea of loitering after one turn (say) then yes, perhaps what you are describing might happen. But that's not how PX4 orbit mode works (for example) and we need to try think of messages that are agnostic of a particular stack.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hamishwillee PX4 orbit mode is a time-uncapped flight mode that would execute as long as autopilot is not requested to transition into another flight mode. It doesn't prevent a stateful finite orbit flight mode to be added such as FlightTaskFiniteOrbit
. Actually this is the name of flight task I'm currently using in my project and this extension on message makes both flight tasks (FlightTaskOrbit
and FlightTaskFiniteOrbit
) gracefully work without any interference.
I can't see how these messages are not stack-agnostic. The particular flight modes that use this message who don't care (or unable to reflect) about the state of orbit can simply neglect those fields.
This is addition of a state enum to ORBIT_EXECUTION_STATUS to indicate whether you're approaching or "in" the orbit, from the perspective of the flight stack. The use case is to make it easier for a ROS system (linked PR) to work out the point at which the orbit started, in order to choose an exit angle. Any opinions? I'm not opposed in that a GCS can now also know the autopilot thinks it is circling, rather than just guessing based on it overlaying the planned path. |
4290420
to
4591c4c
Compare
@hamishwillee any updates on this? |
@tahsinkose Sorry for delay - I typically address the queue on Weds/Thurs every week but am sporadic between. I added a comment and will discuss in the dev call (feel free to attend - it is in about 5 hours from now - see dronecode calendar). We should probably remove the WIP on these messages and add info about ORBIT_EXECUTION_STATUS to the orbit command. I THINK this has to be an extension field too - depends on whether there is a plan in place to allow breaking the message? |
@hamishwillee thanks for the due diligence. Unfortunately I can't commit to removing WIP on the messages yet (not before Sept 2021). Nevertheless this can wait until then - or someone else finishes WIP statuses on them and this would become ready for free. |
Hi @tahsinkose , You could already achieve what (we think) you want using the existing messages. Simply set a target on the point on the radius that you want to enter, fly there, start orbit, then track the position on the radius. Then send new command when you reach the point on the radius you want to exit. This way you know the starting point and end point because you set rather than get them. We had a look at the command and message in the dev call. The general feeling was that perhaps
I don't want to go into much detail on command design without a better view on your use case, but our thinking was:
Anything else? To progress this can you outline a little more about your setup. It would help to have a discussion at the dev call. I know that might be hard for you - is there a good time that overlaps with Zurich work hours? If so, then I can arrange a discussion with someone in the team. |
Hey @hamishwillee.
This is still limited for orbits that require more than 1 tour, e.g. orbit of 720 degree. Besides it relies on a perfect localization which is not the case for my application, i.e. a minor localization jump could cause a possible if-check to miss that the robot was on the orbit. I actually faced this issue with PX4 and solved it by projecting the current position of the robot to orbit circle in flight task. I'm not sure this can be achieved with the same precision by using the telemetry published over ROS. Even if it could be done, I like the idea of deferring the internals to flight task and monitoring orbit FSM until it says "Finished".
I can't see why it would be bad to expose this state. Telemetry itself is already exposed.
I'm all ears for the suggestions on additional states one might be interested in orbit behavior 🙂 Although I don't agree that they aren't a good generalization. They are few in numbers, but still comprehensive in the sense that all discrete states are exposed. For instance, I'm using 3 additional states on my local PX4 clone that are not exposed to this telemetry message, since they are fairly application-specific.
I solved my use-case already with an adequate design. Let's don't waste time on solving it in better ways, because it is irrelevant in the sense that MAVLink format specification should be autopilot-agnostic. Therefore we should deliberately constrain ourselves to the particular question: Is it meaningful to have stateful orbit behavior?
It is command driven.
Exactly as in OK most of your bullet points consider also the fixed wing frames, which makes it naturally more convoluted than the simple extension this PR is aiming to bring in for rotary wings. There is one thing though:
Yes this. However [
This is invalid when you specify the exact orbit distance in radians. This is extremely advanced when compared to what I'm aspiring to bring in and therefore should be avoided until an actual use-case arrives.
I believe it would be useful to emit in both cases. Otherwise how would the mission executor know that the orbit has finished in former case?
These seem like fixed-wing considerations to me. If that is the case, let's constrain this only for rotary wings where loiter on position is achievable.
This is autopilot, even user-code impl. details and has nothing to do with MAVLink message contents right? Again, please don't try to come up with a good overall design for my problem that has to inevitably involve autopilot/user code, which is much more than the content of For a last but not least argument for discouraging the consideration of impl. details, please do consider a spiral orbit behavior wherein the altitude gradually increases in the consecutive stages of orbit arc. This extension still supports it in current status 🙂
It is really tentative, but I can attend a meeting of 1-2 hrs in May 2 between CEST 12.00-5 PM 🤔 |
Sorry, I missed your response! @julianoes Can you liase with @tahsinkose to discuss the needs/requirements here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
In the minimum, we should clearly define finished as one turn. Optionally we support commanding multiple turns and reporting a progress. I think that would make it much more flexible.
What do you think? If we see the use case I think we should extend right away.
@MaEtUgR So it depends a bit on what happens after finishing. Right now I think this is a command and the orbit basically goes on forever. So finished would mean "I got another command that made me leave this mode". There isn't value unless you can be in the mode and not exiting. In that case I see it as useful, but again, it would mean "we stopped orbiting". I wouldn't base that on complete turns since we might want to exit on partial turns - and we'd still be finished. Hope that makes sense. I plan on looking at the responses on this tomorrow. But I really think you guys should all have a meeting to nut out the different use cases we'd like an orbit to address. |
@MaEtUgR @hamishwillee Here is a video in Gazebo where I command the robot to orbit for
I can't see any particular reason for such a constraint. I currently hardcode |
* Allow specification of turn in radians for finite orbits.
message_definitions/v1.0/common.xml
Outdated
@@ -6572,6 +6587,8 @@ | |||
<field type="int32_t" name="x">X coordinate of center point. Coordinate system depends on frame field: local = x position in meters * 1e4, global = latitude in degrees * 1e7.</field> | |||
<field type="int32_t" name="y">Y coordinate of center point. Coordinate system depends on frame field: local = x position in meters * 1e4, global = latitude in degrees * 1e7.</field> | |||
<field type="float" name="z" units="m">Altitude of center point. Coordinate system depends on frame field.</field> | |||
<field type="uint8_t" name="state" enum="ORBIT_EXECUTION_STATE">State of execution during the orbit action.</field> | |||
<field type="uint8_t" units="%" name="progress">Progress of orbit. UINT_MAX8 if orbit is indefinite.</field> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TYI I turned this into a uint8 - much smaller and granularity of 1 is fine for %
Thanks @tahsinkose . Looking good. There are probably a couple of other minor things I should do to it (E.g. allow default value for radius, velocity etc if called when in already in orbit). Will discuss with dev call tonight and hopefully merge tomorrow. |
@tahsinkose We had a discussion in the dev call on this. There was concern that the progress update is something we need to have more generically - ie all commands should report their progress in some way. As a result I have pulled that out of this request (and will submit attempt at generic message shortly in a separate PR). We are broadly agreed on the turns addition though. I will do some other minor fixes on this and merge (as it is still WIP). This is what I removed.
|
Orbit execution status is already a published telemetry info. How the new generic method will apply to that then without the explicit |
@tahsinkose That is a very good question - or at least as I am interpreting it "Should the new mesage also send positional information, if present". If not, what do you mean? The new message will has state information in it. |
Your interpretation seems correct AFAIU. I like discussing over real examples though. Consider https://mavlink.io/en/messages/common.html#ORBIT_EXECUTION_STATUS. My proposal was to add |
@tahsinkose The COMMAND_PROGRESS is still in discussion (as you know) and I hope we can answer those questions in that PR. I felt it useful to merge this because it was the part of the command we were generally in agreement on. It is possible that the Just FMI, if you know you can command a particular arc what do you actually need in the way of additional information for your use case? i.e. you no longer need the entry and exit status to calculate your arc. Perhaps you need to know when the arc is finished to send the next command? |
This is a simple feature extension on orbit mode that allows the implementation of a very simple finite state machine structure in autopilot software. Normally orbit executes indefinitely, however the use-case I'm currently working on requires a finite orbit behavior for a certain amount of angles.
Following is a diagram of the added states when the orbit is requested to happen only for 360 degrees.
![OrbitFSM](https://user-images.githubusercontent.com/10549928/115622596-bb24a300-a300-11eb-829d-928a2259fa73.png)
Based on use-cases, this state machine can be populated with more fine-grained states. Nevertheless this alone enables many capabilities.