Sample Arm Control Code for Mac OSX (C++)

I picked up a very cool AL5C robotic arm for my son and I to work on for x-mas and only had a Macbook to play with it from. I searched for some Mac OS-X software, but didn’t find any. I put together a couple C++ classes “RobotArm” and “SerialPortIo” tonight which control the arm, and an example command line app. I thought this may be very valuable for anyone else wanting to play with the arm on a Mac. I also picked up the USB to serial converter from LynxMotion with my kit as well. My program works well with this (you will need to install the VCP driver from here: ftdichip.com/Drivers/VCP.htm – the uri linked to on the LynxMotion web site is for Windows only).

I have not added IK, or some more advanced features (yet) - but it should still be a great base for those looking. It compiles using Apple’s xcode tools (free, from Apple’s website, and on the second disk of your OS install). The compiled binary in my zip is for Snow Leopard.

To use the class (as in my example main.cpp), just instantiate a copy of it and initialize it with the name of your serial port, something like:

RobotArm arm;
arm.initialize("/dev/tty.modem");

Then, set the positions of the servos you want as a percentage from 0-100 and call “move”. It will move all of the servos at one time, ie:

arm.setBaseRotation( 0 );
arm.setShoulderPosition( 40 );
arm.setElbowPosition( 20 );
arm.setFingerPosition( 0 );
arm.setWristPosition( 0 );
arm.move();

This code should also work under Linux and BSD with little or no modifications.

To compile the code simply run the command “make” in the directory of the code. (ie. open the terminal application, type in “cd ~/Documents/robotarmcontroller”, then type in “make”). This code assumes you have the jumper set on your SSC-32 to “9600 baud”. Follow the SSC-32 manual to get the right jumpers for this (0 1 on mine).
robotarmcontrol.zip (8.63 KB)

This is very cool! Thanks for making this available! I made it a sticky for you. :smiley: