miércoles, 23 de noviembre de 2011

Reading Dynamixel AX-12+ position

The intent of this code is to be clear and easy to understand, it not pretend to be the best code to do the job.

This method create the command to read the AX-12+ position :

[sourcecode language="cpp"]
int Dynamixel::getReadAX12PositionCommand(byte id)
{
//OXFF 0XFF ID LENGTH INSTRUCTION PARAMETER1 …PARAMETER N CHECK SUM
int pos = 0;

buffer[pos++] = 0xff;
buffer[pos++] = 0xff;
buffer[pos++] = id;

// length = 4
buffer[pos++] = 4; //placeholder

//the instruction, read => 2
buffer[pos++] = 2;

// pos registers 36 and 37
buffer[pos++] = 36;

//bytes to read
buffer[pos++] = 2;

byte checksum = checkSumatory(buffer, pos);
buffer[pos++] = checksum;

return pos;
}

int Dynamixel::getPosition(SerialPort *serialPort, int idAX12)
{
int ret=0;

int n=getReadAX12PositionCommand(idAX12);
long l=serialPort->sendArray(buffer,n);
Sleep(2);

memset(bufferIn,0,BufferSize);
n=serialPort->getArray(bufferIn, 8);

short pos = -1;
if (n>7)
{
pos = fromHexHLConversion(bufferIn[5], bufferIn[6]);
}

printf("nid=<%i> pos=<%i> length=<%i>n", idAX12, pos, n);
if (pos<0 || pos > 1023)
ret=-2;
else
ret=pos;

return ret;
}
[/sourcecode]

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:

martes, 22 de noviembre de 2011

Software souls

Everybody has dreams that makes him wake up full of energy and  motivation. We born with it or may be it grows up inside us. Mine is software for personal robotics. Software that blows live, a personality, to your robotics creatures.

ROS (Robot Operating System)

ROS (Robot Operating System)

Fawkes robotics framework

Fawkes robotics framework

Fire station

AntOne 3.5 Robotis Bioloid hexapod

AntOne is a project which goal is create interesting and simple behaviours to an hexapod using the Bioloid Premium kit and programmed using C#

NXT Acer Explorer

NXT Acer Explorer

Lego Mindstorms NXT

Lego Mindstorms NXT

Robotis Bioloid

Robotis Bioloid are several modular kits that lets you create "legged" or "wheeled" creatures

Aldebaran NAO


New NAO!, click here to read the specifications


[caption id="attachment_190" align="aligncenter" width="430" caption="New NAO 2011 Schema"]New NAO 2011 Schema[/caption]

Datasheets:
[embed]http://www.softwaresouls.com/NAO/Datasheets_H21H25_NAO_Next_Gen_EN.pdf[/embed]

[youtube http://www.youtube.com/watch?v=Vtl1H9H4KZY?rel=0]

Main features:
[embed]http://www.softwaresouls.com/NAO/NextGen-About.pdf[/embed]

Motherboard:
[embed]http://www.softwaresouls.com/NAO/NextGen-Motherboard.pdf[/embed]

Vision:
[embed]http://www.softwaresouls.com/NAO/NextGen-Vision.pdf[/embed]

Audio:
[embed]http://www.softwaresouls.com/NAO/NextGen-Audio.pdf[/embed]

Languages:
[embed]http://www.softwaresouls.com/NAO/NextGen-Languages.pdf[/embed]

CPU:
[embed]http://www.softwaresouls.com/NAO/NAO-NextGen-CPU.pdf[/embed]

Camera:
[embed]http://www.softwaresouls.com/NAO/NAO-NextGen-CAM.pdf[/embed]

View:
[embed]http://www.softwaresouls.com/NAO/NAO-NextGen-View.pdf[/embed]

Head:
[embed]http://www.softwaresouls.com/NAO/NAO-NextGen-Head.pdf[/embed]

Aldebaran main features

Robotis Darwin-OP

Robotis Darwin-OP is the advanced humanoid platform from Robotis

CM-5: Creating a simple "Hello World" C program

This post try to explain how to compile, load in the CM-5 (transmit) and execute a C program (a servo version of the "Hello World" classic example).

What do you need?


(You can find here how to start programming CM-5 / CM-510)

Obviously, some Bioloid hardware:


- The CM-5


- The battery or power source


- The serial cable


- An AX-12


- A cable to connect the AX-12 with the ID 17 to the CM-5. You can change the ID in the program.



What should you do?


1. Download and install the software:


1.- Download and install the Robotis RoboPlus software.


2.- Download and install WinAVR


3.- Download a Hello World example for WinAVR.


The C “Hello World” servo program is based in the original Robotis example.


4.- You should create a folder for your CM-5 program, for example c:myprojectscm5helloworld Copy there the previously downloaded helloworld.zip and unzip it.



2. Compile and link the program


1. Execute WinAVR and open the unzipped project:


( Bioloid User's Guide.pdf could help you using WinAVR)




You should change the ID 17 of the servo for the ID of the servo you are using



2.- Compile and link. Make all:



3.- You should see “Errors: none”



4.- Transmit and execute the helloworld.hex to the CM-5


( Here you can find more info )



Well, if you only want to test the executable, you can download only the hex.


When loaded you should see an screen with two equal values as a correct "Checksum" check (in this example the value is 81, it's calculated from the source code). If the values are not equal there is an error in the transmission.


CM5HexLoaded


5.- Every time you press the red MODE button the servo should spin


CM-510 as a multiple sensor dynamixel item (updated 7/11/13)

[UPDATE 7/11/13: CM_510 TossModeJCA updated to v5.8. Several parameters error fix and somewhat faster]

My main Bioloid project is to build a robot that will have some interesting (non easily predictable but reasonable) behaviours. AntOne 3.6 is the last version:

AntOne 3.6 is based on a PDA that has the software for the behaviour and a CM-510 (ATMega 2561) that control the hardware (servos and sensors). But I discovered that standard CM-510 firmware has no command to get sensor values, so I programmed another with that function. But then I thought that it would be interesting to embed some perception functions in the CM-510.

This is a general diagrama:

[caption id="attachment_47" align="alignnone" width="547"]Single controller Single controller[/caption]

Updated 23/2/2013

The new hex file v4.3 (the old CM-510 firmware)

Now it supports new functions, as:

- Toss Mode (up) now can read from Dynamixel and write to serial and, as the previous version, read from serial and write to Dynamixel, it allows to....
- receive from zigbee and send the data to the Dynamixel button
- read raw sensor values
- averaged sensor values when F_SET_SENSOR_VALUES_TO_FILTER is set < 5, not including the min and the max when >= 5
- CM-510 beep
- sensor scan (still in development)

[sourcecode language="c"]
#define F_NO_FUNCTION 0
#define F_GET_SENSOR_VALUE_RAW 1
#define F_GET_TWO_DMS_SENSOR_VALUES 2
#define F_GET_MULTIPLE_SENSOR_VALUE 3
#define F_GET_SENSOR_VALUE_FILTERED 4
#define F_SET_SENSOR_VALUES_TO_FILTER 5

#define F_BEEP 8
#define F_DO_SENSOR_SCAN 9
#define F_SET_VALUE_DMS1 11
#define F_SET_VALUE_DMS2 12
[/sourcecode]

C# example os use:

[sourcecode language="csharp"]
private void B_ReadPort_Click(object sender, EventArgs e)
{
byte function = (byte)NUD_Function.Value;
byte portId = (byte)NUD_Port.Value;

if (portId < 0 || portId > 6)
portId = 1;

string strPortId=portId.ToString();

if (function == 1 || function == 4)
{
short portValue = cm510.getSensorValue(function, portId);
string str = portValue.ToString();

TB_PortValue.Text = str;
}
else
{
if (function == 2)
{
byte[] parameters = new byte[3];
parameters[0] = function;
parameters[1] = Convert.ToByte(TB_DMS1_ID.Text);
parameters[2] = Convert.ToByte(TB_DMS2_ID.Text);

short[] values = new short[3];
cm510.getMultipleSensorValue(parameters, values);
//cm510.getTwoSensorValue(function, Convert.ToByte(TB_DMS1_ID.Text), Convert.ToByte(TB_DMS2_ID.Text), values);

if (values.Length >= 2)
{
TB_DMS1_PortValue.Text = values[1].ToString();
TB_DMS2_PortValue.Text = values[2].ToString();
}
}
else
{
if (function == 3)
{
byte[] parameters = new byte[3];
parameters[0] = function;
parameters[1] = Convert.ToByte(TB_DMS1_ID.Text);
parameters[2] = Convert.ToByte(TB_DMS2_ID.Text);

short[] values = new short[3];
cm510.getMultipleSensorValue(parameters, values);

if (values.Length >= 2)
{
TB_DMS1_PortValue.Text = values[1].ToString();
TB_DMS2_PortValue.Text = values[2].ToString();
}
}
else
{
if (function == 11)
{
TB_DMS1_ID.Text = strPortId;
}
else
{
if (function == 12)
{
TB_DMS2_ID.Text = strPortId;
}
}
}
}
}
}

[/sourcecode]

Start programming CM-5/CM-510 in C (AVR microcontrollers)

From time to time I receive questions about how to start programming the CM-5/CM-510 with C.

[This post is also in spanish]

I think it’s necessary to have a working knowledge about:

1. C programming

2. CM-5/CM-510 programming

3. Dynamixel protocol

You can find  a lot of information about CM-510 / CM-700  programming at Robotis support website And here you can learn how to create a simple "Hello World" program for CM-5

1. C programming

I think “C Programming for Microcontrollers is a fast and very practical introduction to C and microcontrolers programming, but I’m a not sure if it an easy way to start learning C.If you a want a more structured and deeper introduction to the C programming language, this is a pretty good and free introduction:


C introduction (pdf)


But there are a lot…


C Language Tutorial (html)
How C Programming Works (html)
Several C programming tutorials (html)


and more from Google


2. CM-5/CM-510 programming

From Robotis support website CM-5/CM-510 programming


3. Dynamixel protocol

From Robotis support website Dynamixel actuator


4. Your first step

If you use a CM-510 you will find here at Robotis support site a lot of information, and if you use the CM-5 you will find in this post some useful information and links


Two others great sources of information are:

Robosavvy Bioloid information wiki


Source code of Stuart&Matt library

lunes, 21 de noviembre de 2011

Hello world!

Welcome to WordPress.com. After you read this, you should delete and write your own post, with a new title above. Or hit Add New on the left (of the admin dashboard) to start a fresh post.

Here are some suggestions for your first post.

  1. You can find new ideas for what to blog about by reading the Daily Post.

  2. Add PressThis to your browser. It creates a new blog post for you about any interesting  page you read on the web.

  3. Make some changes to this page, and then hit preview on the right. You can always preview any post or edit it before you share it to the world.