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

UDP port collision fix #180

Merged
merged 2 commits into from
Apr 7, 2023

Conversation

trevorm4x
Copy link
Contributor

This PR adds functionality for changing the video feed UDP port from the default (11111) to one set by the user, allowing multiple drones to connect to the same computer and stream video simultaneously. Without this change multiple drones will send data to the same port, causing port collision and rendering all video streams useless.

This "bug" only comes up if the user connects multiple drones to the same WiFi network and connects to them individually using multiple Tello() objects instead of one Swarm() object. This was motivated by a capstone project at Northeastern University that requires fine-positioning multiple drones simultaneously.

To this aim, the function change_vs_udp allows the user to set an arbitrary video stream udp port. There is also, for convenience, an optional parameter to the Tello() class constructor to set the udp port there, although I can understand if that was not necessary for others. The attribute self.vs_udp_port is added and used in place of the class attribute VS_UDP_PORT.

This functionality could be extended to also change the command port from the default but this was not an issue we came across in our project to our knowledge.

Using these changes we were able to stream video from three drones simultaneously without port collision, using the latest 2.4.0 release.

However, I didn't realize until beginning the PR process that there are many unreleased changes on master, and haven't been able to test them yet, so this has only been demonstrated to work with the cv2-based code and not the more recent PyAV versions. I don't believe there should be any problems but won't be able to upgrade and test for some time due to end-of-semester time constraints. If any maintainers want me to follow up with further tests or changes please let me know and I will complete them as soon as possible.

Thank you!

@M4GNV5
Copy link
Collaborator

M4GNV5 commented Apr 7, 2023

Hey,

thanks for the comprehensive description and the pull request.
I think we can merge this as is, just one questions:

This "bug" only comes up if the user connects multiple drones to the same WiFi network and connects to them individually using multiple Tello() objects instead of one Swarm() object.

I do not see how the Swarm class helps with this problem? Doesn't it just simply create a list of Tello instances? How is that different to creating them manually?
I do however think it would be a good idea to implement this as a feature in the swam class (i.e. picking separate ports for each instance).

@M4GNV5 M4GNV5 merged commit 5ee9dd7 into damiafuentes:master Apr 7, 2023
@trevorm4x
Copy link
Contributor Author

Hi, thanks for accepting the PR.

The comment about Swarm class was just saying that this may be a non-idiomatic way to use the library, but on closer look I can see that this problem would come up using Swarm too, if a user ran Swarm([..]).get_frame_read(). I agree that it makes sense to extend the Swarm class by adding something to the Swarm.init to pick a unique UDP port. It may even be worth it to use different control ports even if collision is less likely.

That said, it's worth mentioning that most computers accepting video feeds from multiple drones will experience network bottlenecks.

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

Successfully merging this pull request may close these issues.

None yet

2 participants