miércoles, 23 de noviembre de 2011

Practical C++ programming tutorial for Bioloid robots

This is the main block of a simple Dynamixel example program using serial port.

Do you want to use the usb2dybnamixel? Changing it will be very easy. Here you can find several combinations of hardware, firmware and programming tools.

Here the Visual Studio C++ zipped project. And if you use this firmware you also can query sensor port values with this example:



[sourcecode language="cpp"]
#include "stdio.h"
#include "Dynamixel.h"
#include "SerialPort.h"

int _tmain(int argc, _TCHAR* argv[])
{
int error=0;
int idAX12=17;

SerialPort serialPort;
Dynamixel dynamixel;

if (serialPort.connect(L"COM1")==0) {
dynamixel.sendTossModeCommand(&serialPort);

int pos=dynamixel.getPosition(&serialPort, idAX12);

if (pos>248 && pos <1023)
dynamixel.setPosition(&serialPort, idAX12, pos-100);
else
printf ("nPosition <%i> under 248 or over 1023", pos);

serialPort.disconnect();
}
else {
printf ("nCan't open serial port");
error=-1;
}

return error;
}
[/sourcecode]

Let's start using the serial port:

Windows:

  1. Simple C++ class example using serial port  and  Windows and Linux communications programming then

  2. Reading Dynamixel AX-12+ position, and finally

  3. Writing Dynamixel AX-12+ position.


Linux:

  1. Linux example


If you want to learn C++ these wonderfuls links (found at JUCE) will help you:

No hay comentarios:

Publicar un comentario