Robot App Store Developer Program

robots-app-store-developer-program

Knowledge Base

How to Control AR.Drone LEDs

  By Anna Sandler

Make sure you are familiar with "How to program AR.Drone remotely over WIFI" chapter before you continue to this tutorial.

AT*LED command

This command is used to make the four motor’s LEDs blink with pre-defined sequence.

Syntax

AT*LED=[Sequence number ],[Animation number to play],[Frequency in Hz of the animation],[Total duration] <LF>

Explanation:

  • Sequence number- 1 if it is a first command, or sequence number value of previous command + 1;
  • Animation number- Integer at range of 0-20. See explanation for the animation number below;
  • Frequency in Hz of the animation- floating point number encoded as integer. See explanation below;
  • Total duration- Integer. Total duration in seconds of the animation. See explanation below;

Example:

The following UDP packet sends AT*LED command for the BLINK_GREEN_RED LED animation.
One cycle is set to last 2 seconds; the duration is set to 4 seconds, meaning 2 cycles of the animation.

The UDP packet that is sent to AR.Drone is:
AT*LED=1,0,1056964608,4<LF>

Arguments explanation

Animation number

LED animation is a pre-defined script for the LED colors, LED location and the active duration of the LED.

The definition of each animation can be easily calculated according the led_animation.h file that is located here: \ARDroneLib\Soft\Common\ inside the ARDrone SDK.

Each LED_ANIMATION has the following format:
LED_ANIMATION([name], { [number of default cycles],[number of items in the next argument], { {LED colors and positions bit-field], [duration in MS]},… } } )

The following is a definition of the LED_ANIMATION arguments:
  • Name- The name of the animation;
  • Number of default cycles- if the duration argument value is 0, the default value will be considered.
    1 as a default cycle will play the animation only once, while 0 will play the animation infinite.
    In order to stop infinite animation, use the BLANK animation (animation id 10);
  • Number of items in the next argument- You may ignore it;
  • LED colors and positions- This is a bit-field.
    Each bit represents the color and the position of the LED:
    (front left green bit | front left red bit | front right green bit | front right red bit | rear right green bit | rear right red bit | rear left green bit | rear left red bit).
    In order to get the orange-yellow color, both LEDs green and red should be turned on at the same position.
    For example, in order to get the orange color for all the four LEDs, use the 0xFF;
Animation number argument values:
  • 0- BLINK_GREEN_RED.
    Turn on all the four red LEDs for 500 MS,
    then turn on all the four green LEDs for 500 MS.
    Do it infinite if the duration argument value is 0;
  • 1- BLINK_GREEN.
    Wait for 500 MS
    then turn on all the four green LEDs for 500 MS.
    Do it infinite if the duration argument value is 0;
  • 2- BLINK_RED.
    Turn on all the four red LEDs for 500 MS,
    then turn all off and wait for 500 MS.
    Do it infinite if the duration argument value is 0;
  • 3- BLINK_ORANGE.
    Turn on all the LEDs for 500 MS.
    The combination of red and green will give the yellow-orange color.
    Then turn all off and wait for 500 MS.
    Do it infinite if the duration argument value is 0;
  • 4- SNAKE_GREEN_RED.
    Turn on the front left green LED and the front right red LED for 200 MS,
    then turn on the front left red LED and the rear right green LED for 200 MS,
    then the front right green LED and the rear right red LED for 200 MS,
    then the front right red LED and the rear left green LED for 200 MS,
    then the rear left red LED and the rear right green LED for 200 MS,
    then the front left green LED and the rear right red LED for 200 MS,
    then the front left red LED and the rear left green LED for 200 MS,
    then the front right green LED and the rear left red LED for 200 MS.
    Do it infinite if the duration argument value is 0;
  • 5- FIRE.
    Turn on all the 2 red LED on the rear and the red and green (for yellow-orange color) LED on the front right for 50 MS,
    then keep the 2 red LED on the rear turned on and turn on the red and green (for yellow-orange color) LED on the front left for 50 MS.
    Do it infinite if the duration argument value is 0;
  • 6- STANDARD.
    Turn on all the 2 green LEDs on the front and all the 2 red LEDs on the rear for 100 MS.
    Do it once if the duration argument value is 0;
  • 7- RED.
    Turn on all the four red LEDs for 100 MS.
    Do it once if the duration argument value is 0;
  • 8- GREEN.
    Turn on all the four green LEDs for 100 MS.
    Do it once if the duration argument value is 0;
  • 9- RED_SNAKE.
    Turn on the front left red LED for 500 MS,
    then the front right red LED for 500 MS,
    then the rear right red LED for 500 MS,
    then the rear left red LED for 500 MS.
    Do it infinite if the duration argument value is 0;
  • 10- BLANK.
    Turn off all the LEDs from previous animations;
  • 11- RIGHT_MISSILE.
    Wait for 500 MS,
    then turn on the rear right red LED for 300 MS,
    then the front right red LED and rear right red-green (orange-yellow) LEDs for 100 MS,
    then the front right green-red (orange-yellow) LEDs for 300 MS,
    then turn all the LEDs off and wait for 500 MS.
    Do it once if the duration argument value is 0;
  • 12- LEFT_MISSILE.
    Wait for 500 MS,
    then turn on the rear left red LED for 300 MS,
    then the front left red LED and rear left red-green (orange-yellow) LEDs for 100 MS,
    then the front left green-red (orange-yellow) LEDs for 300 MS,
    then turn all the LEDs off and wait for 500 MS.
    Do it once if the duration argument value is 0;
  • 13- DOUBLE_MISSILE.
    Wait for 500 MS,
    then turn on all the red LEDs on the rear for 300 MS,
    then all the LEDs (orange-yellow) on the front and the 2 LEDs on the front for 100 MS,
    then all the LEDs (orange-yellow) on the front for 300 MS,
    then turn all the LEDs off and wait for 500 MS.
    Do it once if the duration argument value is 0;
  • 14- FRONT_LEFT_GREEN_OTHERS_RED.
    Turn on the front left green LED, front right red LED, rear left red LED and rear right red for 100 MS.
    Do it once if the duration argument value is 0;
  • 15- FRONT_RIGHT_GREEN_OTHERS_RED.
    Turn on the front right green LED, front left red LED, rear left red LED and rear right red for 100 MS.
    Do it once if the duration argument value is 0;
  • 16- REAR_RIGHT_GREEN_OTHERS_RED.
    Turn on the front left red LED, front right red LED, rear left red LED and rear right green for 100 MS.
    Do it once if the duration argument value is 0;
  • 17- REAR_LEFT_GREEN_OTHERS_RED.
    Turn on the front left red LED, front right red LED, rear left green LED and rear right red for 100 MS.
    Do it once if the duration argument value is 0;
  • 18- LEFT_GREEN_RIGHT_RED.
    Turn on the front left green LED, the front right red LED, the rear right red LED and the rear left green LED for 100 MS.
    Do it once if the duration argument value is 0;
  • 19- LEFT_RED_RIGHT_GREEN.
    Turn on the front left red LED, the front right green LED, the rear right green LED and the rear left red LED for 100 MS.
    Do it once if the duration argument value is 0;
  • 20- BLINK_STANDARD.
    Wait for 500 MS,
    then turn on all the 2 front green LEDS and all the 2 rear red LEDs for 500 MS.
    Do it infinite if the duration argument value is 0;

Frequency of the animation

Frequency of the animation is the period in seconds (inversed floating number) of one cycle of the animation.
Pre-defined animation has a list of commands for execution.
The period of the active LED in the script is pre-defined and cannot be changed, but the delay between the commands can be controlled through the Frequency argument.

The frequency should be higher or equal to the animation minimum cycle.

The higher the value, the shorter the delay period, the faster the animation cycle.

For example:
The BLINK_GREEN_RED animation cycle takes at least one second to finish (with zero delay between the commands). 2 seconds frequency will add extra 1 second as follows: All the four red LEDs will be turned on for 500 MS, then wait the extra 1 second that we’ve added to the frequency, after the pause all the four green LEDs will be turned on for 500 MS. Total duration for one cycle will be 2 seconds as instructed.

The value of the Frequency argument will be calculated as follows:
  • Inverse the desired duration in seconds for one animation cycle (1 / cycle duration).
    For example, 2 seconds will be inversed to 1/2 number or 0.5 float.
  • Convert the inversed float into hax.
    For example, 0.5 float in hex will be 3F000000.
  • Convert the hex to decimal.
    For example, 3F000000 will be 1056964608 in decimal. This number will be used as a frequency argument value.

Total duration

Total duration is the total duration in seconds for all the animation cycles to complete.
  • If the duration argument value is set to 0-
    the animation will be executed according to the default value for each animation (usually it will be executed only once or infinite);
  • If the duration argument value is set to number that is higher than the frequency seconds,
    it will loop the animation (add more cycles) for the duration period;








Related Robot-Apps™

Comments