PDA

View Full Version : [Project] C# Dynamixel Project



MikeG
01-11-2010, 08:55 AM
I spent most of my weekend polishing up a C# Dynamixel project. The source files are available at http://www.agaverobotics.com/services/dotnet/Dynamixel/default.aspx

Each Dynamixel instruction is class. For me, that makes things easier to deal with. I gave the SyncWrite instruction special attention. Each of the SyncWrite sub-instructions are handled as a collection. That allows you to create one instance of the SyncWritBuilder and swap out instructions.

Here's a snippet of my unit test code. The actual source is heavily commented.


SyncWriteBuilder swb = new SyncWriteBuilder(ControlTable.GoalPosition);
byte[] buff;

swb.AddParameter(new SyncWriteParameter(1, ControlTable.GoalPosition, 256));
swb.AddParameter(new SyncWriteParameter(2, ControlTable.GoalPosition, 512));

buff = swb.ToByteArray();
WriteToInstructionTextbox(buff);
sPort.Write(buff, 0, buff.Length);
Thread.Sleep(1000);

swb.ClearAllParameters();

swb.AddParameter(1, 512);
swb.AddParameter(2, 256);

buff = swb.ToByteArray();
WriteToInstructionTextbox(buff);
sPort.Write(buff, 0, buff.Length);
Thread.Sleep(1000);

swb.RemoveParameterAt(0);
int index = swb.ParameterIndexOfId(2);
swb.RemoveParameterAt(index);

swb.AddParameter(1, 256);
swb.AddParameter(2, 512);
buff = swb.ToByteArray();
WriteToInstructionTextbox(buff);
sPort.Write(buff, 0, buff.Length);
Thread.Sleep(1000);

swb.ClearAllParameters();

swb.AddParameter(1, 512);
swb.AddParameter(2, 256);

buff = swb.ToByteArray();
WriteToInstructionTextbox(buff);
sPort.Write(buff, 0, buff.Length);
The status packet class is designed to be used in conjunction with a buffer. The object can parse a byte array and frame up the status packets within. Subscribers can handle the status packet as they wish.

There's also a help file that describes the objects.

I have more work planned but thought I would go ahead and throw this out there for any .NET folks that might be interested.

nagmier
01-11-2010, 03:59 PM
nice I love the work fergs has done with python but I can't seem to get my head wrapped around it (admittedly I don't have alot of time to devote) I find C# easier to follow... Any ways I hope this project stays well I have a bioloid coming in the near future.

Adam
01-11-2010, 04:20 PM
FYI - There is already a C# Dynamixel project available from Forest Moon Productions.

MikeG
01-11-2010, 04:45 PM
Yep Scott' s C# project (Forest Moon Productions) is awesome. I wanted to write one that worked a little differently. The idea is to have the Dynamixel objects listen to the instruction packets just like the physical Dynamixel network. Besides there can be more than one Dynamixel C# project.

Adam
01-11-2010, 05:38 PM
Sure, you can never have too much Dynamixel code. :veryhappy:

DresnerRobotics
01-12-2010, 01:07 PM
Yep Scott' s C# project (Forest Moon Productions) is awesome. I wanted to write one that worked a little differently. The idea is to have the Dynamixel objects listen to the instruction packets just like the physical Dynamixel network. Besides there can be more than one Dynamixel C# project.

I actually am liking how this project is structured a bit more than the Forest Moon Project. Having spent significant time playing with Scott's code, I find it a bit convoluted... this might be easier to grasp.

And yes, can never have too many Dynamixel code projects, it's a great technology and I love seeing more people involved and contributing!

MikeG
01-12-2010, 08:21 PM
Thanks Tyberius,

I hope to have more code released this weekend. I'm wiring up the Dynamixel control tables right now.