Realtime Linux: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''Author(s):''' Jeroen de Best, Koen Meessen
* '''Check [http://www.techunited.nl/wiki/index.php?title=How_to_turn_Hardware_into_Football How to turn Hardware into Football] from the techunited page.'''


'''Source:''' http://www.techunited.nl/wiki/index.php?title=How_to_turn_Hardware_into_Football
* '''Check the [[E-box/Install_manual|E-box]] page for more information.'''


* '''Check [http://www.mate.tue.nl/mate/pdfs/10018.pdf Installing a Real-Time Linux Kernel for Dummies] by Jeroen de Best & Roel Merry'''
** '''IMPORTANT:''' When using Ubuntu 10.04 and the linux-rt kernel, in addition to what is mentioned in the above about CPU-scaling, remove the file "/etc/init.d/ondemand" to stop the scaling mode from changing to ondemand 1 minute after startup.


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=
=Ubuntu RealTime Kernels=
This chapter describes in detail all the consecutive steps needed in order to get a fully operational development PC called devpc.
'''Source:''' [https://help.ubuntu.com/community/UbuntuStudio/RealTimeKernel Ubuntu Documentation]


==Install Ubuntu 8.10==
Check the source for an up to date version of this subject, the text provided here is for quick reference and was copied from the source when it was last edited on 23-08-2011.  
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==
== Prerequisite definitions: ==
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:


<pre>
'''kernel''' - central component of a computer's operating system, bridging between applications and the actual data processing done at the hardware level. See also [http://en.wikipedia.org/wiki/Kernel_%28computing%29 Wikipedia's Kernel entry].  
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>
</pre>


Accept the settings and you will be connected to the wireless TU/e network.
'''real-time''' - an attempt to have deterministic operational deadlines from an event to system response, i.e. the time it takes the computer to respond to an event is known and predictable. A byproduct of this is usually lower [http://en.wikipedia.org/wiki/Latency_%28audio%29 latency for audio]. See also [http://en.wikipedia.org/wiki/Real-time_computing Wikipedia's Real-time entry].


===Switch to basic appearance===
'''vanilla kernel source''' - Linux kernel source code than you can download at www.kernel.org.
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===
'''Ubuntu kernel source''' - Linux kernel source code used in Ubuntu and modified for offer all Ubuntu features. You can download it at [http://kernel.ubuntu.com/git http://kernel.ubuntu.com/git] or simply install binary releases via Synaptic.
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.


<pre>
== Kernel Types ==
robocup@devpcX:~$ sudo passwd root
</pre>


Type your own password when asked as follows
'''-generic kernel''' - this is the stock kernel that is provided by default in Ubuntu.


<pre>
'''-preempt kernel''' - this kernel is based on the -generic kernel source tree but is built with different configurations (settings) to reduce latency. Also known as a [http://en.wikipedia.org/wiki/Real-time_computing#Hard_and_soft_real-time_systems soft real-time kernel].
[sudo] password for robocup:
</pre>


and enter the new root password ****** twice when asked as follows
'''-rt kernel''' - is based on the Ubuntu kernel source tree with [http://en.wikipedia.org/wiki/Ingo_Moln%C3%A1r Ingo Molnar] maintained PREEMPT_RT patch applied to it. Also know as a [http://en.wikipedia.org/wiki/Real-time_computing#Hard_and_soft_real-time_systems hard real-time kernel].


<pre>
'''-lowlatency kernel''' - very similar to the -preempt kernel and based on the -generic kernel source tree, but uses a more aggressive configuration to further reduce latency. Also know as a [http://en.wikipedia.org/wiki/Real-time_computing#Hard_and_soft_real-time_systems soft real-time kernel].
Enter new UNIX password:
Retype new UNIX password:
</pre>


Now your root password is updated.
'''-realtime kernel''' - is based on the vanilla kernel source tree with [http://en.wikipedia.org/wiki/Ingo_Moln%C3%A1r Ingo Molnar] maintained PREEMPT_RT patch applied to it. Also know as a [http://en.wikipedia.org/wiki/Real-time_computing#Hard_and_soft_real-time_systems hard real-time kernel].


<pre>
At the moment only the first three kernels are available through official Ubuntu archives.
passwd: password updated successfully
</pre>


===Install additional packages===
== Choosing a Kernel for Your Use Case ==
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.


<pre>
These are some simple guidelines provided to help you understand which kernel, and in which order, you should test to fit your use case.
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
</pre>


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.
* If you do not require low latency for your system then please use the -generic kernel.
* If you need a low latency system (e.g. for recording audio) then please use the -preempt kernel as a first choice. This reduces latency but doesn't sacrifice power saving features. It is available only for 64 bit systems (also called amd64).
* If the -preempt kernel does not provide enough low latency for your needs (or you have an 32 bit system) then you should try the -lowlatency kernel.
* If the -lowlatency kernel isn't enough then you should try the -rt kernel.
* If the -rt kernel isn't enough stable for you then you should try the -realtime kernel.


===Change gcc and g++ version===
== Kernel Repositories ==
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


<pre>
Currently, not all kernels are available in the official Ubuntu repositories. The balance may be found in select [https://help.launchpad.net/Packaging/PPA PPA's].
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# gcc --version
root@devpcX:/home/robocup# g++ --version
</pre>


Now we alter the link gcc and g++ to point to the 4.1 versions. This is done as follows
First attempt to locate the desired kernel in the official Ubuntu repositories by using your choice of package management (i.e. Synaptic or apt-get). '''Warning - the -rt kernel release can lag behind mainstream, check to the kernel version number!''' As of this writing, Lucid release, the kernel is 2.6.32 but the -rt kernel available in the Ubuntu repositories is 2.6.31.


<pre>
Next it is recommended you search in the following selective and discriminating PPAs:  
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++
</pre>


Check the versions again to make sure that the correct version 4.1 is now used.
* Alessio Igor Bogani's PPA - [https://launchpad.net/%7Eabogani/+archive/ppa https://launchpad.net/~abogani/+archive/ppa]
* Ubuntu Studio Developer's PPA - [https://launchpad.net/%7Eubuntustudio-dev/+archive/ppa https://launchpad.net/~ubuntustudio-dev/+archive/ppa]


==Install Matlab 2007b==
'''It is not recommended to use kernels from unknown or untested PPA's!''' You do not know what configuration were used or how it was built and an unstable (or unbootable) system could be the result. '''Use only trusted PPA's'''
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


<pre>
Please note that [https://wiki.ubuntu.com/AlessioIgorBogani Alessio Igor Bogani] has been the Ubuntu Studio kernel maintainer for several releases and has the support of the Ubuntu Studio team.
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
</pre>


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
== Kernel Confusion ==


<pre>
Some confusion persists about the purposes of -lowlatency and -realtime kernels.
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# cd /usr/local/bin
root@devpcX:/usr/local/bin# gedit matlab
</pre>


Add the following at line 183 just after all the comments
The goal of -realtime and -rt (hard real-time) kernels is to achieve the lowest possible latency at every cost. In technical slang hard realtime systems should always meet their deadlines. Thus developers should use the most advanced programming techniques (sleeping spinlocks, PI Mutex, Full preemption, IRQ Threads and others) and sacrifice things like reliability, power-saving and throughput. Almost all parts of kernel should be analysed to guarantee that right behaviour always occurs.


<pre>
The goal of -preempt and -lowlatency (soft real-time) kernels is to achieve good realtime characteristics, meanwhile offering welcomed features like rock-solid reliability, good power-saving features and also good throughput. But in this way it can't guarantee lowest latency under all conditions.
export MATLAB_JAVA=/usr/lib/jvm/java-6-sun-1.6.0.14/jre
</pre>


Save and close the file. Now you can start matlab. Always start matlab as a superuser/root so


<pre>
===FAQ: from [https://wiki.ubuntu.com/RealTime Ubuntu Wiki]===
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# matlab
</pre>


==Change mex options==
''Q'': What is the difference between an -rt kernel and a -realtime kernel?
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


<pre>
''A'': From a technical point of view, -rt and -realtime are the same kernel. They are both based on the PREEMPT_RT patchset, although the version may be different. The main difference is that the -rt kernel should be based on the Ubuntu source tree (and therefore can use the same features, patches, enabled hardware, security fixes and so on) and should offer the same services that the Ubuntu default -generic kernel offers. For example, it should be compatible with closed video drivers (nvidia and fglrx), any external DKMS drivers, and have available backport packages. The goal of an -rt kernel is to obtain a real time variant of the Ubuntu kernel that is aligned with the -generic kernel.
>> mex -setup
</pre>


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.
On the other hand, the -realtime kernel is a PREEMPT_RT patched kernel based on the vanilla source tree (not the Ubuntu source). This kernel will be missing Ubuntu specific code, patches or security fixes and it isn't guaranteed to be compatible with any external software (low level utilities, DKMS drivers and so on). It does not use the same Linux kernel version as the -generic kernel, and so these two kernels are not aligned. It is a working, upstream real-time kernel that is being used on Ubuntu. No more no less.
 
==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
 
<pre>
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# cd Desktop
root@devpcX:/home/robocup/Desktop# mv linux-2.6.28.3 /usr/src
</pre>
 
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
 
<pre>
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
</pre>
 
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
 
<pre>
robocup@devpcX:~$ uname -r
</pre>
 
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
 
<pre>
robocup@devpcX:~$ su
root@devpcX:/home/robocup# ifconfig eth0 mtu 9200
</pre>
 
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
 
<pre>
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
</pre>
 
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
 
<pre>
robocup@devpcX:~$ su
root@devpcX:/home/robocup# cd /home/robocup/Desktop
root@devpcX:/home/robocup/Desktop# mv smartsvn-5_0_4 /usr/local
</pre>
 
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.
 
<pre>
robocup@devpcX:~$ su
root@devpcX:/home/robocup# gedit /usr/local/smartsvn-5_0_4/bin/smartsvn.sh
</pre>
 
Uncomment and edit the JAVA_HOME as follows
 
<pre>
JAVA_HOME=/usr
</pre>
 
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
 
<pre>
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
</pre>
 
Always start SmartSVN as a normal user by typing
 
<pre>
robocup@devpcX:~$ smartsvn
</pre>
 
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
 
<pre>
>> make_all_install
</pre>
 
To create the motion executable in matlab go to /home/robocup/svn/trunk/src/Turtle2/Motion and type
 
<pre>
>> build_turtle_motion turtleX
</pre>
 
where X stands for the number of the turtle. Copy the motion executable to the turtle by typing
 
<pre>
>> copy_motion turtleX
</pre>
 
To build and copy the vision go to /home/robocup/svn/trunk/src/Turtle2/Vision
 
<pre>
>> build_turtle_vision turtleX
>> copy_vision turtleX
</pre>
 
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
 
<pre>
>> export AGENT=#devpcnumber+10
>> trc
</pre>
 
=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
 
 
<pre>
robocup@devpcX:~$ su
Password:
root@devpcX:/home/robocup# matlab
</pre>
 
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
 
<pre>
>> cd /home/Robocup/svn/trunk/src/Turtle2/Motion/Tools/Test_connections
>> init_test_connection turtleX
</pre>
 
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
 
<pre>
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
</pre>
 
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.
 
{| border="1" cellpadding="5" cellspacing="0"
|+Test motor
|-
| System    ||  Motor || Current  || Encoder    || Direction
|-
| rowspan="3"| 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
|-
| rowspan="4"| Ball handling
| rowspan="2"|Ball motor left
| +0.05 
|  0-5
| push ball
|-
| -0.05 
|  5-10
| pull ball
|-
| rowspan="2"|Ball motor right
| +0.05 
|  0-5
| push ball
|-
| -0.05 
|  5-10
| pull ball
|-
| Shooting device*
| kick motor
| +0.6
| decrement
| up
|-
| colspan="5" | 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' <u>and set all inputs to zero</u>.

Latest revision as of 14:02, 16 February 2012

  • Check the E-box page for more information.
  • Check Installing a Real-Time Linux Kernel for Dummies by Jeroen de Best & Roel Merry
    • IMPORTANT: When using Ubuntu 10.04 and the linux-rt kernel, in addition to what is mentioned in the above about CPU-scaling, remove the file "/etc/init.d/ondemand" to stop the scaling mode from changing to ondemand 1 minute after startup.


Ubuntu RealTime Kernels

Source: Ubuntu Documentation

Check the source for an up to date version of this subject, the text provided here is for quick reference and was copied from the source when it was last edited on 23-08-2011.

Prerequisite definitions:

kernel - central component of a computer's operating system, bridging between applications and the actual data processing done at the hardware level. See also Wikipedia's Kernel entry.

real-time - an attempt to have deterministic operational deadlines from an event to system response, i.e. the time it takes the computer to respond to an event is known and predictable. A byproduct of this is usually lower latency for audio. See also Wikipedia's Real-time entry.

vanilla kernel source - Linux kernel source code than you can download at www.kernel.org.

Ubuntu kernel source - Linux kernel source code used in Ubuntu and modified for offer all Ubuntu features. You can download it at http://kernel.ubuntu.com/git or simply install binary releases via Synaptic.

Kernel Types

-generic kernel - this is the stock kernel that is provided by default in Ubuntu.

-preempt kernel - this kernel is based on the -generic kernel source tree but is built with different configurations (settings) to reduce latency. Also known as a soft real-time kernel.

-rt kernel - is based on the Ubuntu kernel source tree with Ingo Molnar maintained PREEMPT_RT patch applied to it. Also know as a hard real-time kernel.

-lowlatency kernel - very similar to the -preempt kernel and based on the -generic kernel source tree, but uses a more aggressive configuration to further reduce latency. Also know as a soft real-time kernel.

-realtime kernel - is based on the vanilla kernel source tree with Ingo Molnar maintained PREEMPT_RT patch applied to it. Also know as a hard real-time kernel.

At the moment only the first three kernels are available through official Ubuntu archives.

Choosing a Kernel for Your Use Case

These are some simple guidelines provided to help you understand which kernel, and in which order, you should test to fit your use case.

  • If you do not require low latency for your system then please use the -generic kernel.
  • If you need a low latency system (e.g. for recording audio) then please use the -preempt kernel as a first choice. This reduces latency but doesn't sacrifice power saving features. It is available only for 64 bit systems (also called amd64).
  • If the -preempt kernel does not provide enough low latency for your needs (or you have an 32 bit system) then you should try the -lowlatency kernel.
  • If the -lowlatency kernel isn't enough then you should try the -rt kernel.
  • If the -rt kernel isn't enough stable for you then you should try the -realtime kernel.

Kernel Repositories

Currently, not all kernels are available in the official Ubuntu repositories. The balance may be found in select PPA's.

First attempt to locate the desired kernel in the official Ubuntu repositories by using your choice of package management (i.e. Synaptic or apt-get). Warning - the -rt kernel release can lag behind mainstream, check to the kernel version number! As of this writing, Lucid release, the kernel is 2.6.32 but the -rt kernel available in the Ubuntu repositories is 2.6.31.

Next it is recommended you search in the following selective and discriminating PPAs:

It is not recommended to use kernels from unknown or untested PPA's! You do not know what configuration were used or how it was built and an unstable (or unbootable) system could be the result. Use only trusted PPA's

Please note that Alessio Igor Bogani has been the Ubuntu Studio kernel maintainer for several releases and has the support of the Ubuntu Studio team.

Kernel Confusion

Some confusion persists about the purposes of -lowlatency and -realtime kernels.

The goal of -realtime and -rt (hard real-time) kernels is to achieve the lowest possible latency at every cost. In technical slang hard realtime systems should always meet their deadlines. Thus developers should use the most advanced programming techniques (sleeping spinlocks, PI Mutex, Full preemption, IRQ Threads and others) and sacrifice things like reliability, power-saving and throughput. Almost all parts of kernel should be analysed to guarantee that right behaviour always occurs.

The goal of -preempt and -lowlatency (soft real-time) kernels is to achieve good realtime characteristics, meanwhile offering welcomed features like rock-solid reliability, good power-saving features and also good throughput. But in this way it can't guarantee lowest latency under all conditions.


FAQ: from Ubuntu Wiki

Q: What is the difference between an -rt kernel and a -realtime kernel?

A: From a technical point of view, -rt and -realtime are the same kernel. They are both based on the PREEMPT_RT patchset, although the version may be different. The main difference is that the -rt kernel should be based on the Ubuntu source tree (and therefore can use the same features, patches, enabled hardware, security fixes and so on) and should offer the same services that the Ubuntu default -generic kernel offers. For example, it should be compatible with closed video drivers (nvidia and fglrx), any external DKMS drivers, and have available backport packages. The goal of an -rt kernel is to obtain a real time variant of the Ubuntu kernel that is aligned with the -generic kernel.

On the other hand, the -realtime kernel is a PREEMPT_RT patched kernel based on the vanilla source tree (not the Ubuntu source). This kernel will be missing Ubuntu specific code, patches or security fixes and it isn't guaranteed to be compatible with any external software (low level utilities, DKMS drivers and so on). It does not use the same Linux kernel version as the -generic kernel, and so these two kernels are not aligned. It is a working, upstream real-time kernel that is being used on Ubuntu. No more no less.