Wednesday, February 25, 2009

Python integration with Bioloid (An Overview)

What is Python:
Python is scripting language as paradigm. The Python features are the combination of programming language like C, JAVA and Functional languages, which are;
- Imperative (procedural oriented like C)
- Object Oriented (like JAVA)
- Functional (like Haskel, LISP)

What is Bioloid:
Bioloid is a robotic kit made up of interchangeable block-shaped parts. By using these parts, we can build different types of robots performing various tasks. The name Bioloid comes from words “Bio” + “all” + “oid” meaning that any living thing can be built in the form of a robot.

Bioloid Hardware:
The hardware of the Bioloid consists of three types.
- CM-5: The main central processing unit and power source of Bioloid robotics system resides in CM-5 unit. The main purpose is to program execution and storage that interact with AX series Dynamixel (AX-12 Actuator and AX-S1 Sensor). Atmel’s Atmega128 microcontroller, containing four Dynamixel serial ports, programmable control buttons, and status LED's (including one auxiliary programmable led).
- Dynamixel: This is the basic unit of the Bioloid which acts as a joint or a sensor. The AX-12 Dynamixel is an actuator that is used as a joint. The AX-S1 Dynamixel is a sensor unit that can sense both distance and sound.
- Frame: The frame connects the robot units. The Dynamixels can be connected together with the use of the frame. Also, the frame connects the Dynamixels and the CM-5 unit.
More detailed information can be found in manuals of CM-5, AX-12, and AX-S1 Dynamixel.
Most of the research in robotics focuses not on specific industrial tasks, but on investigations into new types of robots, alternative ways to think about design robots, and new ways to manufacture them. A first particular new innovation in robot design is the open sourcing of robot-projects.

There is some group of developers who made interpreters for robots integration. Some are PyRo (www.purorobotics.org), PyMite (http://pymite.python-hosting.com/wiki/PyMite), Swig (www.swig.org), MyRo. By using these interpreters we can integrate robot with Python language to perform different operations.

Discussion on PyRo:
Still Bioloid hardware has some integration problems. Associate Professor Douglas Blank, one of the PyRo developers told me that there is no support for Bioloid in PyRo. His student, Teyvonia Thomas, is working on controlling the Bioloid's CM5 from Python, through an add-on board called the Fluke. Furthermore, he elaborates a new software project, called Myro, which is a simplified interface for robotics. Teyvonia is working on further documentation so that anyone can build a serial over Bluetooth interface with the Bioloid kit. Once you have a serial connection established, then you will need a method of programming the Bioloid motors. I suspect that Teyvonia will have an interface that allows setting gestures/poses, and also gives individual joint control as well. This is a combination of a firmware program on the CM-5, and a series of commands given over the serial line.
Once you have a serial interface, creating a PyRo object is very easy. However, there isn't any support in Pyro for articulated joints. This will be all new interfaces created by Teyvonia. (Although Player/Stage has recently created an act array, an array for controlling articulated arms.)

http://wiki.roboteducation.org/Designing%2C_Building_and_Programming_a_Hexapod:_From_King_Spider_to_TevBot#Electronic_Components
http://wiki.roboteducation.org/Exploring_Search_and_Rescue_with_TevBot

But the point is what is the serial communication protocol of Fluke board and CM-5 Unit?, and if some communication is established between Fluke and CM-5 using Python then it means that Python can be directly communicate with CM-5.

Fluke Hardware: The Fluke is a small electronic board that contains wireless Bluetooth, camera, IR (infrared) sensors, LEDs (light emitting diodes) and an ARM microprocessor. By itself (with a battery), it is a complete (although immobile) robot that can receive simple commands and send back IR readings, camera images, and turn on its LED lights. Connect it to a robot and you can control the robot wirelessly, and add vision and sensors to it. The more detail of the Fluke hardware and its integration is given the website http://wiki.roboteducation.org/Hacking_the_Fluke.

Discussion on PyMite:
I have another discussion with Dean Hall, working in Apple Macintosh and core-developer of PyMite. PyMite is a Python interpreter in order to execute on 8-bit and larger microcontrollers with resources as limited as 64 KB of program memory (flash) and 4 KB of RAM. A brief introduction of PyMite is given in the report. As Bioloid contains AVR microcontroller having total 4KB RAM and PyMite itself require 4KB RAM, so it will quite hard to run Bioloid on PyMite interpreter. I am quoting his rough outline of what I would need to do:
“1. Learn how to build PyMite for ATmega128 (you'll have to learn how Makefile works and edit the arguments to avr-gcc to tell it that you want the ATmega128 processor)
2. Adapt the general AVR platform to your ATmega128 (clocks, interrupts, heap size all have to be tuned to your platform).
3. Learn how to make PyMite native functions (C code wrapped by Python function) so you can call functions to control the Bioloid.
4. Learn PyMite internals so you can remove functions/libraries you don't need in order to have enough RAM to run your program. And I've already made PyMite as small as possible, so there isn't much you will be able to do with only 4 KB of RAM.
I am going to say this again for emphasis #4 is almost a show-stopper. The ATmega128's 4KB of RAM will not leave you with much room to run a program (toggle some pins, ramp a PWM maybe; but nothing elaborates).”

Bioloid Hardware Limitations:
Bioloid hardware is still in the research phase to explore the way to make its connection with Python language. PyRo a Python interpreter still have no support for Bioloid hardware. PyRo, supports some robots like Pioneer, Aibo, Khepera, Soccer Robots, having server client based architecture. From PyRo Robotics website, I did not find any clue to connect AVR microcontrollers through Python. An email conversation with Associate Professor Douglas Blank, core developer of PyRo, elaborates that there is software named as MyRo, and Fluke board, by using both CM-5 unit integration is possible.
PyMite is another python interpreter which provide interface between AVR controllers and Python. PyMite interpreter required 4KB of SRAM at the time of execution and deployment of program code, but on the other hand ATmega128 controller has total 4 KB SRAM which is also impracticable solution.

Related Articles:
Install Python on Linux and how to try Python? (hackerz4u.com)
Ruby, Python, and Science (johndcook.com)

Integration of SQLite3 and Netbeans C/C++ IDE

Few days back, I wanted to use SQLite database for one of my project. I spend couple of hours to find a way to integrate with Netbeans. Mayb...