Skip to content

Instantly share code, notes, and snippets.

@jimweirich
Last active July 22, 2017 18:47
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimweirich/5680626 to your computer and use it in GitHub Desktop.
Save jimweirich/5680626 to your computer and use it in GitHub Desktop.
Controlling multiple drones with a single Ruby program.
# This script should be run on the drone.
# Change the IP address to be difference
# for each drone on the same ad-hoc network
#
killall udhcpd
ifconfig ath0 down
iwconfig ath0 mode ad-hoc essid ardrone2_070401 channel auto commit
ifconfig ath0 192.168.1.100 netmask 255.255.255.0 up
# NOTE: This is a version of Argus locally hacked
# to support multiple drones.
require 'argus'
drones = [
Argus::Drone.new(nil, '192.168.1.100'),
Argus::Drone.new(nil, '192.168.1.200'),
]
drones.each do |drone| drone.start end
drones.each do |drone| drone.take_off end
sleep 5
drones.each do |drone| drone.turn_right(1.0) end
sleep 3
drones.each do |drone| drone.turn_left(1.0) end
sleep 3
drones.each do |drone| drone.hover.land end
sleep 5
drones.each do |drone| drone.stop end

Instructions

To control multiple drones you need to get them on the same network. We used an ad-hoc network with statically assigned IP addresses. The adhoc.sh script will restart a drone's network on the ad-hoc network, but will not change the boot-up process, so that restarting a drone will put it back on the standard network.

Before starting, you should upload a copy of the adhoc.sh script to each drone. The script should be modified per drone to have a unique IP address.

Steps

For each drone

  • Select the drone's wifi network and telnet to 192.168.1.1
  • Run the adhoc.sh script on the drone

On you laptop:

  • Select the adhoc network named in the adhoc.sh script (we used jimsdrone_ah).
  • Select an unused static IP address (from network preferences on a Mac)
  • Run the dual_rotation.rb program (using the IP addresses assigned to the drone).

Video

http://youtu.be/BHxloUx332A

That's it. Have fun.

-- Jim Weirich / Carin Meier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment