| 1 | # Copyright (c) 2015 Timm Murray | ||
| 2 | # All rights reserved. | ||
| 3 | # | ||
| 4 | # Redistribution and use in source and binary forms, with or without | ||
| 5 | # modification, are permitted provided that the following conditions are met: | ||
| 6 | # | ||
| 7 | # * Redistributions of source code must retain the above copyright notice, | ||
| 8 | # this list of conditions and the following disclaimer. | ||
| 9 | # * Redistributions in binary form must reproduce the above copyright | ||
| 10 | # notice, this list of conditions and the following disclaimer in the | ||
| 11 | # documentation and/or other materials provided with the distribution. | ||
| 12 | # | ||
| 13 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| 14 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 15 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 16 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
| 17 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 18 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 19 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| 20 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| 21 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 22 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 23 | # POSSIBILITY OF SUCH DAMAGE. | ||
| 24 | package UAV::Pilot::ARDrone; | ||
| 25 | 1 | $UAV::Pilot::ARDrone::VERSION = '1.0'; | |
| 26 | 1 | ▶ | use v5.14; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 27 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 28 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 29 | 1 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 30 | |||
| 31 | # ABSTRACT: Implements the Parrot AR.Drone under UAV::Pilot | ||
| 32 | |||
| 33 | |||
| 34 | 1 | ▶ | no Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 35 | 1 | __PACKAGE__->meta->make_immutable; | |
| 36 | 1 | 1; | |
| 37 | __END__ | ||
| 38 | |||
| 39 | |||
| 40 | =head1 NAME | ||
| 41 | |||
| 42 | UAV::Pilot::ARDrone | ||
| 43 | |||
| 44 | =head1 SYNOPSIS | ||
| 45 | |||
| 46 | use UAV::Pilot::ARDrone::Driver; | ||
| 47 | use UAV::Pilot::ARDrone::Control; | ||
| 48 | |||
| 49 | my $ardrone = UAV::Pilot::ARDrone::Driver->new({ | ||
| 50 | host => '192.168.1.1', | ||
| 51 | }); | ||
| 52 | $ardrone->connect; | ||
| 53 | |||
| 54 | my $dev = UAV::Pilot::ARDrone::Control->new({ | ||
| 55 | sender => $ardrone, | ||
| 56 | }); | ||
| 57 | |||
| 58 | |||
| 59 | $dev->takeoff; | ||
| 60 | $dev->pitch( 0.5 ); | ||
| 61 | $dev->flip_left; | ||
| 62 | $dev->land; | ||
| 63 | |||
| 64 | |||
| 65 | =head1 DESCRIPTION | ||
| 66 | |||
| 67 | Library for controlling Unmanned Aerial Drones. | ||
| 68 | |||
| 69 | |||
| 70 | =head1 FIRST FLIGHT OF AR.DRONE | ||
| 71 | |||
| 72 | =head2 Initial Setup | ||
| 73 | |||
| 74 | Connect the battery and put on the indoor or outdoor hull (as needed). | ||
| 75 | |||
| 76 | By default, the AR.Drone starts as its own wireless access point. Configure your wireless | ||
| 77 | network to connect to it. | ||
| 78 | |||
| 79 | =head2 The Shell | ||
| 80 | |||
| 81 | The C<uav> program connects to the UAV and prompts for commands. Simply start it and | ||
| 82 | wait for the C<<uav>>> prompt. You can exit by typing C<exit;>, C<quit;>, or C<q;>. | ||
| 83 | |||
| 84 | The shell takes Perl statements ending with 'C<;>'. Only a basic shell is loaded by | ||
| 85 | default. You must first load the AR.Drone libraries into the system, which you can do with: | ||
| 86 | |||
| 87 | load 'ARDrone'; | ||
| 88 | |||
| 89 | The ARDrone module will now be loaded. You can now tell it to takeoff, wave, flip, and land. | ||
| 90 | |||
| 91 | takeoff; | ||
| 92 | wave; | ||
| 93 | flip_left; | ||
| 94 | land; | ||
| 95 | |||
| 96 | If your drone suddenly stops, has all red lights, and won't takeoff again, then it went into | ||
| 97 | emergency mode. You get it out of this mode with the command: | ||
| 98 | |||
| 99 | emergency; | ||
| 100 | |||
| 101 | Which also works to toggle emergency mode back on if your UAV goes out of control. | ||
| 102 | |||
| 103 | If needed, you can force emergency mode by grabbing the UAV in midair (one hand on top, one | ||
| 104 | on the bottom) and flipping it over. | ||
| 105 | |||
| 106 | For simple piloting, the commands C<roll/pitch/yaw> can be used. Each of these takes a | ||
| 107 | single parameter of a floating point nubmer between -1.0 and 1.0: | ||
| 108 | |||
| 109 | roll -0.5; | ||
| 110 | pitch 1.0; | ||
| 111 | yaw 0.25; | ||
| 112 | |||
| 113 | As you can see, sending a single command only causes the manuever for a brief moment | ||
| 114 | before stopping. Commands must be continuously sent in order to have smooth flight. | ||
| 115 | |||
| 116 | TODO Write how to send commands continuously once we figure out how | ||
| 117 | |||
| 118 | =head1 OTHER LINKS | ||
| 119 | |||
| 120 | L<http://www.wumpus-cave.net> - Developer's blog | ||
| 121 | L<http://projects.ardrone.org> - AR.Drone Open API | ||
| 122 | L<http://ardrone2.parrot.com> - AR.Drone Homepage | ||
| 123 | |||
| 124 | =head1 LICENSE | ||
| 125 | |||
| 126 | Copyright (c) 2015 Timm Murray | ||
| 127 | All rights reserved. | ||
| 128 | |||
| 129 | Redistribution and use in source and binary forms, with or without modification, are | ||
| 130 | permitted provided that the following conditions are met: | ||
| 131 | |||
| 132 | * Redistributions of source code must retain the above copyright notice, this list of | ||
| 133 | conditions and the following disclaimer. | ||
| 134 | * Redistributions in binary form must reproduce the above copyright notice, this list of | ||
| 135 | conditions and the following disclaimer in the documentation and/or other materials | ||
| 136 | provided with the distribution. | ||
| 137 | |||
| 138 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS | ||
| 139 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
| 140 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
| 141 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
| 142 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 143 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 144 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | ||
| 145 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
| 146 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 147 | |||
| 148 | |||
| 149 | =cut | ||