Neural net on an Espruino

Posted on
  • I'm in the process of building a robot in the shape of K9 from Doctor Who. I'm keeping everything low cost and Creative Commons so that kids can adapt the code and follow suit should they want, here's what he looks like (inside and out):

    Key to keeping costs down is to use a Raspberry Pi as his central processing unit. To keep him responsive, though, means I need to offload as much sensor processing as I can away from the Pi. Currently I'm working on a 'follow me' capability where he follows a handheld ultrasonic transmitter using five ultrasonic sensors placed around his body.

    Now I could have programmed something myself, but I thought it would be cooler if I created and trained a neural net that executed on an Espruino. This means that just the x,y co-ordinates are transmitted to the Pi, not the sensor data.

    To do this I created an Espruino based ground truth collector that is described in this post.

    The collected data was then used to create and train a feed forward neural net using the Synaptic.JS library in a JSFiddle environment. The library then generated a standalone JavaScript function that would run on the Espruino. That allowed me to do both the sensor collection and neural net execution on a single device as described in this post.

    Yes it even works!

    If you want more, this post describes another experiment with ultrasonics and Fast Fourier Transforms. These experiences have convinced me The Espruino is a brilliant bit of hardware with a wonderful IDE!

    Cheers
    Richard

  • That's awesome! I love the K9 dog - with all the laser cut and 3D printed stuff now it seems rare to see some nice aluminium brackets, big motors and lead acid batteries :)

    The idea of pre-training a neural net and then running that is really clever though. I didn't realise anything like Synapic.js existed. It's seems like a fantastic tool if you've got the right problem (like your sensors!).

  • Thanks Gordon, rather embarrassingly I just realised that I used digitalRead rather than analogRead to interface to the ultrasonic sensors, so the neural net was only being trained with 2^5 (i.e. 32) possible values from [0,0,0,0,0] to [1,1,1,1,1]! Later this week I will retrain the net with analogRead data and I suspect it will be much more accurate. The fact it worked at all shows just how powerful neural nets are - and how good Espruino's are for building robots!

    Cheers
    Richard

  • Did I see this at Derby Maker faire last weekend? :)

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Neural net on an Espruino

Posted by Avatar for hopkira @hopkira

Actions