Ardrone
Public Types | Public Member Functions | Protected Member Functions
Ardrone Class Reference

Remote Control module for AR.Drone. More...

#include <Ardrone.h>

List of all members.

Public Types

enum  LEDAnimation {
  ARDRONE_LED_ANIMATION_BLINK_GREEN_RED = 0, ARDRONE_LED_ANIMATION_BLINK_GREEN, ARDRONE_LED_ANIMATION_BLINK_RED, ARDRONE_LED_ANIMATION_BLINK_ORANGE,
  ARDRONE_LED_ANIMATION_SNAKE_GREEN_RED, ARDRONE_LED_ANIMATION_FIRE, ARDRONE_LED_ANIMATION_STANDARD, ARDRONE_LED_ANIMATION_RED,
  ARDRONE_LED_ANIMATION_GREEN, ARDRONE_LED_ANIMATION_RED_SNAKE, ARDRONE_LED_ANIMATION_BLANK, ARDRONE_LED_ANIMATION_RIGHT_MISSILE,
  ARDRONE_LED_ANIMATION_LEFT_MISSILE, ARDRONE_LED_ANIMATION_DOUBLE_MISSILE, ARDRONE_LED_ANIMATION_FRONT_LEFT_GREEN_OTHERS_RED, ARDRONE_LED_ANIMATION_FRONT_RIGHT_GREEN_OTHERS_RED,
  ARDRONE_LED_ANIMATION_REAR_RIGHT_GREEN_OTHERS_RED, ARDRONE_LED_ANIMATION_REAR_LEFT_GREEN_OTHERS_RED, ARDRONE_LED_ANIMATION_LEFT_GREEN_RIGHT_RED, ARDRONE_LED_ANIMATION_LEFT_RED_RIGHT_GREEN,
  ARDRONE_LED_ANIMATION_BLINK_STANDARD
}
 Defines types of LED animation for use with addAtLedAnimCmd() More...
enum  Animation {
  ARDRONE_ANIMATION_PHI_M30_DEG = 0, ARDRONE_ANIMATION_PHI_30_DEG, ARDRONE_ANIMATION_THETA_M30_DEG, ARDRONE_ANIMATION_THETA_30_DEG,
  ARDRONE_ANIMATION_THETA_20DEG_YAW_200DEG, ARDRONE_ANIMATION_THETA_20DEG_YAW_M200DEG, ARDRONE_ANIMATION_TURNAROUND, ARDRONE_ANIMATION_TURNAROUND_GODOWN,
  ARDRONE_ANIMATION_YAW_SHAKE, ARDRONE_ANIMATION_YAW_DANCE, ARDRONE_ANIMATION_PHI_DANCE, ARDRONE_ANIMATION_THETA_DANCE,
  ARDRONE_ANIMATION_VZ_DANCE, ARDRONE_ANIMATION_WAVE, ARDRONE_ANIMATION_PHI_THETA_MIXED, ARDRONE_ANIMATION_DOUBLE_PHI_THETA_MIXED
}
 Defines types of animation for use with addAtAnimCmd() More...

Public Member Functions

 Ardrone ()
void init ()
void run ()
void setControlYaw (float control_yaw)
void setControlVZMax (float control_vz_max)
void setEulerAngleMax (float euler_angle_max)
void setAlitudeMax (float altitude_max)
void setOutdoor (float outdoor)
void setFlying (boolean flying)
boolean flying ()
void setRoll (float roll)
float roll ()
void setPitch (float pitch)
float pitch ()
void setGaz (float gaz)
float gaz ()
void setYaw (float yaw)
float yaw ()
void connected ()
void periodicTask ()
void addAtPCmd (unsigned int flags, float roll, float pitch, float gaz, float yaw)
void addAtConfigCmd (const char *name, const char *value)
void addAtLedCmd (Ardrone::LEDAnimation animation=ARDRONE_LED_ANIMATION_BLINK_GREEN_RED, float frequency=5.0, uint16_t duration=5)
void addAtAnimCmd (Ardrone::Animation animation=ARDRONE_ANIMATION_WAVE, uint16_t duration=5)
void addAtFtrimCmd ()
 Adds a drone FTRIM comamnd to the command buffer, which will be sent during the next update();.
void addAtRefCmd (uint32_t flags)
void addAtComWdgCmd ()
 Adds a drone COMWDG comamnd to the command buffer, which will be sent during the next update();.
void addAtPmodeCmd (uint8_t mode)
void addAtMiscCmd (uint16_t a, uint16_t b, uint16_t c, uint16_t d)

Protected Member Functions

void device_init ()
void update ()
void sendAtCmd (uint8_t *msg, uint16_t len)
void sendAtCmd (char *s)
void sendCurrentAtCmd ()
 Sends the entire currently accumulated command buffer to the drone AT port.

Detailed Description

Remote Control module for AR.Drone.

This class provides a simple interface to the AR.Drone over a WiFi connection.

Overview

This module presents a simple interface through wchich you can control and fly a AR.Drone. It requires a WiFi interface hardware and the WiShield library. It initialises the WiFi library, hardware and drone, then sends a stream of flying commands to the drone's AT UDP port. Member functions allow you to control the pitch, roll, yaw and altitude of the drone, and to make it land and take off, based on some input device (or perhaps a canned sequence of commands).

Initialisation

This module intialises the drone in the following way:

After initialisation, the update() function sends PCMD, REF and COMWDG commands every ARDRONE_AT_CMD_INTERVAL milliseconds.


Member Enumeration Documentation

Defines types of animation for use with addAtAnimCmd()

Each animation produces a different type of preprogrammed pattern of movement, superposed on the flying commands

Defines types of LED animation for use with addAtLedAnimCmd()

Each animation produces a different type of flashing pattern


Constructor & Destructor Documentation

Ardrone::Ardrone ( )

Constructor. After contruction and initialisation, call the init() and run() functions. You must also define the SSID of the AR.Drone's ad-hoc wireless network, like this:

Ardrone ardrone;
const prog_char ssid[] PROGMEM = "ardrone_165416";

where ardrone_165416 is replaced with the actual network name for your particular AR.Drone.


Member Function Documentation

void Ardrone::addAtAnimCmd ( Ardrone::Animation  animation = ARDRONE_ANIMATION_WAVE,
uint16_t  duration = 5 
)

Adds a drone ANIM comamnd to the command buffer, which will be sent during the next update();

Parameters:
[in]animationOne of the Animation values, which specifies the type of flying animation pattern to use
[in]durationPeriod of time to run the animation for in seconds
void Ardrone::addAtConfigCmd ( const char *  name,
const char *  value 
)

Adds a drone CONFIG comamnd to the command buffer, which will be sent during the next update();

Parameters:
[in]nameString name of the config parameter to change
[in]valueString value to change it to

Referenced by device_init().

void Ardrone::addAtLedCmd ( Ardrone::LEDAnimation  animation = ARDRONE_LED_ANIMATION_BLINK_GREEN_RED,
float  frequency = 5.0,
uint16_t  duration = 5 
)

Adds a drone LED comamnd to the command buffer, which will be sent during the next update();

Parameters:
[in]animationOne of the LEDAnimation values, which specifies the type of flashing pattern to use
[in]frequencyFlashing frequency in Hz.
[in]durationPeriod of time to run the animation for in seconds

Referenced by device_init().

void Ardrone::addAtMiscCmd ( uint16_t  a,
uint16_t  b,
uint16_t  c,
uint16_t  d 
)

Adds a drone MISC comamnd to the command buffer, which will be sent during the next update();

Parameters:
[in]aNot documented
[in]bNot documented
[in]cNot documented
[in]dNot documented
void Ardrone::addAtPCmd ( unsigned int  flags,
float  roll,
float  pitch,
float  gaz,
float  yaw 
)

Adds a drone PCMD comamnd to the command buffer, which will be sent during the next update();

Parameters:
[in]flagsBitmask of ARDRONE_PCMD_FLAG_* flags
[in]rollThe new roll command value.
[in]pitchThe new pitch command value.
[in]gazThe new gaz command value.
[in]yawThe new yaw command value.

Referenced by update().

void Ardrone::addAtPmodeCmd ( uint8_t  mode)

Adds a drone PMODE comamnd to the command buffer, which will be sent during the next update();

Parameters:
[in]modeNot documented
void Ardrone::addAtRefCmd ( uint32_t  flags)

Adds a drone REF comamnd to the command buffer, which will be sent during the next update();

Parameters:
[in]flagsBitmask of ARDRONE_REF_FLAG_*

Referenced by update().

void Ardrone::connected ( )

For internal use only. Indicates a successful connection to the drone has been made, and initialisation can commence

void Ardrone::device_init ( )
protected

For internal use only. Called periodically during device initialisation. Sends a series of commands to initialise the drone.

References addAtConfigCmd(), addAtFtrimCmd(), addAtLedCmd(), and sendCurrentAtCmd().

Referenced by periodicTask().

boolean Ardrone::flying ( )

Returns the most recently set value of the flying parameter.

Returns:
the current value of the flying parameter

Referenced by setFlying().

float Ardrone::gaz ( )

Returns the most recently set value of the gaz parameter.

Returns:
The current gaz value;

Referenced by setGaz().

void Ardrone::init ( )

Initialises the wireless WiFi receiver Call once at startup time after addresses, flight parameters etc have been configured.

void Ardrone::periodicTask ( )

For internal use only. Runs various periodic tasks for the drone

References device_init(), and update().

float Ardrone::pitch ( )

Returns the most recently set value of the pitch parameter.

Returns:
The current pitch value;

Referenced by setPitch().

float Ardrone::roll ( )

Returns the most recently set value of the roll parameter.

Returns:
The current roll value;

Referenced by setRoll().

void Ardrone::run ( )

Call this to process pending Wireless events. Call this as often as possible in your main loop. Runs the wireless driver stack, which calls periodicTask(), among other things

void Ardrone::sendAtCmd ( uint8_t *  msg,
uint16_t  len 
)
protected

Sends a command to the drone AT port

Parameters:
[in]msgThe message to be sent
[in]lenThe length of the message in bytes

Referenced by sendAtCmd(), and sendCurrentAtCmd().

void Ardrone::sendAtCmd ( char *  s)
protected

Sends a string to the drone AT port

Parameters:
[in]sThe ASCII string to send

References sendAtCmd().

void Ardrone::setAlitudeMax ( float  altitude_max)

Sets the intialisation value for control:altitude_max which limits the maximum height Defaults to 3000.0 mm

Parameters:
[in]altitude_maxmaximum altitude in mm
void Ardrone::setControlVZMax ( float  control_vz_max)

Sets the intialisation value for control:control_vz_max which limits the maximum rate of change of altitude Defaults to 700.0 mm/sec

Parameters:
[in]control_vz_maxmaximum rate of change of altitude, mm/second
void Ardrone::setControlYaw ( float  control_yaw)

Sets the intialisation value for control:control_yaw which limits the maximum rate of change of yaw Defaults to 1.75 radians/sec

Parameters:
[in]control_yawmaximum rate of change of yaw, radians/second
void Ardrone::setEulerAngleMax ( float  euler_angle_max)

Sets the intialisation value for control:euler_angle_max which limits the maximum roll and pitch tilt Defaults to 0.1 radians

Parameters:
[in]euler_angle_maxmaximum tilt for roll and pitch in radians
void Ardrone::setFlying ( boolean  flying)

Sets the flying parameter Causes the drone to take off or land. Defaults at initialisation to false.

Parameters:
[in]flyingIf true, drone will take off to 1m hover. If false, drone will land.

References flying().

void Ardrone::setGaz ( float  gaz)

Sets the gaz (rate of change of altitude). Range from -1.0 (descend at control_vz_max mm/sec) to +1.0 (ascend at control_vz_max mm/sec). 0.0 means level. Defaults at initialisation to 0.0. The new gaz parameter will be sent during the next update() if the drone is flying.

Parameters:
[in]gazThe new gaz value

References gaz().

void Ardrone::setOutdoor ( float  outdoor)

Sets the intialisation value for control:outdoor which specifies whether the default drone limits for indoor or outdoor flying should be used Defaults to false.

Parameters:
[in]outdoortrue if flying outdoors
void Ardrone::setPitch ( float  pitch)

Sets the pitch parameter. Range from -1.0 (pitch forward to euler_angle_max radians) to +1.0 (pitch back to euler_angle_max radians). 0.0 means level. Defaults at initialisation to 0.0. The new pitch parameter will be sent during the next update() if the drone is flying.

Parameters:
[in]pitchThe new pitch value

References pitch().

void Ardrone::setRoll ( float  roll)

Sets the roll parameter. Range from -1.0 (roll left to euler_angle_max radians) to +1.0 (roll right to euler_angle_max radians). 0.0 means level. Defaults at initialisation to 0.0. The new roll parameter will be sent during the next update() if the drone is flying.

Parameters:
[in]rollThe new roll value

References roll().

void Ardrone::setYaw ( float  yaw)

Sets the yaw (rate of change of yaw). Range from -1.0 (rotate left at control_yaw radians/sec) to +1.0 (rotate right at control_yaw radians/sec). 0.0 means no rotation. Defaults at initialisation to 0.0. The new yaw parameter will be sent during the next update() if the drone is flying.

Parameters:
[in]yawThe new yaw value

References yaw().

void Ardrone::update ( )
protected

For internal use only. Called periodically after device initialisation. Sends any commands accumulated by earlier calls to addAt*Cmd() functions. If the drone is flying sends a PCMD with the curent flying parameters Also sends a REF command with appropriate flags for flying or grounded Also sends a COMWDG command to refresh teh comms watchdog.

References addAtComWdgCmd(), addAtPCmd(), addAtRefCmd(), and sendCurrentAtCmd().

Referenced by periodicTask().

float Ardrone::yaw ( )

Returns the most recently set value of the yaw parameter.

Returns:
The current yaw value;

Referenced by setYaw().


The documentation for this class was generated from the following files: