Senin, 28 Juli 2008

Programming for Robot Controller

A robot controller consist in a set of functions that are compiled and linked with the rest of the simulator objects. The most important of these functions is the usr_step that, when the robot is running, is called at each time slice. This function should implement the control rule for the robot, or what is the same, give a set of low level commands to be executed next. Observe that the effects of these low level commands are not observable until they are actually executed and this happens just after the usr_step routine concludes.

Each robot controller is contained in a private directory. This directory must contain a header file (user.h), a program file (user.c), and a compilation rule file named dependencies that enumerates the modules used by user.c. The program file user.c must define at least the following set of functions:

  • usr_init: Called when the simulator is started.
  • usr_reset: Called each time the simulator is reset.
  • usr_step: Called once at each time slice if the user controller is enabled.
  • usr_close: Called when the simulator is closed.

All these function receive as a parameter a robot object (the one to be controlled) and a user definable type t_user that can be useful to store parameters or the state of the controller in a given time slice. This type is defined in user.h and the functions to manipulate it should be provided by the user in the program file user.c. The functions to manipulate the robot object are detailed in section 3.2.

The user_skel directory provides an empty controller that can be useful as a base to fill in when a new controller wants to be defined.

To compile a new controller you can use:

compile directory_name
where directory_name is the name of the directory containing the controller to be compiled.

To run the simulator with the currently included controller just type


The Object

A legged robot has a body and four or more legs. The body shape can be described as a polygon in the X-Y plane of the robot's reference frame sweeped along an interval in the Z axis. In our simulator each leg has three degrees of freedom (dof) and the same structure for all robots. However, some parameters of the leg structure (size, joint bounds, ...) can be instantiated for each robot. Each one of leg degrees of freedom is controlled by an independent motor. The most elementary method to move a leg is to command an angle directly to one of these motors. If this angle is inside the user provided bounds, the motor instantaneously moves to the desired angle (we assume that motors can move at any speed). However, the angular form of control is not intuitive (for instances, to move a leg along a straight line at least two motors have to be properly coordinated). For this reason, we provide functions to command each leg in two Cartesian frames of references (see figure 3.1): the leg one (particular for each leg) and the robot one (common for all legs). Additionally, methods are provided to get leg positions in another two frame of references: the world one and the reference one (defined from the reference positions).


\begin{figure} \centerline{ \includegraphics [width=0.6\linewidth]{images/referencies.eps} }\end{figure}



\begin{figure} \centerline{ \includegraphics [width=0.6\linewidth]{images/ref_ref.eps} }\end{figure}

The reference position of a leg is the preferred position for that leg. This position normally correspond to the central position of the leg workspace (i.e. when all angles are set to zero) but the user can choose it to be a different one. The reference frame or reference is a Cartesian frame of reference placed in the center of gravity of the polygon conformed by reference positions (see figure 3.2). This frame of reference is only used to evaluate tensions (see section 2.1.6).

To easy even more the leg movement control, we have included two high level methods to move a leg. The first one moves a set of legs in a coordinated way (applying to all of them the same transformation expressed in the robot's reference frame). This coordinated movement of legs is what we called a gesture [4]. The other high level function to move legs allows to move a leg to a given position in a given time (expressed as a number of time slices to achieve the final position).

All robot models are equipped with touch sensors at feet (that detect contact with the ground in any direction) and two inclinometers (one aligned with the X axis of the robot and the second aligned with the Y axis). Optionally, a robot can be provided with a camera. If this is the case, the simulator shows and additional window displaying the images provided by the camera. The pan and tilt of the camera can be queried and modified with the appropriate functions described below.