Copyright © 2006 Peter Soetens, Herman Bruyninckx
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation, with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of this license can be found at http://www.fsf.org/copyleft/fdl.html.
| Revision History | ||
|---|---|---|
| Revision 0.01 | 30/10/2006 | PS |
| Initial version, text stripped from Main manual. | ||
Abstract
This document describes the Orocos Kinematics and Dynamics Library Plugin for the Real-Time Toolkit.
The Orocos Scripting language allows users of the Orocos system to write programs and state machines controlling the system in a user-friendly realtime script language. The advantage of scripting is that it is easily extendible and does not need recompilation of the main program.
This document describes the extensions the Kinematics and Dynamics Library (KDL) plugin adds to this scripting language.
In order to obtain the kdl plugin, the kdl needs to be configured
with the path to the Real-Time Toolkit. The kdltk
library and the kdl/kdltk/toolkit.hpp header
file are then required for each application which wishes to use
the KDL with the RTT.
The KDL plugin can then be enabled in your program by writing:
#include <kdl/kdltk/toolkit.hpp>
int ORO_main(int, char*)
{
RTT::Toolkit::Import( KDL::KDLToolkit );
}
The Import statement may occur multiple times in the same program, the first one will actually import KDL into the RTT. From now on the KDL types described below are available at the TaskBrowser prompt and in scripts.
The KDL adds 3D vector, rotation, frame, twist and wrench types to the scripting language.
Likewise, the following operators are available for the geometry types :
var frame f1, f2, f3 var rotation r var vector v var twist t var wrench w // ... set f1 = f2.inv * f3 // frame transformations: inverse of f2 times f3 set v = f1.p // read the position set r = f1.R // read the rotation set r = f1.R.inv // read the inverse rotation set v = t.vel // read the translational velocity set v = t.rot // read the rotational velocity set v = w.force // read the force set v = w.torque // read the torque var double x = v.x // also : v.y or v.z var double p = r.roll // also : r.pitch or r.yaw
You can not use the '.' operator in the reverse direction. thus the following code is invalid :
set f.p = v // Invalid ! set f1.R = r // Invalid !
These are thus read-only accessors and can thus not be written to. To change them, you'll have to use a constructor from the next section.
For the KDL types, scripting constructors are provided. The simplest example is the vector constructor, that looks like this:
vector( arg1, arg2, arg3 )
where arg1, arg2 and arg3 are expressions which must be of type double. This returns an expression of type vector, with arg1 as the x component, arg2 as the y component, and arg3 as the z component.
Other constructors currently available are:
// roll, pitch and yaw are double expressions, this // returns a rotation, that is constructed using the // Roll-Pitch-Yaw convention in RADIANS : var double roll = 45.0 * (2.*3.14/360.) // convert to radians // ... var rotation rot = rotation( roll, pitch, yaw ) // Vect is a vector expression, rot is a rotation // expression. This returns a frame, constructed // using the vector x as the origin, and rotation // rot as the rotation.. var frame f = frame( vect, rot ) // or changing its vector and/or rotation: f = frame( -f.p, f.M.inv ) // Double6D is a commonly used type in Orocos // and has been recently introduced in the parser var double6d d6 = double6d(0.0) set d6[0] = 1.0 var double d0 = d6[0] set d6 = double6d( 1., 2., 3., 4., 5., 6. )