CM-510 firmware and post updated
CM-900 is really tiny and cheap, so is perfect to use as communication bridge between any computer (Raspberry Pi, Pandaboard, etc. included, of course) and the Dynamixel bus. Whatever it receives from the Serial USB (usually commands and queries) is sent to the Dynamixel bus, and what it receives from the Dynamixel bus is sent to the SerialUSB (usually answers)
Here is the source code of the little program for CM-900 IDE:
int counter; bool onlyOnceHappened; void blinkOnce() { digitalWrite(BOARD_LED_PIN, LOW); delay_us(100); digitalWrite(BOARD_LED_PIN, HIGH); } void setup() { pinMode(BOARD_LED_PIN, OUTPUT); onlyOnceHappened=false; counter=0; //USB Serial initialize SerialUSB.begin(); // SerialUSB.attachInterrupt(USBDataReceived); //DXL initialize Dxl.begin(1); } byte aByte=0; uint8 aUint8; void loop() { // SerialUSB.println (counter++); if (onlyOnceHappened==false) { blinkOnce(); onlyOnceHappened=true; delay (3000); //Some time to the user to activate the monitor/console SerialUSB.println ("v1.1.1 Orders receiver started"); } if (SerialUSB.available()) { aUint8=SerialUSB.read(); blinkOnce(); Dxl.writeRaw(aUint8); // delay(20); } if (Dxl.available()) { aByte=Dxl.readRaw(); blinkOnce(); SerialUSB.write(aByte); // delay(20); } }
In the next post I will include an improved version that could read sensors connected to the CM-900, “expanding” the Dynamixel protocol.
[V.02 updates: AX C++ architecture, core classes diagram and HexaWheels scanning video]
C++, specially with the great improvements of the last C++11 standard, joins together a great efficiency in performance and a low memory footprint with advanced high level language features, making C++ a great tool for embedding, robotics, programming.
If you want to know how to use C++ very efficiently these two guides will help you:
– The JSF air vehicle C++ coding standards ( F-35 fighter aircraft)
– ISO C++ committee’s report on performance
.
.
Bioloid Premium is a wonderful kit for creating legged and wheeled robots, including (here full parts list):
– 18 powerful and versatile AX-12 servos
– an ATMega 2561 (CM-510) or, recently, an ARM STM32F103RE 32bits (CM-530), based controller. Also you can control the AX-12 with the USB2Dynamixel straight from your USB with a FTDI driver.
– And a lot of parts to create the structure of the robot
.
Raspberry Pi is the cheaper and more brilliant conceived SBC (more specifications here):
– Broadcom BCM2835 SoC full HD multimedia applications processor
– 700 MHz Low Power ARM1176JZ-F Applications Processor
– Dual Core VideoCore IV® Multimedia Co-Processor
– 256/512 MB SDRAM
One simple example:
C++ is a very powerful but complex programming language, so I think that the better approach is to start step by step, from the most easy features (yes, C++ could be used in an easy way) to the most advanced features it offers. What is C++? I will quote (I try to not explain anything that already is explained), Stroustrup, “his father”, from his book The C++ programming language 3th Edition:
“C++ is a general-purpose programming language with a bias towards systems programming that
– is a better C,
– supports data abstraction,
– supports object-oriented programming, and
– supports generic programming.”
And wikipedia:
C++ (pronounced “see plus plus”) is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features.[3] Developed by Bjarne Stroustrup starting in 1979 at Bell Labs, it adds object oriented features, such as classes, and other enhancements to the C programming language.
If you want more C++ links, these found at JUCE will help you.
Free books and documents:
– Maintain stability and compatibility with C++98 and possibly with C;
– Improve C++ to facilitate systems and library design, rather than to introduce new features useful only to specific applications;
– Increase type safety by providing safer alternatives to earlier unsafe techniques;
– Increase performance and the ability to work directly with hardware
Books:
Advancing:
In robotics, and embedded programming in general, we will need some advanced knowledge and practices to reach our goals.
Free books and documents:
Books:
Well, this is really the goal, robotics programming.
As this is a workshop it will follow the creation of the the walker and vehicle Hexapod showed above in the video. This is currently the core architecture and the HexaWheels module (namespace classes):
And these are the core classes:
The workshop will include:
– Basics
Like communications with serial port and wireless, using Dynamixels, sensors, … Language features for robotics, like asynchronous communications and threads and… delays!.
– Intermediate
Combination of basics features using sensors (like scanning) and servos (walking motions). For example, scanning with a DMS sensor:
As a simple example:
– Advanced
Advanced perception and behaviours
I think this could very funny, using an advanced sensor like Asus Xtion, to detect certain objects to interact, and create configurable and amusing behaviours.
CM-510 mirocontroller programming
– Tools:
PC, Raspberry Pi and Pandaboard, installation and configuration, tool and projects
– GNU C++, Boost
– Eclipse
– QT 5
The contents will come soon, very soon…
[Next post: Dynamixel communications with C#]
It would be a workshop using C# .Net and C++ with Qt 5. The code presented here is used in this two different robots and boards, a HP 214 Ipaq with Windows Mobile and a Raspberry Pi, using the Robotis CM-510 as the servo and sensors controller:
These will be the first steps, using C# and .Net , here the code and the exe for the Workbench UI:
Using this enhaced Toss Mode that adds some new functions. Some of them:
Lego Mindstorms NXT is a great kit that allow you to build and program an almost unlimited variety of robots and automatisms.
The kit includes a “brick” that includes a programmable 32 bits microcontroller. Lego open sourced the software and the hardware of NXT, here you can find all the documents and source code.
You can program its microcontroller with the included visual programming tool, called NXT-G, that is very easy to use for small programs but probably you will find it too much limited, specially if you can program in other programming language. But don’t worry, you can use standard and professional programming languages like Java, C or C++ among others. All them free as in beer and as in speech.
Just a few words about which, in my opinion, are the best options:
Apart from NXT-G the easiest way for programming NXT is NXC. It’s a language similar to C, very easy to learn and you don’t should change the NXT Lego firmware, so you can continue using NXT-G.
If you know or want to learn Java this is your tool. I think that is the best tool, more difficult that NXC but far more powerful.
Do you want to learn C or C++? Real time programming? This is your tool!
There are a lot of possible combinations of hardware, firmware and languages for programming Bioloid. I think that the table below show the the main combinations.
You can choose from the easy but limited Robotis own tool (Roboplus Task) and only your CM-5 or CM-510 to a SBC or “embedded” PC like Roboard and any language which can manage a serial port connection, like C, C++, Java, Python,…
Linux C++ Dynamixel reading and writing example
C# Dynamixel reading and writing example
Practical C++ programming tutorial for Bioloid
Robotis officially supports the programming solutions with the blue background:
With these programming solutions you can use the Zigbee SDK to send and receive data between the CM5-/CM-510 and any computer, using Zig-110A or the new bluetooth BT-110, the Zig2Serial and the USB2Dynamixel. You can download example in Visual Basic .Net, C# and Visual C++
But there are more options!
Using a PC, SBC (Single Board Computer), PDA, Mobile or other light and battery powered computer
Using a serial port connection with your more beloved programming language:
If you have any device with a USB host and a FTDI driver you can use USB2Dynamixel to command programatically your Dynamixel servos using the Dynamixel protocol. You only will need your CM-5 or CM-510 to connect your Dynamixel to the battery.
Same as the previous option but instead of using the USB2Dynamixel you only will need the serial cable and the “Toss Mode” launched with the ‘t’ command from the “Manage Mode”
Instead of only sending and receiving data, with the previous wireless connections you can command remotely your robot using the standard firmware and the “Toss Mode” launched with the ‘t’ command from the “Manage Mode”. You will need to command it using the Dynamixel protocol.
With these options and the CM-510 you will find a little problem… there is no way to read your sensor values! Well, you can use this firmware that offers a “Toss Mode” that supports reading CM-510 ports.
Start learning!
If you want to start learning how to program your CM-5 or CM-510 controller you will find interesting this post “Start programming CM-5/CM-510 in C“. But may be you prefer to control your robot from a PC, SBC or other computer in C++ or C#