Skip to content

Commit cb5e9e4

Browse files
Shashank Dateblacktm
Shashank Date
authored andcommitted
Added alias for backward and modified client/server to exit gracefully in test mode
1 parent 485deca commit cb5e9e4

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

.ruby-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0.0

README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,22 @@ Nice! For now, let's land the drone and learn about what else it can do.
4747
```
4848
## Your first Tello EDU flight
4949

50-
This is a bit more involved process, since you have to set up the Tello EDU drones (assuming you have two of them) to connect to your `local WiFi` as described in this [Video](https://www.youtube.com/watch?v=cIsddY4SKgA&t=162s)
50+
The Tello EDU drones operate in two mutually exclusive modes: the AP mode and the Station Mode. The AP mode is the default Out-Of-The-Box mode which lets you control the Tello EDU as regular Tello drone: one controller per drone. Once you test that the drone is working as expected, you need to manually switch it the "Station" mode which allows a single controller to control a swarm of multiple Tello EDU drones, all of which are in the station mode.
5151

52-
The gem comes with a command-line utility, named `telloedu`. We can use it to launch an interactive console and send commands to the drones (one at a time for now). Go ahead and start the console:
52+
To set the Tello EDU in Station mode, you should use the command-line utility that comes with this gem, named `telloedu`. You can use it to launch an interactive console and send commands to the Tello EDU drones (one at a time for now). Go ahead and start the console (be sure to connect to the drone's WIFI before you start sending commands):
5353

5454
```
5555
$ telloedu console
56+
Ready to receive TelloEDU commands. Type "exit" to quit.
57+
[1] pry(main)> connect
58+
59+
[2] pry(main)> ap 'Your-Wifi-SSID', 'Your-WIFI-password' ## this should reboot the drone in about 3 seconds
60+
61+
[3] pry(main)> quit
5662
```
5763

58-
Now, set the drones on the ground clear of any objects (including yourself) and press the button to turn them on. Wait for them to boot up, until the status light is blinking yellow.
64+
65+
Now, set the drones on the ground, clear of any objects (including yourself) and press the button to turn them on. Wait for them to boot up, until the status light is blinking yellow.
5966

6067
In your interactive console, connect to the drone like so (the `>` here is just to note it's a Ruby prompt — don't type that):
6168

lib/tello/cli/server.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
puts "Starting Tello test server...".bold, "Listening on udp://localhost:#{PORT}"
1111

12-
loop do
12+
bye = false
13+
while (not bye) do
1314
msg, addr = server.recvfrom(100)
1415
puts "#{"==>".green} Received: \"#{msg}\", from #{addr[3]}:#{addr[1]}"
1516

@@ -44,8 +45,9 @@
4445
when 'wifi?'
4546
#=> snr
4647
res = "90\r\n"
47-
when 'whatever'
48-
res = "unknown command: whatever"
48+
when 'bye!'
49+
res = 'good bye!'
50+
bye = true
4951
else
5052
#=> 'ok' or 'error'
5153
res = 'ok'

lib/tello/dsl.rb

+10
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def in_move_range?(v)
7272
end
7373
end
7474
alias_method :front, :forward
75+
alias_method :backward, :back
7576

7677
# Turn clockwise or counterclockwise
7778
[:cw, :ccw].each do |cmd|
@@ -217,6 +218,15 @@ def sn
217218
send('sn?')
218219
end
219220

221+
def bye!
222+
## Tell the server to exit gracefully.
223+
## Only applicable in test mode.
224+
if Tello.testing
225+
send('bye!')
226+
exit(0) if connected?
227+
end
228+
end
229+
220230
# Get Wi-Fi signal-to-noise ratio (SNR); if parameters, set SSID and password
221231
def wifi(ssid: nil, pass: nil)
222232
if ssid && pass

0 commit comments

Comments
 (0)