class Crubyflie::Commander

The Commander facility is used to send control information to the Crazyflie. You want to use this class to fly your Crazyflie

Public Class Methods

new(crazyflie) click to toggle source

Initialize the facility

# File lib/crubyflie/crazyflie/commander.rb, line 23
def initialize(crazyflie)
    @crazyflie = crazyflie
end

Public Instance Methods

send_setpoint(roll, pitch, yaw, thrust, xmode=false) click to toggle source

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 @param roll [float] the roll value @param pitch [float] the pitch value @param yaw [float] the yaw value @param thrust [Integer] thrust is an integer value ranging

from 10001 (next to no power) to
60000 (full power)
# File lib/crubyflie/crazyflie/commander.rb, line 38
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