- Written by Kyle Granat
Well, it's been a while, but I'm back! I've had a few developments since my last blog (including new bots, a new 3D printer) but today I want to show off the next version of DynaPose.
Last year I wrote some super basic scripts that would allow you to pose an arm in discrete positions. It's handy, but a little clunky. Lat week, after seeing one of SparkFun's Video for the uArm I was inspired to make a real-time DynaPose.
The basic idea is that instead of hitting a button to record each pose, you simply move the arm to the positions you want it to go to and the ArbotiX Microcontroller automatically records positions on a timer. The upside is that the arm will playback in the same fashion that you pose it. However, this is fairly memory intensive, eating up the ArbotiX's precious SRAM.
How intensive is it? Well that depends on your number of servos and your read rate! So let's do the math. The atmega644p on the ArbotiX has 4k of SRAM. We'd have to do some digging to figure out the overhead of our default variables and the DYNAMIXEL and serial libraries, but let's just say that 3.5K was free - or 3584 bytes. Let's also target the PhantomX Pincher which has 5 servos. 3584 bytes / 5 servos gives us 716 bytes per servo. Now AX dynamixels have 10-bit positional encoders, so we're going to have to store the positional data in a 2-byte integer, so 716 / 2 gives us a total of 358 positions.
Now you've got to decide how long you want to stretch those positions. For butter smooth recording and movements, you want somewhere around 50ms between reads. and 50ms * 358 positions gives you 17,900 milliseconds, or 17.9 seconds of pose time - not a whole lot. i've found that 100ms (10 reads per second) works fairly smoothly and doubles your time to 35.8 seconds. If you don't mind some jerkiness, you could go up to 500ms for 179 seconds! But you're also bound to miss some positional data.
now of course there's ways to expand your memory. You've got another 1k of EEPROM, or you can use an external EEPROM module or other memory module. I'm also looking into using an SD card logger to handle the data and make it easy to get to your computer.
Or you could ditch the ATMega 644p for a Teensy 3.2 with 64k of ram - with that much ram you could pose a 20-servo HR-OS1 at 20hz for 161 seconds!
The code can be found here as part of the before mentioned repository. The code is a work in progress and needs some tweaking before using other robots, so drop me a line before you use it. You'll need 2 buttons (record on DIO3, play on DIO4), a buzzer on DIO2 and an analog sensor on A0 if you want to manually control a gripper.
SERVOCOUNT defines your number of servos and
READ_INTERVAL is that timed interval I mentioned before.
Here are some things I'm working on to make it ready for general consumption:
- Better gripper options for other arms
- Locking/unlocking options
- Removing duplicate pose data (but possibly recording pause data and allowing for a headband of the 'same' pose)
And some things I'm pondering for the future
- Bit-shifting to use even more memory
- Low resolution option (double your pose time)
- EEPROM writes
- SD card writes