Realtime Linux
Author(s): Jeroen de Best, Koen Meessen
Source: Techunited: How to turn Hardware into Football
This document describes how to get the robots of Tech United to play football. It begins with installing a development PC, devpc.
How to install a devpc
This chapter describes in detail all the consecutive steps needed in order to get a fully operational development PC called devpc.
Install Ubuntu 8.10
Get a Ubuntu 8.10 live CD put it in your CD tray, boot your system from CD and select Install Ubuntu 8.10 to your hard disk. At the first step choose your language (English) and select 'Forward'. At the second step choose your time-zone. The time-zones are sorted by continent. Choose Europe, Amsterdam and select 'Forward'. At the third step choose your keyboard settings. You can try the settings in the lower area of the setup screen. The default is U.S. English, U.S. English. Select 'Forward'. At the fourth step you are asked to prepare the disks. Choose for the manual option here and select 'Forward'. Now watchout, because in the following steps you are going to erase your entire harddisk! Consecutively, select each partition and delete those partitions by clicking 'Delete partition'. After deleting all partitions select 'free space' and click 'New partition'. First make a primary partition of 4096 megabytes which is located at the beginning. Use this partition as a swap partition. This can be chosen in the 'Use as' drop down menu. Select 'Ok'. Secondly, make a primary partition of the remaining size which is located also at the beginning. Use this partition as an ext3 partition. This can be chosen in the 'Use as' drop down menu. The mount point should be '/'. Now, all disk space is partitioned. Turn on the 'Format?' option for the ext3 partition and select 'Forward'. At step number five, do not Migrate Documents and Settings and select 'Forward'. At the sixth step you should fill in the form about who you are. In our case the login name and username are robocup. The password for robocup is Robocup. Make sure that the name of your computer is devpcX, where X stand for the number of the devpc. Tick the Login Automatically option. The installation will take approximately 15 minutes. After installation, reboot the system.
Wireless internet at the TU/e
If you have a wireless ethernet adapter, you will be asked to give a default keyring password after rebooting. Just apply it without giving any password and accept the warning about the weak password. You can get wireless connection to the internet by clicking the network applet in the top right corner of the screen. Choose tue-wpa2. A screen with settings appears. Set the following settings:
Wireless Security: WPA & WPA 2 Enterprise Authentication: Protected EAP (PEAP) Anonymous Identity: Ca- Certificate: /usr/share/ca-certificates/mozilla/GTE_CyberTrust_Global.crt PEAP Version: Version 0 Inner Authentication: MSCHAPv2 Username: <your TU/e user name> Password: <your TU/e password>
Accept the settings and you will be connected to the wireless TU/e network.
Switch to basic appearance
At this moment we shutdown the fancy graphics environment. Therefore, go to System, Preferences, Appearance, Visual Effects and set these to none. This turns of all the fancy desktop features, which are unneccesary.
Change root password
Now we should change the superuser/root password by typing. This can be done using a so-called terminal, which can be started from Applications, Accessories, Terminal. A white screen will appear with a command line prompt. To change the root password type the following.
robocup@devpcX:~$ sudo passwd root
Type your own password when asked as follows
[sudo] password for robocup:
and enter the new root password ****** twice when asked as follows
Enter new UNIX password: Retype new UNIX password:
Now your root password is updated.
passwd: password updated successfully
Install additional packages
At this point, be sure to have a working internet connection. If so, open Synaptic Package Manager from System, Administration, Synaptic Package Manager. Type the password Robocup to enter the package manager. Click the top right 'Reload' button to update the package list. Now double-click or right-click and select 'Mark for Installation' for the following packages. You can find these packages fast by selecting one of the packages (single-click) in the top right package list and type the first letters of the package you are searching for.
csh (needed for matlab engine) g++ g++-4.1 gcc-4.1 (needed for compatibility with mex) glade-3 (needed for GUIs) kernel-package (needed for kernel compilation) libgd2-noxpm-dev (needed for gd functionalities) libstdc++5 mc (file browser midnight commander) nfs-common (needed to mount wtbfiler) ntp (needed for synchronizing clocks) ntpdate (needed for synchronizing clocks) openssh-server (to access from a remote computer) sun-java6-bin (needed for java) subversion (needed for svn version) bison (needed for comm) ccache
Apply to install the packages. Agree the license agreement of Java, select 'Forward'. These packages will be needed during the following steps or will be needed in combination with the Tech United software.
Change gcc and g++ version
On your system there are now two versions of gcc, namely 4.1 and 4.3. Since the mex command of Matlab cannot cope with the 4.3 version we have to use the 4.1 version. The current version will probably be 4.3. To check this type the following
robocup@devpcX:~$ su Password: root@devpcX:/home/robocup# gcc --version root@devpcX:/home/robocup# g++ --version
Now we alter the link gcc and g++ to point to the 4.1 versions. This is done as follows
robocup@devpcX:~$ su Password: root@devpcX:/home/robocup# cd /usr/bin root@devpcX:/usr/bin# ln -sf gcc-4.1 gcc root@devpcX:/usr/bin# ln -sf g++-4.1 g++
Check the versions again to make sure that the correct version 4.1 is now used.
Install Matlab 2007b
Now we will install Matlab 2007b. Therefore we will access to the wtbfiler of the TU/e. Note that this is only possible if you are at the TU/e or having a VPN connection with the TU/e. Make sure you have a working internet connection, preferably wired to speed up the installation process. Open a Terminal and proceed as follows
robocup@devpcX:~$ su Password: root@devpcX:/home/robocup# mkdir /mnt/temp root@devpcX:/home/robocup# mount wtbfiler.wtb.tue.nl:/software /mnt/temp root@devpcX:/home/robocup# mkdir /usr/local/matlab75 root@devpcX:/home/robocup# cd /mnt/temp/Unix-Software/matlab2007b/license root@devpcX:/mnt/temp/Unix-Software/matlab2007b/license# cp license.dat /usr/local/matlab75 root@devpcX:/mnt/temp/Unix-Software/matlab2007b/license# cd ../DVD1 root@devpcX:/mnt/temp/Unix-Software/matlab2007b/DVD1# ./install
Choose the matlab root directory as /usr/local/matlab75. During installation cut the license at the begin and at the end where it is indicated (cut including the begin and end comments). Select the option Create symbolic links to MATLAB scripts in: /usr/local/bin. The installation will approximately take 30 minutes. Now we change the matlab command to work with the installed java package. Therefore edit the file /usr/local/bin/matlab. Open a Terminal and open the file as follows
robocup@devpcX:~$ su Password: root@devpcX:/home/robocup# cd /usr/local/bin root@devpcX:/usr/local/bin# gedit matlab
Add the following at line 183 just after all the comments
export MATLAB_JAVA=/usr/lib/jvm/java-6-sun-1.6.0.14/jre
Save and close the file. Now you can start matlab. Always start matlab as a superuser/root so
robocup@devpcX:~$ su Password: root@devpcX:/home/robocup# matlab
Change mex options
In this section we change the options for the matlab function mex in order to be able to build the Tech United software lateron. If matlab is started type the following
>> mex -setup
Choose for option 2, Template Options file for building gcc MEX-files. Matlab reports that a file mexopts.sh is created in the folder /root/.matlab/R2007b. Check if it is placed in the prementioned folder. If this is not the case, you probably did not start matlab as a superuser and therefore the file mexopts.sh is placed in /home/robocup/.matlab/R2007b, which is incorrect. If this is the case restart matlab as a superuser and do the same again. Open the file /root/.matlab/R2007b/mexopts.sh with the editor of matlab and remove the -ansi option from the CFLAGS options on line 57 and 65. Add the option -W on line 57 and 65 to show warnings during compilation. Save and close the file.
Install linux kernel 2.6.28.3
Since the Tech United software is based on the linux kernel 2.6.28.3 we need to install this kernel. Therefore, make sure to have a working internet connection. Open the webbrowser Mozilla and go to the FTP site ftp://ftp.kernel.org/pub/linux/kernel/v2.6 and download the file linux-2.6.28.3.tar.bz2 to your desktop. Extract the file by right-clicking and chosing extract here. To move the folder linux-2.6.28.3 from your desktop to /usr/src open a Terminal and type
robocup@devpcX:~$ su Password: root@devpcX:/home/robocup# cd Desktop root@devpcX:/home/robocup/Desktop# mv linux-2.6.28.3 /usr/src
Now obtain the .config file needed for the compilation of the kernel from another devpc and put it into the folder /usr/src/linux-2.6.28.3. Now your are ready to compile the 2.6.28.3 linux kernel. Here we will make debian packages of the kernel, *.deb files, such that they can be easily installed and uninstalled from your current installation. Open a Terminal and proceed as follows
robocup@devpcX:~$ su Password: root@devpcX:/home/robocup# cd /usr/src/linux-2.6.28.3 root@devpcX:/usr/src/linux-2.6.28.3# make-kpkg --initrd binary-arch
The compilation will approximately take one hour. After that, two debian packages are created in /usr/src, namely linux-image-2.6.28.3_2.6.28.3-10.00.Custom_i386.deb and linux-headers-2.6.28.3_2.6.28.3-10.00.Custom_i386.deb. Open the file browser Nautilus from Places, Computer and go to /usr/src/ and double-click the first one. Enter the password and install the package. Do the same for the second one. Finally, restart your PC. During rebooting you will see that there are now two more GRUB options from which the default is now the new linux kernel 2.6.28.3. Once booted, you can check the kernel version in a Terminal
robocup@devpcX:~$ uname -r
It should be 2.6.28.3.
Linux
In the startup script set the maximum transfer unit of the GigE ethernet card to 9200 kilobytes. This can be done as
robocup@devpcX:~$ su root@devpcX:/home/robocup# ifconfig eth0 mtu 9200
where eth0 is the GigE ethernet port. Furthermore, add a directory /dev/usb and run the executable makenodes. This is necessary to make the compass function properly. The prementioned steps can be done as follows
robocup@devpcX:~$ su root@devpcX:/home/robocup# mkdir /dev/usb root@devpcX:/home/robocup# cd svn/trunk/src/Turtle2/Libs/TUeDACS-2.0/UgcDriver root@devpcX:/home/robocup/svn/trunk/src/Turtle2/Libs/TUeDACS-2.0/UgcDriver# ./makenodes
With the linux dmesg we can check if the compass is detected correctly. If necessary remove and again insert the compass in the usb port of the PC. You should get messages concerning Range Bearing Devices.
Install SmartSVN
Before we can actually build the Tech United Robocup software we have to obtain the Robocup svn software tree using SmartSVN. To install SmartSVN open the webbrowser Mozilla and go to http://www.syntevo.com. Choose for SmartSVN. On the left hand side choose for Download, followed by Generic (Linux, Unix, OS/2) Download. Tick the I have read, understand and agree to all terms of the license agreement and download SmartSVN. Save the smartsvn-generic-5_0_4.tar.gz to your Desktop. Extract the tar.gz file to your Desktop by right-clicking the tar file and chosing for Extract here. Move the created directory smartsvn-5_0_4 to /usr/local, by typing the following in a Terminal
robocup@devpcX:~$ su root@devpcX:/home/robocup# cd /home/robocup/Desktop root@devpcX:/home/robocup/Desktop# mv smartsvn-5_0_4 /usr/local
We should edit the file smartsvn.sh in /usr/local/smartsvn-5_0_4/bin. This can be done for example using gedit, see below.
robocup@devpcX:~$ su root@devpcX:/home/robocup# gedit /usr/local/smartsvn-5_0_4/bin/smartsvn.sh
Uncomment and edit the JAVA_HOME as follows
JAVA_HOME=/usr
Save and close the file. It is nice to have a symbolic link to SmartSVN such that you can start it from anywhere on your PC. To make a link to SmartSVN type the following in a shell
robocup@devpcX:~$ su root@devpcX:/home/robocup# cd /usr/local/bin root@devpcX:/usr/local/bin# ln -sf /usr/local/smartsvn-5_0_4/bin/smartsvn.sh smartsvn
Always start SmartSVN as a normal user by typing
robocup@devpcX:~$ smartsvn
Tick the I understand and agree to the terms and conditions of this agreement and click Next. Choose for the Free Professional edition and click Next. Choose My repositories are already set up and click Finish. Then Check out project from repository and click Ok. Choose for the Quick Checkout (less configuration) option with URL http://robocup.wtb.tue.nl/svn/techunited and Local directory as /home/robocup/svn and click Next. Accept that you want to create the directory if it does not exist by clicking Create and finally click Finish. In lower status bar you can see that SmartSVN is now checking out. When the checkout is completed, click the Refresh button in the lower left Transitions part. Choose to create cache for the whole repository at http://robocup.wtb.tue.nl/svn/Techunited. To close SmartSVN click the normal close button, but also close it in the upper right toolbar by right-clicking the SmartSVN icon and chosing Exit SmartSVN.
Install the Tech United software
Now startup matlab as superuser and go to the directory /home/robocup/svn/trunk/src/Turtle2. Install the robocup software in matlab by typing the following in the matlab command window
>> make_all_install
To create the motion executable in matlab go to /home/robocup/svn/trunk/src/Turtle2/Motion and type
>> build_turtle_motion turtleX
where X stands for the number of the turtle. Copy the motion executable to the turtle by typing
>> copy_motion turtleX
To build and copy the vision go to /home/robocup/svn/trunk/src/Turtle2/Vision
>> build_turtle_vision turtleX >> copy_vision turtleX
To start the turtle we need to start the Turtle Remote Control panel. Open a Terminal login as superuser and start the trc as follows
>> export AGENT=#devpcnumber+10 >> trc
How to test the connections of the turtle
This chapter describes how to run test connections osn a turtle. Note that the wheels of the robot have to be released of the ground as the wheels will rotate!!
Preparation
Put the turtle on a plateaux and make sure the wheels can freely rotate. Connect a devpc to the robot using a UTP cable. Plug the cable in the input port (right port) of the IO stack. Next, start matlab as follows
robocup@devpcX:~$ su Password: root@devpcX:/home/robocup# matlab
Within the matlab go to /home/Robocup/svn/trunk/src/Turtle2/Motion/Tools/Test_connections and initialize the test_connections scheme by typing the following in the matlab command window
>> cd /home/Robocup/svn/trunk/src/Turtle2/Motion/Tools/Test_connections >> init_test_connection turtleX
Now open the simulink scheme test_connections.mdl on the devpc. Make sure that the following settings are set
- Power on/off : 1
- Amplifiers on/off : 1
and all other constants are to zero! If the settings are correct build the model by pressing CTRL-B. Next open a Terminal and run the executable test_connections as follows
robocup@devpcX:~$ su Password: root@devpcX:/home/robocup# cd svn/trunk/src/Turtle2/Motion/Tools/Test_connections root@devpcX:/home/robocup/svn/.../Tools/Test_connections# ./test_connections -w
Go back to test_connection.mdl and press "Simulation", "Connect to target" and after a few seconds press "Simulation", "Start real-time code".
Test motors
In the table below, a list is created that shows to which values the inputs (current) have to be set, what the encoder should show, and what the direction of motion should be.
System | Motor | Current | Encoder | Direction |
Drive | drive motor front left | +0.1 | decrement | anti-clockwise |
drive motor rear | +0.1 | decrement | anti-clockwise | |
drive motor front right | +0.1 | decrement | anti-clockwise | |
Ball handling | Ball motor left | +0.05 | 0-5 | push ball |
-0.05 | 5-10 | pull ball | ||
Ball motor right | +0.05 | 0-5 | push ball | |
-0.05 | 5-10 | pull ball | ||
Shooting device* | kick motor | +0.6 | decrement | up |
Keeper frame |
'*'Note that this motor has a finite stroke, hence, set it to zero when it reaches the end of stroke!
Solenoid
To check the kicker, a very light shot will be produced. First, check the state of the slave of the shooter and the encoder of the kicker
- The output of SHTstatus should be equal to 1.
- Pulling out the kicker should result in an increasing SHTvalue.
Now it is time for a tiny shot. Place a ball in front of the robot and make sure that nothing can be hit by the ball. Set the following values
- SHTdutycycle : 0.15
- SHTpulselength : 25
- SHTencodermax : 100
After setting these values, set
- SHTcontrol : 1
Now the kicker should kick.
Stop test connections
In test_connections.mdl, press 'Simulation', 'Stop real-time code' and set all inputs to zero.