Share
Embed
Cross Platform Copter with Titanium
How to control a drone with javascript and titanium
Marcus Ross
February 23, 2013
Transcript
27 slides
-
Cross Pla)orm Copter How to control a drone with
5tanium? Marcus Ross / @zahlenhelfer -
Boys and their toys... • When I was a
liCle boy, I always wanted this: hCp://www.flickr.com/photos/raijsi/4442087532/ -
...when they grow up • Now, I´m a man
– but a boy, too. • so I want this today: -
...but as a Titan do more • perfect solu5on:
Titanium + AR.Drone = BIG FUN • Kickstarter was: Blackberry JAM Asia 2012 Contest • I tried the Alpha Version of the BB SDK • ask Ketan for more serious apps with this -
details of the drone • AR.Drone 2.0 is from
Parrot • 4 x 35,000 rpm motors • ARM Cortex A8 1Ghz • 1 GB RAM • Wifi with b/g/n • BusyBox Linux 2.6.32 • Magnometer / Gyro • 2x camera (720p HD & QVGA) hCp://www.flickr.com/photos/crea5ve_stock/ -
This is BB10 Copter • Titanium based app
• basic flight • can do a stunt • has LED control artwork by Liz Meyers -‐> -
Challanges • understand the SDK • understand UDP
• do real5me stuff • make it easy via JS hCp://www.flickr.com/photos/irrezolut/ -
• use the SDK docs • understand the protocol •
understand the cmds • use easy javascript with Titanium power tools for the job 8 hCp://www.flickr.com/photos/skistz/398429879/ -
dev requirements • get SDK Docs (hCps://projects.ardrone.org/)
• get Appcelerator Titanium (hCp://www.appcelerator.com/) • get the UDP plugin (hCps://github.com/appcelerator/ 5tanium_modules.git) • clone the starter project (hCps://github.com/zahlenhelfer/ CrossPla)ormCopter.git) • have FUN! -
How to talk to a drone • think in
real5me! • be polite • repeat yourself osen • don´t forget the kill switch (demo) -
Let´s start building it • Read the docs
• and understand it, too J -
Drone 101 – Part 1 • use AT Commands
(like to old 5mes) • calc bit-‐arrays to integers (arrrghhh!) • use a counter (to be repe55ve) Example: AT*REF=<seq>,<command><CR> in more detail-‐> next page -
basic drone commands • start the drone
AT*REF=1,290718208<CR> • land the drone AT*REF=2,290717696<CR> -
How to calc commands • a string value
(ex: the arguments of AT*CONFIG, or AT*REF) • a signed integer -‐ the sequence number • a single-‐precision IEEE-‐754 floa5ng-‐point value (aka. float). Instead, the 32-‐bit word containing the float will be considered as a 32-‐bit signed integer and printed in the AT command (an example is given below) AT*REF=1,290718208<CR> -
basic drone commands • move les AT*PCMD=3,1,-1090519040,0,0,0<CR>
• move right AT*PCMD=4,1,1056964608,0,0,0<CR> -
control the flight • use AT Commands •
calc float to 32Bit WORD to integers • Example: -‐0.8 degree pitch -‐0.8f equal BF4CCCCD equal −1085485875 • Result: AT*PCMD=2,0,−1085485875,0,0,0,0 -
bytebuffer.js • hCps://github.com/5mkurvers/byte-‐buffer Example: <script src="bytebuffer.js"></script> <script>
b = new ByteBuffer(2, ByteBuffer.BIG_ENDIAN, true) alert(b.length); var floatValue = -0.8; b.writeFloat(floatValue); b.seek(-4); alert('int:'+b.readInt()); </script> -
UDP & AR.Drone 19 1) est. wifi with
the drone (192.168.1.1) ⌘ AR.Drone 2) send CMD through UDP (Port 5556) -
UDP in a nutshell • UDP = User Datagram
Protocol • RFC 768 • based on the transport layer of ISO/OSI • it´s very fast but, • it´s very unreliable • some kind of a sister protocol to TCP more info: hCp://en.wikipedia.org/wiki/User_Datagram_Protocol -
Add UDP Module Support • Add the following to
5app.xml <modules> <module platform="iphone" version="1.1">ti.udp</module> <module platform="android" version="2.1">ti.udp</module> </modules> -
Create UDP Socket var UDP = require('ti.udp'); var socket
= UDP.createSocket(); socket.sendString({ host: 192.168.178.1, port: 4242, data: “some cool command” }); -
Building block with javascript • update the sequence number
seq=seq+1; • send a command more then once setIntervall(doCurrentCmd,30) -
demo time 24 Welcome Captain… the drone is ready
to start fasten your seatbelts take off! -
and now? • Have fun an experiment with that!
• start your 5tanium envoirment • try the CPCopter Code • look insight flightbook.js -
future plans • get into the WP8 beta –
Jeff, please! • Save the flight-‐data in ACS (Ketan looking forward to your session!) • make the camera-‐stream work (Extend Titanium.Media.VideoPlayer for PVE) • built a TitanCopter community • Keep it free – so all can have fun! -
Thank you! • Thank you Boydlee for making 5Conf!
• Thank you audience! • Thank you Appclereator for this cool tool! • for further ques5ons: – eMail: [email protected] – twiCer: @zahlenhelfer – ReaLife: meet me outside for a drink