CURRENT ISSUE Contests
Issue #212 March 2008
Robotics with Ada95
by Daniel Ramirez
Ada95 is a standardized object-oriented programming language that was developed in the late 1970s by the U.S. Department of Defense. Today, engineers like Daniel use the highly structured language to increase the safety and reliability of their new robotics applications.
Start | Why Use Ada95 For Robotics? | GNAT Ada95 Tools | Debugging Ada95 Applications | Ada95 Coding Style |Wireless Sensor Controller | Wireless Messages | The Glove In Action | XYZ Accelerometers | XBee-PRO Wireless UART | Controller Range | USB 2.0 Interface | Ethernet | The Kernel | Ada95 vs. Other Languages | Future Applications | Sources & PDF
What do robots in space, the International Space Station, the Canadian robot arm, the European Arienne rocket, the Boeing 767, the Eurobus jet, and the French Grand Vitesse bullet train have in common? The answer is Ada95, a computer language used to develop life-critical embedded applications. Ada was developed during the late 1970s and early 1980s by the U.S. government for defense applications in an effort to reduce the high life-cycle cost of large software applications. It was also intended to replace older languages, such as COBOL, FORTRAN, and PL/1, which were used by various government agencies.
Ada was developed to fill the need for highly reliable fault-tolerant software. We engineers and robot designers should also be concerned with our robotic inventions that use embedded software. Why? Because they are growing in size and weight and could possibly cause harm or injury to innocent bystanders. The Robot Wars and Tetsujin exoskeleton competitions, where teams design robotic exoskeletons capable of lifting heavy weights, are dangerous events. Just imagine an out-of-control, fire-breathing autonomous battle ’bot. Sounds like a Stephen King movie, doesn’t it?
Now you can take advantage of the highly structured Ada95 language for your own purposes because it is freely available on the Internet via GNU/GNAT user-supported sites. An LRM, a complete user manual, and other reference manuals are available at www.adaic.org. It is easy to get started with Ada95, especially if you already know similar programming languages such as Java, Pascal, Visual Basic, and Visual C++. There are also many references and textbooks on Ada95. I highly recommend J. G. P. Barnes’s Programming in Ada: Plus an Overview of Ada 9X and “Ada 2005 Rationale” by Intermetrics. Like C++ and Java, Ada95 supports object-oriented programming (OOP) and procedural programming (if you don’t want to get into OOP).
What makes the Windows GNAT Ada95 good for the embedded systems developer are the tightly typed variables, tasking, and other structural and safety features. They include: Ada95 packages, generic functions that are similar to C++ templates, types, tagged types and protected records that are similar to C++ classes, ranges, schedulers, tasks that are similar to C++ and Java threads, and Ada exceptions that are similar to the C++ try, catch, and throw keywords.
Real-time multitasking, multiprocessing, and parallel processing are areas that Ada95 handles well. They are also the reason it is used for the development of life-critical software. The Ada95 task instruction with its related delay, select, and accept statements and its own deterministic scheduler make it ideal for hard real-time systems that require synchronization. In particular, the protected record structure enables two or more tasks to communicate via shared global data (critical region) without having it corrupted by either task and without the need for semaphores.
Ada95 packages and tagged types encapsulate both data and functions in a similar manner to C++ classes. Packages also control the visibility of objects so some implementation details can be hidden from other packages for information hiding.
Another wonderful feature of Ada95 is bindings. A binding is an interface to another language such as C or assembly using the Ada “pragma interface to C.” This is great because it gives your Ada95 applications access to most of the hardware on a PC or laptop. The serial bindings give you access to the serial port. Bindings to the Ethernet are provided via the Winsock bindings that enable you to develop client and server applications. In addition, you can access the mouse via the mouse bindings and a joystick via the joystick bindings for those telepresense and telerobotic applications that you are working on. All of the Win32 bindings and the DirectX graphics bindings necessary for real-time displays and Windows panels are also available.
The language features will help you build more robust, safer, and fault-tolerant robotic applications with my examples as a starting point using AdaCore GNAT Ada95. The Ada features combined with embedded microcontrollers that support the serial communication interface (SCI), the USB interface, and the Ethernet TCP/IP interface (MAC) will help you harness your PC or laptop’s gigahertz power for your robot applications.
For designers like me who use Unix, Linux, and LynxOS, there are real-time bindings to POSIX and commercial bindings to WindRiver’s VxWorks that can also use GNAT Ada95 for Unix to develop similar applications. Unix and Linux users don’t need to be left out from embedded robotics development because of a lack of Windows-specific software tools.