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 To run the simulator with the currently included controller just type
The Object
![]() |
![]() |
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.
![\begin{figure} \centerline{ \includegraphics [width=0.6\linewidth]{images/referencies.eps} }\end{figure}](http://www-iri.upc.es/people/porta/simulator/manual_simulador/img39.gif)
![\begin{figure} \centerline{ \includegraphics [width=0.6\linewidth]{images/ref_ref.eps} }\end{figure}](http://www-iri.upc.es/people/porta/simulator/manual_simulador/img40.gif)