Re: How to build an Orocos application

[email protected]
Newsgroups gmane.science.robotics.orocos.user
Organization KU Leuven
Message-ID <[email protected]>
On Wednesday 15 January 2003 11:50, [email protected] 
wrote:
> I need to write a simple orocos application.
> I want to create:
>  3 RT processes (ZTT),
> 1 RT process (ZLT),
> 1 Not-RT process in user space.
> All ZTT processes must be connected with ZLT Process by fifo's,
> The not-RT process  must be connected to ZLT process,
> What are the guide lines that I need to follow to reach my goal?
> In the orocos core (0.9.0) there are some test file,but they are very hard
> to understand!
> What are the most important files for my purpose?


you could do the following :

write task 1 :

#include <TaskNonPreemptible.hpp>

class TaskOne : public TaskNonPreemptible
{
public:
	TaskOne() 
	: TaskNonPreemptible(0.001)   // period is 1ms
	{ // constructor, executed once on new ... }
	~TaskOne()        { // destructor, executed on delete ... }
	void initialise() { // your init code ... }
	void step()       { // your periodic task code ... }
	void finalise()   { // your finalise code .. }
}; // tada !

do the same for process 2 and 3
Do the same for the preemptible process but write :

class TaskFour : public TaskPreemptible
{ ...};

then in your startup file ( say example.cpp )


TaskOne* task1;
void initFunction()
{
	task1 = new TaskOne(); // constructor called
	task1->start();        // initialise is called once
				// step is executed periodically
}

void termFunction()
{
	task1->stop();         // step is no longer called, finalise is called.
	delete task1;          // call destructor
}	


now you only have to call these functions in your init_module and 
cleanup_module functions (take a look at moduleStartStop.c or so in the 
core/src directory )

The userspace process can have a main() function where it opens a fifo to 
communicate with the kernel.

to set up communication, i advise only to use fifos between kernel space and 
user space, and use the STL queue<YourType> for communication between two 
tasks. For fifos, look at the FifoRT[In/Out].hpp and FifoUS[In/Out].hpp files 
or documentation.

I am very aware of the lack of clear example programs, but i urge you to read 
the documentation and make sure you understand it. The online API (see link 
documentation on the orocos website) also helps you in discovering what's 
there.

Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.