A robot definition can comprises of three sections <structure>, <sensors> and <actuators>, where <sensors> and <actuators> are optional. The robot definition may also be specified in a separate file which is then referenced in the main program. For example, if the specification in Fig. 1.1
is stored in a file named "snake.xml" in directory "xml/robot", then in the program script, it suffices to write:
<robot file="xml/robot/snake.xml"/>
The <structure> section consists of a set of named groups, each with a set of elements. Each element in the "elements" attribute can be a module's logical ID or a group name defined previously. The logical ID is a unique ID for a module; it may correspond to the ID in PBSim if PBSim is connected and one wants to see the motion in simulation. For example, Fig. 1.2 shows a robot definition for a 6-legged centipede, with three left legs and three right legs, and each leg consists of three modules.


The <sensor> and <actuator> sections have the same syntax as the <structure> section, with group names replaced by sensor or actuator names. The elements of a sensor or an actuator are the modules which have the named sensor or actuator. If an element of a sensor or an actuator is a group name defined in the structure section, it is assumed that all the modules of that group have the named sensor or actuator. Each named sensor or actuator has to be implemented. The current version has implemented "angle" (named angle), "accelerometer" (named accel) and "switch" (named touch) sensors, but no actuators.
Fig. 1.3 shows an example of a turning loop specification, where there are two groups and there is also an accelerometer associated with every modules in the "turn" group. Sensors can have named arguments. For example, the accelerometer sensor has three arguments, named x, y, and z, respectively, indicating the accelerometer reading for x-, y-, and z- axis, respectively. The touch sensor has two arguments, named left and right.
If a sensor is specified in the robot definition file, the values will show up in the PARPE GUI after the program is loaded, in the reading or running state.
Exercise 1.1 Write a robot definition file for turnloop.xml so that each loop module has a touch sensor. [Easy]
Robot definitions use logical IDs which are hardware independent. Each hardware module has its own ID. In order to control the hardware, a logical to physical mapping file is needed. Such a mapping file is in XML format as well. A possible mapping for "snake.xml" is shown in Fig. 1.4.

After load the mapping file, physical IDs will be displayed in the PARPE GUI as shown in Fig. 1.5.

To control the hardware, first connect the serial port RS232 to the robot, then turn on power supply. Check "Connect to Serial" in the PARSL GUI. Communication status should be "Reading" and the current joint angles should be displayed in column "angle". "Loop Time" shows one cycle of communication in milliseconds. If the "Loop Time" is more than a couple of seconds, the serial communication does not work properly.