Saturday, October 15, 2016

QuadraPi Camera with Bluetooth Controller

Bluetooth controller running motor with software PWM.  Planning to get the code for this posted to GIT soon, have had a few people ask about it.  





Wednesday, August 17, 2016

Dancing Robots!! (...again)

This is QuadraPi, which is a Pi 2B upon which I've mounted a camera with a 2-axis motor mount (I got metal gear micro towers this time because I keep wearing out the plastic-geared cheapies that you can get for like $2 each.  These cost about $10 a piece but perform a lot better and hold up over time).  

I've been playing with OpenCV (at about 8 FPS) on the pi with this camera and working on some motion tracking stuff using the motorized mount (more on that some other time).  So here it is doing some choreographed moves:

(Edit: moved video to YouTube since Blogger seems to keep losing it)







So, big deal, more scripted servo stuff.  The reason this demo is cool though is that the script is running on another computer (my laptop) and controlling the camera in near-real time.

This is the result of a project that I've had in the back of my head for some time but just recently got working.  Using some of the same network code I wrote for OliWeb, I've built a much leaner interface using just sockets and and simple TCL-inspired command language.  The project is called ControlSocket and it's now working and available out on GitHub.  

The main reason I wanted this was to allow for tighter communications and control of robo-stuff than what would be possible using web service round-trips.  Now that I've got the back end working, the next step is to tie in control elements running on my phone / tablet (steering the 2-axis camera using the phone's accelerometer, for instance, or choreographing light displays with swipe gestures, just for instance).

I have more testing to do to measure round-trip latency and response time, which of course will be network-depedent.  You can see from the video though that the choreography of the camera motion as scripted from the laptop is pretty tight.

For the client side of the solution, I just wrote a text file consisting of a bunch of motor commands and piped it through telnet.  This makes for a really easy way to do remote scripting of *whatever* on your pi project remotely.  

Pi is not really very good at PWM (arduino is much, much better for this).  One thing I've done in the past is to connect a teensy 3.1 board via serial to the pi and let it do the lifting on all the PWM stuff with simple commands coming from the pi to tell it what duty cycle to put on which pin.  That "pi-duino" approach works pretty well.  The motor control you see here is done via the gpio_pwm command line utility that I built a while ago (software PWM pulse train generation from the command line - works just fine for steering servos or what have you if you don't need ultra-precise control or continuous PWM signals going to the hardware).  I have it on the to-do list to break this out into its own project for easier inclusion in other projects, but you can find it in the OliWeb distro on Git for the time being.

More updates to follow once I've made some progress on the front end and have more razzle-dazzle to show off.

Oh, and: who's that guy next to QuadraPi?  That's flipper-bot, a teensy walker that also uses dual-servo action and is RC-controlled.  I'll post on that guy later.  


Friday, September 26, 2014

Remote Servo PiCam

I've been meaning to post this for a while now.  Here's a demo of the servo-mounted pi-cam in action:



It's a pretty standard 180-degree servo that's driven from a command-line program I wrote in C to send a PWM signal over a GPIO pin.  

I've integrated it into the web server on the pi so I can run the camera from the phone remotely, with some controls built into the snapshot page.


Right now it's nestled in next to the fish tank.  I can steer it around the living room from the phone using the included controls.  [LEFT], [RIGHT], and [CENTER] steer full left, full right, or center positions, respectively.  The arrows are for coarse and fine L/R movement.  Pretty nifty.  Here's a hard right pan looking into the fish tank (they're hiding right now).


I'm interested in playing with OpenCV to see if I can rig up some automatic tracking behaviors.  Haven't had as much time to play with the pi of late as I'd like...

Tuesday, October 1, 2013

PiCam Update

After a (4-month) detour writing a web server and playing with GPIO stuff, I have been getting back to the original project which was to make a free-standing web cam.  Last weekend I packed up the pi (complete with its whole GPIO spaghetti tangle) in a small box with the webcam and a 4400mAh cell phone battery (which, in testing, gets me about 6-8 hours of continuous use).  The photo below was taken from in the living room (my wife happened to be in the frame at the time).  




I bungeed the whole setup to the carrier on my bike, set it to record, and took it around the block.  Unfortunately the camera didn't like the sunlight and all of the outdoor footage was whitewashed.  I'm also (still) having trouble with the webcam working reliably with the unpowered USB hub and don't have a way (as of yet) to power my active USB hub remotely.  Once I get the kinks worked out I'll post the bike cam footage.

I did get it to successfully record video inside the house with the powered USB hub, but it's more stunning footage of the ceiling fan.  Truly riveting stuff - before viewing be sure to push back a few feet from the monitor and to hold on to your skull with both hands to keep your mind from being BLOWN RIGHT OUT OF YOUR HEAD.


Friday, August 23, 2013

OliWeb with PHP

After getting the CGI mechanism working with OliWeb, it wasn't that much of a stretch to add PHP support.  I've just posted updates to GitHub for the as-yet-barely-tested capability.

I already know that the CGI QUERY_STRING is not compliant (I'm sending the full request plus arguments in the env variable instead of just the stuff to the right of the '?' which is what the standard calls for).  I'm not sure whether this is going to cause problems for PHP but it will be easy enough to test out (fixing the QUERY_STRING CGI compliance has been on my to-do list for a long time anyways...).

https://github.com/m2ware/OliWeb

[UPDATE] There was really no excuse other than laziness for not fixing the QUERY_STRING to be CGI-compliant and I wanted to make sure that PHP wouldn't have any trouble with it, so I went in and fixed that.  I added a PHP script and an HTML submit form to test proper passing / parsing of arguments through the CGI interface into PHP, which appears to work just fine!

Thursday, July 18, 2013

Chirpy Pi (or - Robot Rooster)

It's been a bit since I've posted, but spent a few weeks messing around with the GPIO pins on the Pi.

I pulled Gordon's code and used it to do some "hello world" LED stuff.  After that, I spent some time figuring out how to read/write the pins in C from Gordon's examples and some others floating around the web.  

Using a couple of bipolar junction transistors I had around, an infrared LED, and the buzzer from a smoke alarm, I've turned the pi into a (very vocal) chirping light detector.  It's got the following components:


  • BJT amplifier with an IR phototransistor in the base attached to a read-mode GPIO pin
  • Shell script using Gordon's cmd-line pin reader that looks for a change in the pin state between 100ms sleeps...
  • ...which invokes a pulse train generator that I wrote in C that turns a pin off and on with programmable frequency and duration...
  • ...which pushes another BJT circuit that makes the buzzer chirp away 



The photo detector circuit is pretty sensitive so I put the whole contraption (pi+case+breadboard circuitry) in a cardboard box with a hole cut for the photo transistor to "see" out of.  With that configuration, I can point it at a window and it will chirp any time someone walks in front of it. 

I've also made a couple of longer pulse train variants that I can invoke from the web server (via CGI) remotely so I can make it chatter at the wife and kids when I'm out of town for work (I think the kids are probably more amused than my wife is...).




Wednesday, May 1, 2013

Sodding Git


I went ahead and put the OliWeb code in GIT and attached an MIT boilerplate to it.  Feel free to use if interested!  CGI parameter passing doesn't work yet (on my to-do list).  After a few minor fixes, I've gotten it running on several Linux platforms including 64-bit (Intel) Ubuntu.  If you happen to use it on another linux distro shoot me a note and let me know if there are any issues (or if it works beautifully out of the box).  

Git Page Here:

https://github.com/m2ware/OliWeb

Git location:

https://github.com/m2ware/OliWeb.git