Saturday, November 22, 2014

Syma X1 Camera Mount



I think the Syma X1 is about the best fun for the money in RC, ever. It's indestructible, flies well indoors or outdoors in calm air, is agile and fun to fly. It costs $30 or so on Amazon. I love it.

I tried a couple different ways of mounting a camera under it. The main challenge with this is to get it securely attached, since there is an oddly shaped battery assembly below the main platform. It has to be very light, since the quad doesn't have a lot of cargo capacity.

 This is the best I've come up with so far - it uses HobbyKing vibration mounts and some 3D printed parts. I printed them in ABS for light weight and a bit of flexibility, and I recommend that if you try it. The printed ring fits snugly around the circular frame that the control board electronics sit on and is attached with a couple zip ties. I had to slightly drill out the two unused screw holes in the circular frame.




I used an older 808 camera, which it lifts fine. There might be light enough FPV gear out there now, I'm not sure. There is still some vibration in the video - I'll probably try a little foam between the camera and platform to see if I can get rid of that. It's a fairly low frequency, since it's not causing "jello" (rolling shutter).

STL files hosted on Thingiverse here

Friday, November 14, 2014

Bare-bones HTTP Image Server in Python

I'm looking at what it would take to integrate the IP camera functionality used by my rover into the main control code, rather than using a separate app to serve up the JPG frames from the camera I've never written a web server before, so I put together a very simple program in Python to figure out the mechanics of sending a JPG file to a requesting HTTP client. It looks like it would be pretty simple to add to the robot code, since the camera callback returns the JPG as a byte array.

This code listens on a socket for an HTTP request - any HTTP request - and completely neglects to check or sanitize the input. It then serves an image back. It works for testing and understanding how things work down at the socket level, and is absolutely unfit for any other purpose. :-)

Tested in Chrome and IE.


#!/usr/bin/env python

import socket

host = ''
port = 8080
backlog = 5
size = 8096

# Read the entire file as a single byte string
with open('test.jpg', 'rb') as f:
    reply = f.read()

while 1:
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

        s.bind((host,port))
        s.listen(backlog)

        client, address = s.accept()
        print "Got client connection"
        clientReq = client.recv(size)
        print clientReq


        replyLength = len(reply)
        headers = "HTTP/1.x 200 OK\r\n"
        headers = headers + "Content-Length: " + str(replyLength) + "\r\n"
        headers = headers + "Connection: Keep-Alive\r\n"
        headers = headers + "\r\n"

        client.send(headers + reply)
        s.shutdown(1)
        s.close()