MCA2 Puma Tutorial Chapter 2
The user interface builder mcagui
The goal of this tutorial is simulating and controlling a puma robot. As a first step we will have a look at an Open Inventor 3D model of a puma robot which we will use for visualisation purposes. Download and unpack the linked zip archive into your puma project (~/mca2/project/puma). A new directory OI will be available which contains the OpenInventor files.
Not everybody has a puma under his/her bed
Not everybody owns a real puma robot to get sensor values and use them for a 3D visualisation. In order to demonstrate the usage of mcagui and the open inventor model we will use a small programme that "simulates" the robot. Actually it just copies controller input values to corresponding sensor outputs (i.e. we are able to predefine and change all sensor values, which are in this special case the puma robot's joint angle values). The name of the program is reply_values and is part of the test project in MCA2.
To start a "simulation" that provides 6 sensor values (a puma robot consists of six joints) we just have to execute:
> reply_values 6 &
Nothing will happen now, except that our simulation is running. Don't expect a gui to appear! Graphical user interfaces and control methods are completely separated in MCA2. We will start the GUI in the next step.
Moving tons with a small mouse
Our virtual robot is active now but does not do anything as it needs commands to perform tasks. Our user interface builder mcagui can be connected to all MCA2 programmes. That way sensor output values can be visualised and commands can be passed to the programmes via their controller inputs. We start mcagui by typing
> mcagui &
A grey window containing a menu bar, a tool bar, a status line, and a working area appears as shown in the following image
We choose 3DRobotViewer from menu Plugins. A small black square (called a GUI widget) appears within the working area. Pressing ctrl + middle mouse button while the mouse cursor points on the black item activates the configuration window for this widget (Note that all widgets can be configured in this manner).
Within the configuration window we select the tab Special. The button Change Robot reveals a file dialogue where we select the file ~/mca2/project/puma/OI/PUMA260/puma260.iv which contains the OpenInventor model of the puma robot. Back in the configuration window (tab Special) the check box Headlight (on/off) needs to be checked. After pressing the button Show all the 3D model of a coloured puma robot is displayed by the widget:
With ctrl + right mouse button the widget's size can be adjusted to the user's needs. With ctrl+left mouse button the widget can be moved within the working area. Widgets can be selected by ctrl + shift + left mouse button (e.g. for deletion), deselection is done by ctrl + shift + left mouse button somewhere in the working area.The ctrl + mouse button commands are available for all GUI widgets.
In the 3D widget objects can be manipulated using the mouse: Holding down the left mouse button, the objects can be rotated according to mouse movements. With the middle mouse button the objects can be moved and with the right mouse button the size of the objects can be changed.
The 3D model is now ready for reacting on sensor values. For that purpose the Widget Ports have to be connected to the IO Channels of the reply_values programmes. This can be done in the Sensors tab of the widget's configuration menu. Mark sensor 0 to sensor 5 in the left and WAIST in the right multi select list and press the --> button to connect the sensor values to the joint angles of the 3D model.
In order to move the puma robot, the sensor values have to be changed. As already mentioned before, reply_values copies the controller input values to the sensor outputs which we have just connected to the 3DRobotViewer widget ports. If we connect sliders to these controller inputs we will be able to control the robot's joint angles. Item Slider in menu Actors places the corresponding widget onto the working area.
Position and resize the new widget as you wish.
Use the configuration dialogue to connect it to the back end as described in the following. Let us connect IO Channel actor 0 to the slider's Widget Port on tab Actors.
After that we specify the minimum (0) and the maximum value (2*PI=6.282) of the slider on the tab Special .
Moving the slider will now result in a rotation of the the robot's waist.
Repeat these steps for the other joints (actors 1-5). Now all axis of the puma robot can be changed by manipulation of the corresponding sliders with the mouse. To show the current values use six of the LCD-Widgets in the menu Sensors and connect them to the sensor values. Your user interface now should look like the following image:
The user interface composed so far with all configured widgets can be saved to file by selecting Save in the File menu (You may use ctrl + s as a shortcut.). All mcagui files have the ending .mcagui. In order to load user interfaces which have been stored in files the File menu provides item Load.
After you have finished trying out your puma robot you should stop reply_values. This is especially important as any parts that have not been stopped will show up if somebody else works on your computer. So please always remember killing your parts like this:
> killall reply_values