Skip to content

Conversation

@mikeclement
Copy link

This follows up on: #56 (comment)

Note: this patch does NOT affect the default behavior of ardrone_driver; optional command-line arguments must be supplied to introduce the described behavior.

I've incorporated a solution for running multiple instances of ardrone_driver on a single computer. It is based on manually specifying custom ports for each instance of the ardrone_driver node and using iptables (root privileges required) to remap UDP packets en route to the standard ports on each quad. The options follow from the port names, e.g., -navdata-port, -video-port, and -at-port. As far as I can tell, these are the only three that need to be customized, but the other port numbers are also made into options for completeness.

To test: first, join the quads into a common network. Supposing two quads, q1 at 192.168.0.101 and q2 at 192.168.0.102, we choose to remap ports as follows:

q1: 5554 (quad) <-> 1554 (ardrone_driver), 5555 <-> 1555, 5556 <-> 1556
q2: 5554 (quad) <-> 2554 (ardrone_driver), 5555 <-> 2555, 5556 <-> 2556

The corresponding iptables commands would be:

q1:

sudo iptables -t nat -A OUTPUT -p udp -d 192.168.0.101 --dport 1554 -j DNAT --to :5554
sudo iptables -t nat -A PREROUTING -p udp -s 192.168.0.101 --dport 5554 -j DNAT --to :1554
sudo iptables -t nat -A OUTPUT -p udp -d 192.168.0.101 --dport 1555 -j DNAT --to :5555
sudo iptables -t nat -A PREROUTING -p udp -s 192.168.0.101 --dport 5555 -j DNAT --to :1555
sudo iptables -t nat -A OUTPUT -p udp -d 192.168.0.101 --dport 1556 -j DNAT --to :5556
sudo iptables -t nat -A PREROUTING -p udp -s 192.168.0.101 --dport 5556 -j DNAT --to :1556

q2:

sudo iptables -t nat -A OUTPUT -p udp -d 192.168.0.102 --dport 2554 -j DNAT --to :5554
sudo iptables -t nat -A PREROUTING -p udp -s 192.168.0.102 --dport 5554 -j DNAT --to :2554
sudo iptables -t nat -A OUTPUT -p udp -d 192.168.0.102 --dport 2555 -j DNAT --to :5555
sudo iptables -t nat -A PREROUTING -p udp -s 192.168.0.102 --dport 5555 -j DNAT --to :2555
sudo iptables -t nat -A OUTPUT -p udp -d 192.168.0.102 --dport 2556 -j DNAT --to :5556
sudo iptables -t nat -A PREROUTING -p udp -s 192.168.0.102 --dport 5556 -j DNAT --to :2556

Now, when running instances of ardrone_driver, add the following args strings:

q1:

-ip 192.168.0.101 -navdata-port 1554 -video-port 1555 -at-port 1556

q2:

-ip 192.168.0.102 -navdata-port 2554 -video-port 2555 -at-port 2556

More information as well as tools for automating wireless reconfiguration and port remapping are available here:
http://hacked10bits.blogspot.com/2014/02/multiple-ardrones-from-single-computer.html

@mikeclement
Copy link
Author

Superceded by #98

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.

1 participant