Monday 3 February 2014

Scripting with SL4A (for fun and profit)

From the outset, I'd intended to put my software development skills to use in creating an application capable of providing real-time tracking and telemetry , imagery and data logging, as well as payload recovery.  Aside from the requisite Java, I've got extremely limited experience with Android development, making for a very steep learning curve.

Enter SL4A: Scripting Layer for Android.  From their website: "SL4A brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device."  I originally came across SL4A when looking at similar projects. and found one that had used SL4A for this very purpose over on James Devine's Blog.

After weighing up the options, I've decided that Python and SL4A will be the way to go - the learning curve is significantly gentler and the code far simpler, which will subsequently lead to shorter development and testing times, culminating in a more rapid development cycle.  As an added bonus, SL4A has support built into Tasker, which in its simplest form is a powerful task-scheduler for Android which can be used to launch scripts based on various user-defined triggers.

I'm hoping to keep the script relatively simple, while incorporating the following features:

  • Data logging:  Coordinates, altitude, speed and total distance tracked
  • Battery data logging:  Charging status, battery level, health and temperature
  • Signal strength logging:  Cell signal strength including network type (2G/3G)
  • Real-time telemetry:  Location tracking via SMS and email (with altitude-dependent update frequency)
  • Real-time imagery:  Transmission of images captured through phone camera via email
  • KML output:  3D output of balloon flight path (with error correction and visual signal strength indication)

I've been playing around with SL4A for a few weeks now, and have been thrilled with the results.  Most variables are being successfully logged in CSV format, altitude-dependent SMS tracking is working, and most impressively, KML output is fully functional, as tested on a recent trip in the Dandenongs:


There's still a long way to go - some basic filtering of erroneous values need to be applied to the GPS coordinates when the signal is weak; while this is unlikely to be an issue, there's no way to be certain until the payload has completed its voyage.  I've also done some basic proof-of-concept work with image capture and transmission, but this will require some fine-tuning before being ready for go-live.

I'll need to perform extensive testing once scripting is finished - then I'll post the code for all to see (and use at your own risk!)

No comments:

Post a Comment