Class: Artoo::Drivers::Crazyflie
- Inherits:
-
Driver
- Object
- Driver
- Artoo::Drivers::Crazyflie
- Defined in:
- lib/artoo/drivers/crazyflie.rb
Overview
The crazyflie driver behaviors
Constant Summary collapse
- COMMANDS =
[:start, :stop, :hover, :land, :take_off, :emergency, :up, :down, :left, :right, :forward, :backward, :turn_left, :turn_right, :power].freeze
Instance Attribute Summary collapse
-
#pitch ⇒ Object
readonly
Returns the value of attribute pitch.
-
#roll ⇒ Object
readonly
Returns the value of attribute roll.
-
#thrust ⇒ Object
readonly
Returns the value of attribute thrust.
-
#xmode ⇒ Object
readonly
Returns the value of attribute xmode.
-
#yaw ⇒ Object
readonly
Returns the value of attribute yaw.
Instance Method Summary collapse
- #backward(deg) ⇒ Object
- #forward(deg) ⇒ Object
- #hover ⇒ Object
-
#initialize(params = {}) ⇒ Crazyflie
constructor
A new instance of Crazyflie.
- #land ⇒ Object
- #left(deg) ⇒ Object
- #power(deg) ⇒ Object
- #right(deg) ⇒ Object
- #set_thrust_off ⇒ Object
- #set_thrust_on ⇒ Object
- #start ⇒ Object
-
#start_driver ⇒ Object
Start driver and any required connections.
- #stop ⇒ Object
- #take_off ⇒ Object
- #turn_left(deg) ⇒ Object
- #turn_right(deg) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Crazyflie
Returns a new instance of Crazyflie.
14 15 16 17 18 19 20 21 |
# File 'lib/artoo/drivers/crazyflie.rb', line 14 def initialize(params={}) @roll = 0 @pitch = 0 @yaw = 0 @thrust = 0 @xmode = false # TODO what is this? super end |
Instance Attribute Details
#pitch ⇒ Object (readonly)
Returns the value of attribute pitch.
12 13 14 |
# File 'lib/artoo/drivers/crazyflie.rb', line 12 def pitch @pitch end |
#roll ⇒ Object (readonly)
Returns the value of attribute roll.
12 13 14 |
# File 'lib/artoo/drivers/crazyflie.rb', line 12 def roll @roll end |
#thrust ⇒ Object (readonly)
Returns the value of attribute thrust.
12 13 14 |
# File 'lib/artoo/drivers/crazyflie.rb', line 12 def thrust @thrust end |
#xmode ⇒ Object (readonly)
Returns the value of attribute xmode.
12 13 14 |
# File 'lib/artoo/drivers/crazyflie.rb', line 12 def xmode @xmode end |
#yaw ⇒ Object (readonly)
Returns the value of attribute yaw.
12 13 14 |
# File 'lib/artoo/drivers/crazyflie.rb', line 12 def yaw @yaw end |
Instance Method Details
#backward(deg) ⇒ Object
67 68 69 |
# File 'lib/artoo/drivers/crazyflie.rb', line 67 def backward(deg) @pitch = -deg end |
#forward(deg) ⇒ Object
63 64 65 |
# File 'lib/artoo/drivers/crazyflie.rb', line 63 def forward(deg) @pitch = deg end |
#hover ⇒ Object
49 50 51 |
# File 'lib/artoo/drivers/crazyflie.rb', line 49 def hover # TODO: call firmware that can do this? end |
#land ⇒ Object
53 54 |
# File 'lib/artoo/drivers/crazyflie.rb', line 53 def land end |
#left(deg) ⇒ Object
71 72 73 |
# File 'lib/artoo/drivers/crazyflie.rb', line 71 def left(deg) @roll = -deg end |
#power(deg) ⇒ Object
59 60 61 |
# File 'lib/artoo/drivers/crazyflie.rb', line 59 def power(deg) @thrust = deg end |
#right(deg) ⇒ Object
75 76 77 |
# File 'lib/artoo/drivers/crazyflie.rb', line 75 def right(deg) @roll = deg end |
#set_thrust_off ⇒ Object
91 92 93 |
# File 'lib/artoo/drivers/crazyflie.rb', line 91 def set_thrust_off @thrust = 0 end |
#set_thrust_on ⇒ Object
87 88 89 |
# File 'lib/artoo/drivers/crazyflie.rb', line 87 def set_thrust_on @thrust = 40000 end |
#start ⇒ Object
38 39 40 41 42 43 |
# File 'lib/artoo/drivers/crazyflie.rb', line 38 def start @roll = 0 @pitch = 0 @yaw = 0 @thrust = 10001 end |
#start_driver ⇒ Object
Start driver and any required connections
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/artoo/drivers/crazyflie.rb', line 24 def start_driver begin every(interval) do send_command end super rescue Exception => e Logger.error "Error starting Crazyflie driver!" Logger.error e. Logger.error e.backtrace.inspect end end |
#stop ⇒ Object
45 46 47 |
# File 'lib/artoo/drivers/crazyflie.rb', line 45 def stop set_thrust_off end |
#take_off ⇒ Object
56 57 |
# File 'lib/artoo/drivers/crazyflie.rb', line 56 def take_off end |
#turn_left(deg) ⇒ Object
79 80 81 |
# File 'lib/artoo/drivers/crazyflie.rb', line 79 def turn_left(deg) @yaw = -deg end |
#turn_right(deg) ⇒ Object
83 84 85 |
# File 'lib/artoo/drivers/crazyflie.rb', line 83 def turn_right(deg) @yaw = deg end |