Saturday, February 8, 2014

Quickie Updates!

I've had a busy month with a few big wins. In rough chronological order they are the completion of a workable DIY steering servo software package, the design of numerous parts in OpenSCAD (because I have a 3D printer on order) and a whole whack of Go software written. Some details:

The Steering Servos

It was a bit harder than I thought to write the code for a simple servo. I think when I imagined it I had assumed the weight of the rover would tend to dampen the motion to a point where 'porpoising' - an unwanted oscillation around the desired position - would not be a problem. But to counteract the dampening I had to drive the motors at 100% power until very near the desired point, which tends to create overshoots... which tends to set up an oscillation.

What I ended up doing was creating two kinds of drive through the L293D; one is a simple on/off at 100% power when the requested angle is different enough from the current angle, and a pulsed power level related to the angular difference when more accuracy is needed. I also added a bit of a power booster to overcome stalls when the power level is too low to cause motion due to small obstacles or surface friction.

3D Printed Parts

I needed several parts that work with the Servocity/Actobotics aluminum channel; everything from the steering & feedback assembly to simple covers for the pan/tilt sensors. My best guess as to how I might assemble these things from their standard catalog meant a TON of redesign time, and in most cases too much added weight for the job at hand. In most cases, especially for gears, it was simpler to create multifunction elements in OpenSCAD.

After the usual amount of research I decided to order a printer. That was 3 weeks ago, and I don't think it's shipped yet. Not happy... the site says 1-2 weeks delay, and they indicated in an email that it should ship last week, but nope, nada, zilch. The company I've ordered from has (apparently) really good post-purchase support so I'm willing to wait, but if I don't see it shipped by the end of the week I'll have to cancel the order and look elsewhere. Time is getting pretty short, so I may have to go with a pre-assembled unit that costs twice as much to make up for the lost time.

Go, Go, Go...

I think I've raved before about concurrency in Go before, but I've found another nifty thing about it - interfaces. When you consider you can, for example, collect variables into a slice (a slice is like an array) and then call the same method name on them, with each type having it's own method implementation, things get interesting in a good way. One application I found was that I wanted to create command sequences, basically lists of commands, and it only took a few hours to create a json reader for sequence files, then simply calling the Run() method on each one in sequence (or concurrently :)

Another less glamorous thing I got around to is understanding multiple source files and the package system. Being able to limit the editing to a particular file once it's done is huge. I can't count the number of times I've introduced bugs (or 'features'...) as a result of well meant cleanups.

I also did a fun little toy program to see if it was reasonable to represent a least-cost routing map as a series of go-routines that distribute routes via channels. It works, but my first stab at it is about 10x slower than a non-concurrent version, and takes about 100x the memory. I'm sure it could be made more efficient, but I had to move on. So the routing system will stay with a more traditional implementation.

That's it for now; hopefully I'll have something with some pretty pictures next time!

No comments:

Post a Comment