module Tello::DSL
Public Instance Methods
acceleration()
click to toggle source
Get IMU angular acceleration data
# File lib/tello/dsl.rb, line 162 def acceleration send('acceleration?') end
attitude()
click to toggle source
Get IMU attitude data
# File lib/tello/dsl.rb, line 157 def attitude send('attitude?') end
baro()
click to toggle source
Get barometer value
# File lib/tello/dsl.rb, line 167 def baro Tello::Client.return_num send('baro?') end
battery()
click to toggle source
Get the battery level
# File lib/tello/dsl.rb, line 182 def battery b = send('battery?') b == false ? false : Tello::Client.return_num(b) end
connect()
click to toggle source
Connect to the drone
# File lib/tello/dsl.rb, line 14 def connect Tello::Client.connect end
connected?()
click to toggle source
Is the drone connected?
# File lib/tello/dsl.rb, line 19 def connected? Tello::Client.connected? end
curve(x1, y1, z1, x2, y2, z2, speed = 10)
click to toggle source
Fly in a curve; If arc radius is not within 0.5..10 m, command responds false
# File lib/tello/dsl.rb, line 117 def curve(x1, y1, z1, x2, y2, z2, speed = 10) # Check if coordinates are in range # TODO: x/y/z can't be between -20..20 at the same time unless in_move_range?(x1) && in_move_range?(y1) && in_move_range?(z1) && in_move_range?(x2) && in_move_range?(y2) && in_move_range?(z2) puts "x/y/z coordinates must be between 20..500 cm" return false end # Check if speed is in range unless (10..60).include? speed puts "Speed must be between 10..60 cm/s" return false end Tello::Client.return_bool send("curve #{x1} #{y1} #{z1} #{x2} #{y2} #{z2} #{speed}") end
disconnect()
click to toggle source
Disconnect the drone
# File lib/tello/dsl.rb, line 24 def disconnect Tello::Client.disconnect end
flip(f)
click to toggle source
Flip in a given direction
# File lib/tello/dsl.rb, line 68 def flip(f) case f when :left, :l Tello::Client.return_bool send('flip l') when :right, :r Tello::Client.return_bool send('flip r') when :forward, :f Tello::Client.return_bool send('flip f') when :backward, :b Tello::Client.return_bool send('flip b') else puts "Not a valid direction to flip" false end end
go(x, y, z, speed = 10)
click to toggle source
Fly to a location in x/y/z coordinates and provided speed
# File lib/tello/dsl.rb, line 99 def go(x, y, z, speed = 10) # Check if coordinates are in range unless in_move_range?(x) && in_move_range?(y) && in_move_range?(z) puts "x/y/z coordinates must be between 20..500 cm" return false end # Check if speed is in range unless (10..100).include? speed puts "Speed must be between 10..100 cm/s" return false end Tello::Client.return_bool send("go #{x} #{y} #{z} #{speed}") end
height()
click to toggle source
Get the height of the drone
# File lib/tello/dsl.rb, line 152 def height Tello::Client.return_num send('height?') end
in_move_range?(v)
click to toggle source
Check if value is within the common movement range
# File lib/tello/dsl.rb, line 34 def in_move_range?(v) (20..500).include? v end
rc(a, b, c, d)
click to toggle source
Send RC control via four channels:
a: left/right, b: forward/backward, c: up/down, d: yaw
# File lib/tello/dsl.rb, line 138 def rc(a, b, c, d) # Check if channel values are in range [a, b, c, d].each do |v| unless (-100..100).include? v puts "RC channel values must be between -100..100" return false end end Tello::Client.return_bool send("rc #{a} #{b} #{c} #{d}") end
send(s)
click to toggle source
Send a native Tello
command to the drone
# File lib/tello/dsl.rb, line 29 def send(s) Tello::Client.send(s) end
speed(s = nil)
click to toggle source
Get or set the flight speed
# File lib/tello/dsl.rb, line 85 def speed(s = nil) if s if (10..100).include? s Tello::Client.return_bool send("speed #{s}") else puts "Speed must be between 10..100 cm/s" end else s = send('speed?') s == false ? false : s.to_f end end
stop()
click to toggle source
Stop all motors immediately
# File lib/tello/dsl.rb, line 202 def stop Tello::Client.return_bool send('emergency') end
temp()
click to toggle source
Get the temperature of the drone
# File lib/tello/dsl.rb, line 188 def temp send('temp?') end
time()
click to toggle source
Get the flight time
# File lib/tello/dsl.rb, line 177 def time Tello::Client.return_num send('time?') end
tof()
click to toggle source
Get distance value from TOF
# File lib/tello/dsl.rb, line 172 def tof Tello::Client.return_num send('tof?') end
wifi(ssid: nil, pass: nil)
click to toggle source
Get Wi-Fi signal-to-noise ratio (SNR); if parameters, set SSID and password
# File lib/tello/dsl.rb, line 193 def wifi(ssid: nil, pass: nil) if ssid && pass Tello::Client.return_bool send("wifi #{ssid} #{pass}") else Tello::Client.return_num send('wifi?') end end