Timm Murray > UAV-Pilot-0.8 > UAV::Pilot::ARDrone::Control

Download:
UAV-Pilot-0.8.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  2
View/Report Bugs
Source  

NAME ^

  UAV::Pilot::ARDrone::Control

SYNOPSIS ^

    my $driver = UAV::Pilot::ARDrone::Driver->new( ... );
    $driver->connect;
    my $dev = UAV::Pilot::ARDrone::Control->new({
        driver => $driver,
    });
    
    $dev->takeoff;
    $dev->pitch( 0.5 );
    $dev->wave;
    $dev->flip_left;
    $dev->land;

DESCRIPTION ^

UAV::Pilot::ControlHelicopter implementation for the Parrot AR.Drone.

METHODS ^

new

NOTE: It's highly recommended that you initialize the subclass UAV::Pilot::ARDrone::Control::Event instead of this one.

    new({
        driver => $driver,
        video  => $video_driver,
    });

Constructor. As with UAV::Pilot::Control, the driver option is a mandatory parameter with the value being a UAV::Pilot::Driver::ARDrone object.

The optional video parameter is a UAV::Pilot::Driver::ARDrone::Video object. When the emergency mode is toggled on the ARDrone, the video stream needs to be restarted. Placing the object here will call emergency_restart() on the video object for you.

takeoff

Takeoff.

land

Land.

pitch

    pitch( 0.5 )

Pitch (front-to-back movement). Takes a floating point number between -1.0 and 1.0. On the AR.Drone, negative numbers pitch the nose down and fly forward.

roll

    roll( -1.0 )

Roll (left-to-right movement). Takes a floating point number between -1.0 and 1.0. On the AR.Drone, negative numbers go left.

yaw

    yaw( -0.25 )

Yaw (spin). Takes a floating point number between -1.0 and 1.0. On the AR.Drone, negative numbers spin left.

vert_speed

    vert_speed( 0.7 )

Change the vertical speed. Takes a floating point number between -1.0 and 1.0. On the AR.Drone, negative numbers make it go down.

calibrate

Calibrates the magnetometer. This must be done while in flight. The drone will spin around (yaw movement) while it does this.

emergency

Toggles the emergency state. If your UAV goes out of control, call this to immediately shut it off. When in the emergency state, it will not be responsive to further commands. Call this again to bring it out of this state.

reset_watchdog

Sends a command to reset the watchdog process. You need to send some command at least every 2 seconds, or else the AR.Drone thinks the connection was lost. If you don't have anything else to send, send this one.

If you run start_event_loop(), the reset will happen for you.

hover

Stops the UAV and hovers in place.

start_userbox_nav_data

Starts saving navigation data on the UAV itself. The file will be in the directory:

    /boxes/flight_YYYYMMDD_hhmmss

You can FTP into the AR.Drone to retrieve this.

stop_userbox_nav_data

Stops logging navigation data on the UAV.

cancel_userbox_nav_data

Stops logging navigation data on the UAV AND deletes the log directory.

take_picture

    take_picture( $delay, $num_pics )

Saves a picture in JPG format to:

    /boxes/flight_YYYYMMDD_hhmmss/picture_YYYYMMDD_hhmmss.jpg

You can FTP into the AR.Drone to retrieve this.

record_usb

Start recording the video stream to a USB stick attached to the AR.Drone's internal USB port. The stick must have at least 100MB free.

setup_read_nav_event

  setup_read_nav_event( $event );

Pass a UAV::Pilot::EasyEvent object. Sets up a UAV::Pilot::NavCollector::AckEvents and starts an event timer for reading nav packets.

set_multiconfig

  set_multiconfig( $user_id, $app_id, $session_id )

NOTE: This doesn't yet seem to work right. You can set the keys, but the UAV won't respond to config commands after that. It should just be a matter of sending AT*CONFIG_IDS before each AT*CONFIG, which is what send_config() will do for you. But it doesn't work. Still debugging . . .

Pass a unique user, app, and session ID. The best way to generate these is to take a string identifying your user and app and run it through a CRC32. The $session_id is optional; if passed, it should be unique to this particular run.

In the AR.Drone, "multiconfig" is a way to set configurations that are unique to the user, app, or session. For backwards compatibility with old apps, the AR.Drone only lets you set some keys when using multiconfig. See the AR.Drone SDK docs for details.

send_config

  send_config( $name, $value )

Send a config name/value. If you used set_multiconfig(), this will send the necessary commands before the config setting.

FLIGHT ANIMATION METHODS ^

The Parrot AR.Drone comes preprogrammed with a bunch of "flight animations" (complicated achrebatic manuevers). You can call the methods below to run them. Note that some of these need a generous amount of horizontal and vertical space, so be sure to be in a wide open area for testing.

I find "wave" and "flip_behind" are particularly good ways to impress house guests :)

    phi_m30_deg
    phi_30_deg
    theta_m30_deg
    theta_30_deg
    theta_20deg_yaw_200deg
    theta_20deg_yaw_m200deg
    turnaround
    turnaround_godown
    yaw_shake
    yaw_dance
    phi_dance
    theta_dance
    vz_dance
    wave
    phi_theta_mixed
    double_phi_theta_mixed
    flip_ahead
    flip_behind
    flip_left
    flip_right

LED ANIMATION METHODS ^

The LEDs on the Parrot AR.Drone can be directly controlled using these animation methods. They all take two parameters: the frequency (in Hz) as a floating point number, and the duration.

    led_blink_green_red
    led_blink_green
    led_blink_red
    led_blink_orange
    led_snake_green_red
    led_fire
    led_standard
    led_red
    led_green
    led_red_snake
    led_blank
    led_right_missile
    led_left_missile
    led_double_missile
    led_front_left_green_others_red
    led_front_right_green_others_red
    led_rear_right_green_others_red
    led_rear_left_green_others_red
    led_left_green_right_red
    led_left_red_right_green
    led_blink_standard
syntax highlighting: