Slide 1

Slide 1 text

BAPTISTE ADRIEN @SHINEWORK

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

SOCKETUDP TCP PHP STREAM react EVENT DRONE Parrot

Slide 4

Slide 4 text

COUCHES HAUTES COUCHES MATERIELLES PHYSIQUE RESEAU TRANSPORT SESSION PRESENTATION APPLICATION LIAISON DE DONNEES

Slide 5

Slide 5 text

connecté non connecté

Slide 6

Slide 6 text

HTTP SOCKET STREAM EVENT LOOP

Slide 7

Slide 7 text

$readble = array($stream1, $stream2); $writable = array($stream3, $stream4); $except = null; if (stream_select($read, $write, $except, 1)) { if ($readble) { foreach ($readble as $stream) { // process } } if ($writable) { foreach ($writable as $stream) { // process } } }

Slide 8

Slide 8 text

Event Loop Component readable stream WRITABLE STREAM stream_select()

Slide 9

Slide 9 text

$loop = React\EventLoop\Factory::create(); $socket = new React\Socket\Server($loop); $socket->on('connection', function ($conn) { $conn->write(’Hello ForumPHP!\n’); $conn->on('data', function ($data) use ($conn) { // Awesome instructions }); }); $socket->listen(1337); $loop->run() SERVEuR

Slide 10

Slide 10 text

$loop = React\EventLoop\Factory::create(); $udpFactory = new Datagram\Factory($loop); $udpFactory->createClient($ip, $port)->then(function ($client) { $client->send(’Coucou !’); }); $loop->run() CLIENT

Slide 11

Slide 11 text

ACCéLéROMETRE caméras GYROSCOPES Magnétometre barometre E/R ULTRASONS SYSTeme embarqué

Slide 12

Slide 12 text

NAVDATA CONTROL VIDEO CONFIG UDP TCP CLIENT SERVEUR

Slide 13

Slide 13 text

HEADER DRONE STATE SEQUENCE NUMBER VISION FLAG CHECKSUM OPTION 1 OPTION 2 OPTION n... Les options contiennent des informations sur l’état de l’AR Drone. Chaque option est définie par un type et des valeurs. Exemple de type: - rawMeasures - visionDetect - winSpeed - videoStream

Slide 14

Slide 14 text

unpack uint32 uint16 float32 ... HEADER DRONE STATE SEQUENCE NUMBER OPTION 1 VISION FLAG CHECKSUM ... ... ID SIZE DATA ID SIZE DATA ... ... ... ... int. 32 int. 32 int. 32 int. 32 int. 16 int. 16 int. 16 int. 16 int. 16 $header = unpack('V/', substr ($incomingData , 0, 4)); / / 0x55667788 $droneState = unpack('V/', substr ($incomingData , 4, 8)); $sequenceNumber = unpack('V/', substr ($incomingData , 8, 12)); $visionFlag= unpack('V/', substr ($incomingData , 12, 16)); $idOption1 = unpack('v/', substr ($incomingData , 12, 14)); $sizeOption1 = unpack('v/', substr ($incomingData , 14, 16)); ...

Slide 15

Slide 15 text

// Décalage à gauche utile pour les masques binaires $droneStateMasks = array( 'flying' => (1 << 0), 'videoEnabled' => (1 << 1), 'visionEnabled' => (1 << 2), 'controlAlgorithm' => (1 << 3), 'altitudeControlAlgorithm' => (1 << 4), 'startButtonState' => (1 << 5), 'controlCommandAck' =>(1 << 6), 'cameraReady' =>(1 << 7) ); $videoIsEnable = ($droneState & $droneStateMasks[1]) ? 1 : 0; & et << pour gérer les états & | ^ ~ << >> AND OR XOR NOT LEFT SHIFT RIGHT SHIFT

Slide 16

Slide 16 text

AT*=, ,, ... PERMET D'ENVOYER DES INSTRUCTIONS DE CONTROLE SUR LE PORT UDP 5554 DE L'AR DRONE AT*REF AT*PCMD AT*CONFIG TYPES

Slide 17

Slide 17 text

PERMET DE FAIRE DECOLLER & ATTERRIR LE DRONE Argument 1 : Sequence Number Argument 2 : Integer représentant un champ de 32 bits; Lorsque bit 9 = 0 : Atterrissage Lorsque bit 9 = 1 : Décollage $ref = 0; $ref = $ref | (1 << 9); // 512 -> 1000000000 $client->send(”AT*REF=1,$ref”); // Décollage ! AT*REF=%d, %d

Slide 18

Slide 18 text

AT*PCMD=%d,%d,%d,%d,%d,%d PERMET DE CONTROLER LES MOUVEMENTS DU DRONE Argument 1: Sequence Number Argument 2: Commande progressive Argument 3: Droite / gauche Argument 4: Avant / arrière Argument 5: Haut / bas Argument 6: Rotation Arguments 3 à 6 de type Float [−1..1] (orientation + vitesse)

Slide 19

Slide 19 text

DEMO TIME https://github.com/jolicode/php-ar-drone

Slide 20

Slide 20 text

github.com/jolicode/php-ar-drone MERCI ! question ? speakerdeck.com/shinework/ [email protected] PROJETS DES COOL ? @SHINEWORK joind.in/talk/view/9361 FEED BACK SLIDES CODE !