Timm Murray > UAV-Pilot-0.1 > UAV::Pilot::Commands

Download:
UAV-Pilot-0.1.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  2
View/Report Bugs
Source   Latest Release: UAV-Pilot-0.9

NAME ^

  UAV::Pilot::Commands

SYNOPSIS ^

    my $device; # Some UAV::Pilot::Device instance, defined elsewhere
    my $cmds = UAV::Pilot::Commands->new({
        device => $device,
    });
    
    $cmds->load_lib( 'ARDrone' );
    $cmds->run_cmd( 'takeoff;' );
    $cmds->run_cmd( 'land;' );

DESCRIPTION ^

Provides an interface for loading UAV extensions and running them, particularly for REPL shells.

METHODS ^

new

    new({
        device => $device
    })

Constructor. Takes a UAV::Pilot::Device instance.

load_lib

    load_lib( 'ARDrone', {
        pack => 'AR',
    })

Loads an extension by name. The pack paramter will load the library into a specific namespace. If you don't specify it, you won't need to qualify commands with a namespace prefix. Example:

    load_lib( 'ARDrone', { pack => 'AR' } );
    run_cmd( 'takeoff;' );     # Error: no subroutine named 'takeoff'
    run_cmd( 'AR::takeoff;' ); # This works
    
    load_lib( 'ARDrone' );
    run_cmd( 'takeoff;' );     # Now this works, too

Any other parmaeters you pass will be passed to the module's uav_module_init() subroutine.

run_cmd

    run_cmd( 'takeoff;' )

Executes a command. Note that this will execute arbitrary Perl statements.

COMMANDS ^

Commands provide an easy interface for writing simple UAV programms in a REPL shell. They are usually thin interfaces over a UAV::Pilot::Device. If you're writing a complicated script, it's suggested that you skip this interface and write to the UAV::Pilot::Device directly.

load

    load 'ARDrone', {
        pack => 'AR',
    };

Direct call to load_lib. The pack paramter will load the library into a specific namespace. If you don't specify it, you won't need to qualify commands with a namespace prefix. Example:

    load 'ARDrone', { pack => 'AR' };
    takeoff;     # Error: no subroutine named 'takeoff'
    AR::takeoff; # This works
    
    load ARDrone;
    takeoff;     # Now this works, too

Any other parmaeters you pass will be passed to the module's uav_module_init() subroutine.

WRITING YOUR OWN EXTENSIONS ^

Extensions should go under the directory UAV/Pilot/Modules/ with a .uav extension. You write them much like any Perl module, but don't use a package statement--the package will be controlled by UAV::Pilot::Command when loaded. Like a Perl module, it should return true as its final statement (put a 1; at the end).

Likewise, be careful not to make any assumptions about what package you're in. Modules may or may not get loaded into different, arbitrary packages.

For ease of use, it's recommended to use function prototypes to reduce the need for parens.

The method uav_module_init() is called with the package name as the first argument. Subsquent arguments will be the hashref passed to load()/load_lib(). After being called, this sub will be deleted from the package.

syntax highlighting: