ISR Bioloid Humanoid

From ISRWiki
Jump to navigation Jump to search

Characteristics

The Bioloid Kit features a CM-5 controller, Dynamixel AX-12+ servos and a Dynamixel AX-S1 distance sensor. The CM-5 is connected to the servos and sensors using a bus connecting all devices through a daisy-chain network. It can also be connected to a computer using a serial connection, giving access to many different ways of dealing with the robot.

The CM-5

The controller used on this robot is a CM-5, which uses the processing ability of an ATMega128. It runs at 16MHz, 128Kb of Flash memory, 4Kb of EEPROM and 4Kb of Internal SRAM. It has two available UARTS, which are designed for communicating with the servos at 1Mbps and with the PC at 57600bps. The original firmware allows different programming methods using the Software from Robotis (more details further down), but it is possible to build our own firmwares, programming in C or C++ and compiling using the right libraries (more details further down).

The Dynamixel AX-12+

These servos feature a precise position and speed control, an alarm system for different malfunctions, holding torques up to 18.6 Kgf.cm and communication speeds up to 1Mbps. It uses a simple communications protocol that allows writing and reading different status values (current and goal position, current and goal speed, LED status, torque, voltage, temperature, etc). Each servo has a different ID and this network doesn't allow multiple packets to be exchanged at the same time. The bus has 3 pins: GND, VDD and DATA. An instruction and status packet must have the following structure:

Instruction
0xFF 0xFF ID LENGTH INSTRUCTION PARAMETERS CHECKSUM
Status
0xFF 0xFF ID LENGTH ERROR PARAMETERS CHECKSUM
  • The first two bytes are the header, both 0xFF
  • The third byte is the ID to whom the instruction is being sent to or where the reply comes from
  • The forth byte is the length of the rest of the message (2+number of parameters)
  • The instruction or error byte have the following values and meanings:
INSTRUCTION ERROR
Value Name Parameters Description Bit Name Description
0x01 PING - Request of a Status Packet 7 - No Error
0x02 READ x,n Requests the values of n bytes starting at byte x 6 Instruction Error The instruction requested is undefined
0x03 WRITE x,values Requests writing values starting at byte x 5 Overload Error The maximum torque isn't enough to hold the load
0x04 REG_WRITE x,values Similar to WRITE, but waits for a ACTION packet 4 Checksum Error The checksum is wrong
0x05 ACTION - Triggers the last REG_WRITE packet received 3 Range Error The values to be written are out of range
0x06 RESET - Restores the Control Table to factory defaults 2 Overheating Error The temperature exceeds the maximum operating temperature
0x83 SYNC_WRITE x,l,S*N Allows writing in several Dynamixels at the same time, starting at byte x, l values. 1 Angle Limit Error The goal position is outside the CW and CCW range.
- - - - 0 Input Voltage Error The input voltage is outside the operating voltage range.


  • The parameters are extra values required for some instructions or replies.
  • The Checksum byte is calculated as ~(ID+LENGTH+INSTRUCTION/ERROR+PARAMETERS)

Datasheet: AX-12+

The Dynamixel AX-S1

The AX-S1 device has several abilities. In addition to the distance sensor in three directions, it also has a sound emitter and receiver, an infrared remote control receiver and a light sensor. The communications protocol and construction is very similar to the ones of AX-12+

Datasheet: AX-S1


The Robotis Software

Robotis supplies three programs in order for the average user to take most advantage from the Bioloid: Behaviour Control Program, Motion Editor and Terminal. Each has a different function, according to the level of complexity you wish to use.

Motion Editor

This program allows the user to compute poses and motion files for the Bioloid. It has 127 motion pages available, each with 7 poses. It features a 3D view of the robot, showing the actual position of the robot, as well as the position of each servo. The pose can be made manually (moving the servos manually and saving the pose) or using the computer (sending goal positions to all servos and saving the pose). These motion pages can be edited in Terminal and can be used as part of the BCP files.

Behaviour Control Program (BCP)

The BCP allows the making of simple control algorithms, using an intuitive block programming system. For example, it allows playing different motion pages (or files) if the robot detects some sound patterns, or detects walls, or even if a button is pressed. The BCP files passed to the CM-5 are played when it enters PLAY mode. It also allows downloading and uploading motion files to the CM-5, recovering and updating the firmware of the CM-5, AX-12+ and AX-S1.

Terminal

The terminal allows maximum freedom customizing motion files and dealing with the robot servos. Using a terminal mode, we can easily change different parameters from the servos Control Table as well as using more precise poses. This program is also used to access the bootloader of the CM-5, allowing an advanced user to upload his own firmware.

Improvements

Although the Bioloid platform is very customizable it lacks the necessary power of computing and sensing required for a walking and balancing algorithm. This section will explain the problems we encountered and the solutions adopted (or about to be adopted) to improve the Humanoid.

6-Axis IMU

In order to be able to estimate an attitude, it has been decided an IMU would be required. In order to facilitate the programming, we chose the 6 Axis IMU from HuvRobotics, which features a 3 Axis Accelerometer and a 3 Axis Gyroscope. Also this device was made in order to simply be connected to the CM-5 bus and follow the same communications protocol as the Dynamixel devices. It has an ATMega8 (the same used in AX-12+), updates the IMU readings at 100Hz and allows an easy reading of the 6 parameters with one single instruction. This solution has been acquired and is mounted in the Humanoid Torso.

Foot Pressure Plates

The acknowledgment that a foot as reached the floor is also an important factor to improve the walking ability. One major possibility to solve this problem also came from HuvRobotics Foot Pressure Board. Just like the IMU, it is made to be connected to the CM-5 bus and respond to the same communication protocol. Alas, the production has been stopped. This has been postponed, but we expect to build our own boards, featuring either a pressure sensor or a simple switch. We still need to decide if this board will have an independent microprocessor to connect to the CM-5 bus (easy to plug, but harder to power) or if we should connect it to an ADC in a new processing board (being built).

USB2Dynamixel

This device allows the connection of a USB port to the Dynamixel bus. Using any language, it is possible to use the computing power of a laptop or desktop PC to create complex algorithms to control the Humanoid. Using this method the CM-5 is not needed to control the servos, but the USB2Dynamixel does not power the servos. In order to solve this problem, one can keep the CM-5 attached but dorment (creating a program that does nothing or using the bridge mode with Libbioloid) or use a new pack of batteries, like Li-Po's. The software of this device allows a simple control of the servos, updating the firmware and changing most Bioloid devices parameters through an user-friendly interface. However, our goal is to make an autonomous robot, not being connected to a big PC, so this device is only used for troubleshooting and tuning the servos. The USB2Dynamixel is made by Robotis, you can find more information and drivers and software dowloads here.

LiPo Batteries

The CM-5 comes with an 8 cells pack of simple NimCad batteries (supplying around 10V total). Not only this batteries have a very limited discharge time, which means the Bioloid can only work around 15min without being connected to a power putlet, but they are also extremely heavy. All around, Bioloid users have been experimenting with LiPo packs, with very good results. Using a simple 3s package (this means 3 cells in series), we are able to supply around 12V to the servos, making them able to achieve higher torques and speed, for over an hour. In spite of the advantages, the LiPos have a few constraints. Firstly, an additional circuit is needed to prevent the batteries from over-discharging, because if this happens the batteries are not recoverable, and to keep their voltage balanced. Secondly, they can only be charged using a specific charger, to prevent overcharging, which can cause the batteries to explode. And finally, their size makes them hard to fit in the original CM-5 box. We have decided to adopt this solution, along with the following changes, and they are being implemented. You can find a lot more info and interesting testimonies in Robosavvy.

Gumstix

In spite of the versatility and how easy it is to program, the Bioloid platform has two very important constraints: processing power and communication actual speed. Most learning and walking algorithms require the usage of matrices, which come with complex mathematics. Not only C programming seems inadequate for this level of mathematics, but also the computing abilities of the ATMega128 just don't cut it. In order to solve this problem, it has been decided we should acquire a Gumstix board. We now have a Gumstix Verdex XM4-bt board, which features a Marvel PXA270 400Mhz microprocessor, 64MB RAM, 16MB Flash, a Bluetooth communication module with antenna, 1 USB port and 3 UARTs, running a Linux OS. The main problem with the communication network is the fact is that it is only half-duplex and shared by all the Bioloid devices. Even with speeds of 1Mbps, the CM-5 needs to send one request to each device and wait for its reply, making it a very slow system to use with a real-time algorithm. The Gumstix also gives a pretty good solution to this problem, firstly with the 3 UARTs available and also with the possibility of using the USB port. It is possible to install several modules in this embedded solution, using a cross-compiling toolchain. The method for this will be explained in the next chapter, since it requires some knowledge and a lot of steps and patience.

Expansion Board

In order to make full use of the 3 UARTs and the USB port it is required an expansion board. Again there are two solutions for this problem: one can buy the expansion board or make one from a scratch. We chose the first, although later we realized to have been a bad judgment. The board was a Console-vx, with 3 Serial connectors for the UARTs, one mini-USB port and a power plug. In spite of seeming a great option, we found several problems. Of the three Serial ports available, only one was usable to connect to the Bioloid bus, because one of them is used for the console connection and the other one is disabled when Bluetooth is enabled. In addition to this, several devices are required to power and link the expansion board and the gumstix to the bus. Among others, the USB2Dynamixel was used to link the USB port to the bus, and one AC adapter, linked to a voltage regulator, for powering. All this devices were too big to fit in the original box and were inadequate for an autonomous robot to walk with. Henceforth, we chose to create an all new board, in order to be able to use the processing of the Gumstix, the power of the LiPo batteries and the many UARTs available on a new microprocessor.

The New Expansion Board

As stated before, the already existing solutions seemed less than satisfactory for the goal at hand. So, following the example of other members in the Bioloid community, we decided to build a custom-made board. This board will have the following features:

  • A 60 pin connector for the Gumstix;
  • An ATXMega128 microprocessor, that will be dealing with all the communications with the Bioloid devices. This microprocessor will be programmed to use one port as a USB connection for the Gumstix and have 6 UARTs available for independent bus connections and 2 ADC connections. The programming, being very similar to the ATMega128, is easy to implement and will allow to compact the several unnecessary headers used by the Bioloid devices;
  • A 3s LiPo batteries pack feeding the Gumstix, the ATXMega128 and the several Bioloid buses, along with an alarm system in case of overdischarge;
  • The possibility of using the ADC ports to connect additional devices later on;
  • A Serial door for the Gumstix console and a JTag for the ATXMega console;
  • Several LED indicators to show communications activity and powering;

This new board and the LiPos won't fit in the original CM-5 box. In order to maintain the Bioloid original form, a new box will be made in order to accommodate all these devices without straying too far from the original designs.

This board is still being designed and we expect to have it ready soon.

Special Procedures and Trivia

This platform is being used and improved for almost 2 years. In all this time, we have experienced different situations, sometimes new, sometimes old, but that we feel that should be compiled in one place. As such, the following situations have been troublesome and here you can find possible solutions and tutorials.

Charging normal batteries

When the Bioloid is using the original CM-5 and firmware, in order to recharge the batteries one needs to plug the 12V DC adaptor AND press the UP button with the Bioloid turned on. Otherwise, the Bioloid won't be charging the batteries, it will only be using the plug power to function.

Changing CM-5 Firmware

As stated before, the original Robotis firmware allows a great deal of programming using simple motion files with more complex behaviour programs. However, an experienced programmer will want to push some functions further and will eventually build his own C program. Although this is an easy procedure, it rises some doubts at first. In order to recover the original firmware, you simple use the Recover CM-5 option from BCP, after downloading the latest firmware from Robotis.

In order to compile the C program, you need to use AVR libraries. In this project we have been using two programs to write and compile these algorithms under Windows. The Programmer's Notepad 2 (PN2) is the program used to create and edit the C files and the compilation was made using the WinAVR. Afterwards you need to send the .hex file to the CM-5 using the bootloader through the Terminal program.

Create a AVR compiling tool in PN2

Using PN2 you need to use Tools->Options then go to Tools tab and choose Global Tools. Add a new one, give some clear name like "WinAVR make all", under Command write "make.exe" and in Folder use "%d" (in order to be called in the current folder). Finally in parameters write "all". Now you have a "make all" tool for AVR. You should also create a "make clean" tool, using the same method. Check for several example files in Bioloid files.

Uploading the Firmware

After running the "make all" you will have a .hex file that you need to upload to CM-5. In order to do this you need to run the Terminal program, connect your Bioloid and enter the Bootloader. This mode is entered by sending # characters (literally keep pressing Shift+# for a while) and pressing the MODE button. You should see a CM-5 Bootloader message and a prompt, in which you write "load". The message "Write Address: 00000000 Ready..." is displayed and then you should go to Files->Transmit File and choose the compiled .hex file. A success message should then appear and a Reset is needed in order to boot using the new firmware.

Changing AX-12 firmware

In order to update the AX-12 (or AX-S1) firmware you can use the BCP program or the USB2Dynamixel program. Either way should work, and you can download the latest firmware from Robotis. However, there is the chance that things go wrong and, just like us, you end up with 18 servos all with the same ID and all flashing the alarm LED. This problem was solved with the help of several people from Robosavvy, as you can in this post.

  1. The first step was to enter the AX-12 bootloader one at a time. Using the CM-5 in bridge mode, at 57600bps baudrate, and the Terminal software, start sending many # through the line, just like in a CM-5 bootloader entry, and then attach the AX-12+ to the bus. It is imperative to only attach the AX-12 after sending the #, because the bootloader on AX-12+ only waits 1/60th of a second before rushing to program mode. If this is sucessfull, you should write 'h' for help, 'C' for clearing the EEPROM, 'A' to enter application mode and finally 'Go'. This should give you a working servo, with ID=1 and at 1Mbps.
  1. This may not work, because the servo firmware is corrupted, just like it happened to us. We had to download the LibBioloid, along with libcompat, libavr and programmer libraries. In order for this to work several steps were needed:
    1. Firstly download these libraries and install a GCC compiler for Windows. MinGW worked fine under Windows 7.


LibBioloid

Changing CM-5 Firmware Flashing Gumstix Compliance Communications and balance experiments