Skip to content
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

Support filtering incoming messages based on target_id #585

Closed
wants to merge 30 commits into from

Conversation

peterbarker
Copy link
Contributor

No description provided.

@hamishwillee
Copy link
Contributor

  1. Tests need to pass :-)

  2. I'm not sure filtering on None quite makes sense here - when would it ever be useful for a vehicle not to filter anything?

  3. If target system is 0 we do no filtering at all. Is that intentional?

  4. I'm a bit concerned this doesn't do quite what we think (though it may "do the right job")

    if self._target_system:
      src = msg.get_srcSystem()
      if src != self._target_system and src != 0:
         return
    

    Specifically what we're getting back is msg.get_srcSystem(), which is appears to be always the source id of the message. We're not filtering on "messages that were sent to us or broadcast" but on "messages that have the id we think is our target vehicle".

The assumption in this code is that 0 is the sourceSystem for a broadcast message, and I don't think it is. I think that we probably don't see messages unless they are either intended for us or for broadcast. We need to confirm this.

Also if 0 was a broadcast message then this still wouldn't help us because that would mean we would be getting any broadcast heartbeats (and these might be setting our mode).

Anyway, if I'm right, then we don't need the filter on src != 0. However we do need to consider whether we will process broadcast messages at all. Is there a case where we ever want to read messages from anything that isn't the vehicle?

Last of all, we need to think about working out what our target id should be. A default of 1 should work in most cases but we probably should think about code to detect the value if at all possible. Minimally something to help people if connect fails to understand this is a likely cause.

@mikerob
Copy link

mikerob commented Feb 24, 2016

Remember there are two use cases for DroneKit - at the vehicle end AND as a GCS.

The GCS case is where you would want to process ALL vehicle IDs.

On 24 Feb 2016, at 4:21 pm, Hamish Willee notifications@github.com wrote:

Tests need to pass :-)
I'm not sure filtering on None quite makes sense here - when would it ever be useful for a vehicle not to filter anything?
If target system is 0 we do no filtering at all. Is that intentional?
I'm a bit concerned this doesn't do quite what we think (though it may "do the right job") if self._target_system: src = msg.get_srcSystem() if src != self._target_system and src != 0: return Specifically what we're getting back is msg.get_srcSystem(), which is appears to be always the source id of the message. We're not filtering on "messages that were sent to us or broadcast" but on "messages that have the id we think is our target vehicle".
The assumption in this code is that 0 is the sourceSystem for a broadcast message, and I don't think it is. I think that we probably don't see messages unless they are either intended for us or for broadcast. We need to confirm this.

Anyway, if I'm right, then we don't need the filter on src != 0. However we do need to consider whether we will process broadcast messages at all. Is there a case where we ever want to read messages from anything that isn't the vehicle?


Reply to this email directly or view it on GitHub.

@hamishwillee
Copy link
Contributor

@mikerob Well you'd want to process all ids, but I think that given the 1:1 nature of the connection between a vehicle and an autopilot you would do that through separate vehicle objects - upshot that changing to only intercept the one specified id makes a lot of sense.

What we would need to change to properly support this model though is a better way to discover all the vehicles on the network and return the Vehicle object that makes sense for each. I'd see that as "step2". Perhaps in the mean time have vehicle get only messages from the supported vehicle, and any vehicle if 0 is set as the target.

if self._target_system:
src = msg.get_srcSystem()
if src != self._target_system and src != 0:
return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we deal with this at the forward_message level?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrpollo
Copy link
Member

mrpollo commented Apr 12, 2016

this patch mostly makes sense to me, but it uncovers some new scenarios we might have not been ready to address here.

What is DroneKit doing now:

  • Vehicle state
  • Modifying state
  • Reacting to mavlink and vehicle attribute state changes

What is our core backend good for right now (mavlink):

  • vehicle messages
  • GCS messages

In theory we should always assume we are not the only link in the network connected to a Flight Controller, this PR makes sense to me because it allows us to filter through vehicle messages, but it doesn't do much with all the GCS (or broadcast) messages, I think we might need to add a new state machine for all the broadcasted messages, this might have a big cost since most users won't really care so we need to be careful how we add this new state machine.

@peterbarker just make sure our tests pass and I'll proceed with merging, if you need help I'll gladly commit some time to get this merged this is big.

@mrpollo
Copy link
Member

mrpollo commented Aug 29, 2016

@peterbarker are you still working on this?

@peterbarker
Copy link
Contributor Author

peterbarker commented Aug 29, 2016 via email

@amilcarlucas
Copy link
Contributor

This looks good Peter. I would like to try it. Can you please rebase ?

@peterbarker
Copy link
Contributor Author

@amilcarlucas Rebased.

@mrpollo
Copy link
Member

mrpollo commented Oct 17, 2017

Good to see you reviving old branches @peterbarker 👍

@peterbarker
Copy link
Contributor Author

peterbarker commented Oct 17, 2017 via email

@guglie
Copy link

guglie commented Oct 17, 2017

Thank you @peterbarker !

@amilcarlucas
Copy link
Contributor

Thank you Peter. Any clues why the tests fail ?

@peterbarker
Copy link
Contributor Author

I'm closing this:

  • it doesn't rebase cleanly
  • pymavlink has support for multiple vehicles in a different way now, so the required patches for pymavlink won't be going in

Somebody'll have to work out how we do dronekit-python with multiple targets in pymavlink using the new pymavlink options :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants