Monday, March 16, 2009

A real time tool can not promise your task is real time

A real time tool like Orocos RTT can not promise that your task is real time task.. It just means that you can use it to build real time task.

A simple case is that:
I have two task, one is period task which has lower priority than the other aperiodic task. If aperiodic need more process time than the interval time of period task, the periodic task can not run anymore as it can not get cpu time. So the periodic task is not periodic anymore. Of course ,for periodic task is not realtime. But if aperiodic task has highest priority in the OS, it will be realtime task.

So whether the task is realtime depends on how you design your multi-task. The real time tools like RTAI or RTLINUX ,hence orcos just give you the ability to build your realtime task.

Saturday, March 14, 2009

Orocos: real time multi-task system

What's mean real time?
It does not mean it's fast. It means the task can be finished in a certain time(determination) with out disturbed by system process or user process.
For a period task, it will run and if it was finished in one period, it will wait next period. When it's waiting , the processor will give the time to other process, which can run for a moment, so that the processor can use more time efficiently .

Orocos : the way to trigger nonperiod activity update funtion

For NonPeriod Activity, the updateHook just can work once after start. But how can I make it work when events come or command come?

Three ways to make updateHook work again for NonPeriod activity:
1, The simple way is add trigger in the updateHook function. But this way will waste the processor time. It likes a loop.
2, Using command method. If other task use this NonPeriod activity's command, then it will run again. The NonPeriod activity engine will first run command, and then run updateHook function.
3, Using event method. But event has two kinds. One is synchronous and the other one is asynchronous. Only the asynchronous one can be used to trigger updateHook. The reason is if the call back is in this NonPeriod activity, synchronous only make this call back run in caller's engine but not this NonPeriod activity's engine. Asynchronous will make the call back part work in the NonPeriod activity's engine.

Thursday, March 12, 2009

A way to load module when linux system is booting

If you want load a modules "some.ko" to kernel when system is booting.. You can do this:

$ cd /etc/init.d/
$ sudo gvim "boot.local"

Add follow line in boot.local file:
"insmod /filedirectory/some.ko"

Make the file executable
$ sudo chmod +x boot.local


Make it bootable ..Dont forget the last dot.
$ sudo update-rc.d boot.local start 51 S .



Now If you reboot system ,you will see the that module already was loaded by command "lsmod";

Monday, March 9, 2009

Combination translation and rotation

The order is very important, so rotation before translation is different translation after rotation.
Of course , rotation matrix also can not change the order ...

Remember that..

Sunday, March 8, 2009

How to use "eof()" in c++ file operation

Today I find a interesting problem when I read data from text file.
The code like this:
[code]
vector data;
ofstream os;
os.open("filename");
while(!os.eof())
{
int a;
os>>a;
data.push_back(a);
}
[/code]


After I run this simple program, a problem is there :
The size of vector data is longer 1 than the size of data in the filename.

What's wrong with this program?

I find it because eof is to check error information that when you read data from file.
if "os>>a" is wrong, program still will add a to the vector.
So How to fix that:

[code]

vector data;
ofstream os;
os.open("filename");
int a;
while(os>>a)
{

data.push_back(a);
}
[/code]