Class: Crubyflie::Commander
- Inherits:
-
Object
- Object
- Crubyflie::Commander
- Defined in:
- lib/crubyflie/crazyflie/commander.rb
Overview
The Commander facility is used to send control information to the Crazyflie. You want to use this class to fly your Crazyflie
Instance Method Summary collapse
-
#initialize(crazyflie) ⇒ Commander
constructor
Initialize the facility.
-
#send_setpoint(roll, pitch, yaw, thrust, xmode = false) ⇒ Object
Send a setpoint to the Crazyflie.
Constructor Details
#initialize(crazyflie) ⇒ Commander
Initialize the facility
24 25 26 |
# File 'lib/crubyflie/crazyflie/commander.rb', line 24 def initialize(crazyflie) @crazyflie = crazyflie end |
Instance Method Details
#send_setpoint(roll, pitch, yaw, thrust, xmode = false) ⇒ Object
Send a setpoint to the Crazyflie
The roll, pitch, yaw values are floats with positive or negative values. The range should be the value read from the controller ([-1,1]) multiplied by the maximum angle change rate
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/crubyflie/crazyflie/commander.rb', line 39 def send_setpoint(roll, pitch, yaw, thrust, xmode=false) if xmode roll = 0.707 * (roll - pitch) pitch = 0.707 * (roll + pitch) end packet = CRTPPacket.new() packet.modify_header(nil, Crazyflie::CRTP_PORTS[:commander], nil) data = [roll, -pitch, yaw, thrust] # send 3 floats and one unsigned short (16 bits) (all little endian) data = data.pack('eeeS<') packet.data = data.unpack('C*') @crazyflie.send_packet(packet, false) end |