PDA

View Full Version : [Question(s)] Arbotix-M sketch for dynamixel AX-12A's



ABB
03-02-2014, 09:48 PM
New to robotics - I have two AX-12A servos set up as 1 & 2 and an Arbotix-M board. I would like a simple sketch that uses one servo as the master and the other to duplicate the motion of the first. I would be moving servo 1 by hand and would like servo 2 to duplicate the movements, similar to this youtube video: http://www.youtube.com/watch?v=u7nNgsW1_No Any ideas?

tician
03-02-2014, 10:07 PM
Untested, but should be close.


#include <ax12.h>

#define MASTER_SERVO 1
#define SLAVE_SERVO 2

void setup()
{
// setup the arbotix's dynamixel library
ax12Init(1000000);
// turn off torque of the master servo so that we can move it around
Relax(MASTER_SERVO);
}

void loop()
{
while (1)
{
// get position of master servo
int posit = GetPosition(MASTER_SERVO);
// set position of slave servo
SetPosition(SLAVE_SERVO, posit);
// delay a bit so we do not swamp servos with packets
delay(50);
}
}

ABB
03-03-2014, 05:33 AM
Thank you very much, exactly what I needed! Dynamixels are great!