Skip to content

Commit

Permalink
Added alias for backward and modified client/server to exit gracefull…
Browse files Browse the repository at this point in the history
…y in test mode
  • Loading branch information
Shashank Date authored and blacktm committed Dec 2, 2021
1 parent 485deca commit cb5e9e4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0.0
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,22 @@ Nice! For now, let's land the drone and learn about what else it can do.
```
## Your first Tello EDU flight

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)
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.

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:
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):

```
$ telloedu console
Ready to receive TelloEDU commands. Type "exit" to quit.
[1] pry(main)> connect
[2] pry(main)> ap 'Your-Wifi-SSID', 'Your-WIFI-password' ## this should reboot the drone in about 3 seconds
[3] pry(main)> quit
```

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.

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.

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):

Expand Down
8 changes: 5 additions & 3 deletions lib/tello/cli/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

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

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

Expand Down Expand Up @@ -44,8 +45,9 @@
when 'wifi?'
#=> snr
res = "90\r\n"
when 'whatever'
res = "unknown command: whatever"
when 'bye!'
res = 'good bye!'
bye = true
else
#=> 'ok' or 'error'
res = 'ok'
Expand Down
10 changes: 10 additions & 0 deletions lib/tello/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def in_move_range?(v)
end
end
alias_method :front, :forward
alias_method :backward, :back

# Turn clockwise or counterclockwise
[:cw, :ccw].each do |cmd|
Expand Down Expand Up @@ -217,6 +218,15 @@ def sn
send('sn?')
end

def bye!
## Tell the server to exit gracefully.
## Only applicable in test mode.
if Tello.testing
send('bye!')
exit(0) if connected?
end
end

# Get Wi-Fi signal-to-noise ratio (SNR); if parameters, set SSID and password
def wifi(ssid: nil, pass: nil)
if ssid && pass
Expand Down

0 comments on commit cb5e9e4

Please sign in to comment.