Is it simple to control tasks through code rather than through scripts?

I've been spending the last few weeks reading the Orocos manuals in order to evaluate Orocos' functionality as well as experimenting with a port to Visual Studio (which still needs a lot more work).

After reading the Orocos Components Manual I was left with the impression that scripts are the intended mechanism for controlling inter-task communication and that their equivalent is awkward to achieve directly in code. Am I wrong here?

In some scenarios, the application, which we will write, will be required to dynamically sequence the execution of its tasks according to a user's configuration. The number of possible configurations are likely to be too great to handle with simple if .. else statements in scripts. Instead, we may need code that does the following:

1) Holds a collection of tasks e.g. using a vector of tasks.
2) Configures these tasks via data ports.
3) Checks the properties of tasks in this collection to determine their state and when they are ready to execute.
4) Subscribe to events from the tasks in this collection to determine when they have completed execution.
5) Executes these tasks by causing them to run one of their programs or by forcing them to transition into a different state.

In Issue 1.6.0 of the Orocos Components Manual I've seen an example in page 68 of where code causes a program to run (the first part of number 5 above) and an example in page 112 where code seems to subscribe to events (number 4 above).

My question is how elegantly can 2, 3 and the second part of 5 be performed in code? Where scripts fail to supply us with the flexibility that we need can we easily replace them with code?

Thanks for your help.

Is it simple to control tasks through code rather than through s

Sorry for the late reply, kind-of missed this topic...

On Monday 19 January 2009 18:49:19 rparussel [..] ... wrote:
> I've been spending the last few weeks reading the Orocos manuals in order
> to evaluate Orocos' functionality as well as experimenting with a port to
> Visual Studio (which still needs a lot more work).

If everyone who started a port to Visual Studio could just show each other the
code, life would be so much easier (don't take this personal :-). Stuff you at
least might consider is located here:

<https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=605>

>
> After reading the Orocos Components Manual I was left with the impression
> that scripts are the intended mechanism for controlling inter-task
> communication and that their equivalent is awkward to achieve directly in
> code. Am I wrong here?

We aim for equivalence. Yet, state machines are easier to describe in
scripting, we don't really have an equally easy alternative in C++. Also
commands behave differently in C++ as in scripting. In C++ you need to write
code if you want to wait for command completion, in scripting, this is done
automatically for you. Other than that, there is not that much difference.

>
> In some scenarios, the application, which we will write, will be required
> to dynamically sequence the execution of its tasks according to a user's
> configuration. The number of possible configurations are likely to be too
> great to handle with simple if .. else statements in scripts. Instead, we
> may need code that does the following:
>
> 1) Holds a collection of tasks e.g. using a vector of tasks.

In Orocos speak, we would say ' a list of peer TaskContexts'

> 2) Configures these tasks via data ports.

What do you mean ? configure the tasks by connecting data ports or by writing
data to the ports ?

> 3) Checks the properties of tasks in this collection to determine their
> state and when they are ready to execute.
ok.
> 4) Subscribe to events from the
> tasks in this collection to determine when they have completed execution.
ok.
> 5) Executes these tasks by causing them to run one of their programs or by
> forcing them to transition into a different state.
ok.
>
> In Issue 1.6.0 of the Orocos Components Manual I've seen an example in page
> 68 of where code causes a program to run (the first part of number 5 above)
> and an example in page 112 where code seems to subscribe to events (number
> 4 above).
>
> My question is how elegantly can 2, 3 and the second part of 5 be performed
> in code? Where scripts fail to supply us with the flexibility that we need
> can we easily replace them with code?

I need more clarity about what you mean with 2.

For doing 3, make the task a peer and check the properties of the peer like
this:

&#10;TaskContext* peer = this-&gt;getPeer(&quot;task1&quot;);&#10;Property&lt;double&gt; par1 = peer-&gt;properties()-&gt;getProperty&lt;double&gt;(&quot;par1&quot;);&#10;if (par1.value() &gt; some_thing ) {&#10; // ...&#10;}&#10;// etc.&#10;
If you need to do this in real-time, make 'par1' a member variable and do the
getProperty in configureHook() or so. In case every peer has par1, you could
also create an std::vector of Property objects.

For item 5, the best way to force a transition is to emit an event of the task
and react to that event in C++ or in a script statemachine.

To emit an event of a peer task, do:
&#10;TaskContext* peer = this-&gt;getPeer(&quot;task1&quot;);&#10;Event&lt;void(void)&gt; do_change = peer-&gt;events()-&gt;getEvent&lt;void(void)&gt;(&quot;change&quot;);&#10;&#10;do_change(); // emits the event of task1&#10;// etc.&#10;

task1 did register a C++ callback function on its 'change' event.

Hope this helps,
Peter

Thanks Peter, for your

Thanks Peter, for your detailed reply. It will be useful in the near future. I apologise for not replying earlier.

With regard to item 2 that I listed, we would need to write code that wrote data to ports on tasks.

Kind regards

Rick

Is it simple to control tasks through code rather than through

Hello,<br><br>I am also trying in my spare time to port Orocos under Windows with MinGW, which I
think is the quickest way. However, it would be very
interesting to have a Visual Studio port. Considering that MinGW uses the win32
API and CMake can generate Visual Studio projects, I am not very sure of the major differences between the two targets. To date, I managed without too
many problems to: <br><br> - Compile Boost with MinGW <br> - Compile ACE + TAO with MinGW / MSYS <br> - Generate Orocos project with CMake for Eclipse CDT / MinGW <br><br> The next steps are: <br> - Implement the FOSI for win32 <br>
- Add a &quot;win32&quot; target in the CMake files <br><br>
Moreover, if someone has already implemented FOSI for win32, I would
really like to have these files to accelerate our development. <br><br>Also, since I am not
a CMake expert, your help would probably be required when adding the
win32 target.<br><br>Well, for futur tracking this talk would have been better on a more explicit topic. <br><br>Philippe Hamelin<br><br><div class="gmail_quote">2009/1/22 Peter Soetens <span dir="ltr">&lt;<a href="mailto:peter [dot] soetens [..] ...">peter [dot] soetens [..] ...</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Sorry for the late reply, kind-of missed this topic...<br>
<br>
On Monday 19 January 2009 18:49:19 <a href="mailto:rparussel [..] ...">rparussel [..] ...</a> wrote:<br>
&gt; I&#39;ve been spending the last few weeks reading the Orocos manuals in order<br>
&gt; to evaluate Orocos&#39; functionality as well as experimenting with a port to<br>
&gt; Visual Studio (which still needs a lot more work).<br>
<br>
If everyone who started a port to Visual Studio could just show each other the<br>
code, life would be so much easier (don&#39;t take this personal :-). Stuff you at<br>
least might consider is located here:<br>
<br>
&lt;<a href="https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=605" target="_blank">https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=605</a>&gt;<br>
<br>
&gt;<br>
&gt; After reading the Orocos Components Manual I was left with the impression<br>
&gt; that scripts are the intended mechanism for controlling inter-task<br>
&gt; communication and that their equivalent is awkward to achieve directly in<br>
&gt; code. Am I wrong here?<br>
<br>
We aim for equivalence. Yet, state machines are easier to describe in<br>
scripting, we don&#39;t really have an equally easy alternative in C++. Also<br>
commands behave differently in C++ as in scripting. In C++ you need to write<br>
code if you want to wait for command completion, in scripting, this is done<br>
automatically for you. Other than that, there is not that much difference.<br>
<br>
&gt;<br>
&gt; In some scenarios, the application, which we will write, will be required<br>
&gt; to dynamically sequence the execution of its tasks according to a user&#39;s<br>
&gt; configuration. The number of possible configurations are likely to be too<br>
&gt; great to handle with simple if .. else statements in scripts. Instead, we<br>
&gt; may need code that does the following:<br>
&gt;<br>
&gt; 1) Holds a collection of tasks e.g. using a vector of tasks.<br>
<br>
In Orocos speak, we would say &#39; a list of peer TaskContexts&#39;<br>
<br>
&gt; 2) Configures these tasks via data ports.<br>
<br>
What do you mean ? configure the tasks by connecting data ports or by writing<br>
data to the ports ?<br>
<br>
&gt; 3) Checks the properties of tasks in this collection to determine their<br>
&gt; state and when they are ready to execute.<br>
ok.<br>
&gt; 4) Subscribe to events from the<br>
&gt; tasks in this collection to determine when they have completed execution.<br>
ok.<br>
&gt; 5) Executes these tasks by causing them to run one of their programs or by<br>
&gt; forcing them to transition into a different state.<br>
ok.<br>
&gt;<br>
&gt; In Issue 1.6.0 of the Orocos Components Manual I&#39;ve seen an example in page<br>
&gt; 68 of where code causes a program to run (the first part of number 5 above)<br>
&gt; and an example in page 112 where code seems to subscribe to events (number<br>
&gt; 4 above).<br>
&gt;<br>
&gt; My question is how elegantly can 2, 3 and the second part of 5 be performed<br>
&gt; in code? Where scripts fail to supply us with the flexibility that we need<br>
&gt; can we easily replace them with code?<br>
<br>
I need more clarity about what you mean with 2.<br>
<br>
For doing 3, make the task a peer and check the properties of the peer like<br>
this:<br>
<br>
&lt;code&gt;<br>
TaskContext* peer = this-&gt;getPeer(&quot;task1&quot;);<br>
Property&lt;double&gt; par1 = peer-&gt;properties()-&gt;getProperty&lt;double&gt;(&quot;par1&quot;);<br>
if (par1.value() &gt; some_thing ) {<br>
&nbsp;// ...<br>
}<br>
// etc.<br>
&lt;/code&gt;<br>
If you need to do this in real-time, make &#39;par1&#39; a member variable and do the<br>
getProperty in configureHook() or so. In case every peer has par1, you could<br>
also create an std::vector of Property objects.<br>
<br>
For item 5, the best way to force a transition is to emit an event of the task<br>
and react to that event in C++ or in a script statemachine.<br>
<br>
To emit an event of a peer task, do:<br>
&lt;code&gt;<br>
TaskContext* peer = this-&gt;getPeer(&quot;task1&quot;);<br>
Event&lt;void(void)&gt; do_change = peer-&gt;events()-&gt;getEvent&lt;void(void)&gt;(&quot;change&quot;);<br>
<br>
do_change(); // emits the event of task1<br>
// etc.<br>
&lt;/code&gt;<br>
<br>
task1 did register a C++ callback function on its &#39;change&#39; event.<br>
<br>
Hope this helps,<br>
Peter<br>
<br>
--<br>
Peter Soetens -- FMTC -- &lt;<a href="http://www.fmtc.be" target="_blank">http://www.fmtc.be</a>&gt;<br>
<font color="#888888">--<br>
Orocos-Users mailing list<br>
<a href="mailto:Orocos-Users [..] ...">Orocos-Users [..] ...</a><br>
<a href="http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users" target="_blank">http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users</a><br>
<br>
Disclaimer: <a href="http://www.kuleuven.be/cwis/email_disclaimer.htm" target="_blank">http://www.kuleuven.be/cwis/email_disclaimer.htm</a><br>
<br>
</font></blockquote></div><br>

Is it simple to control tasks through code rather than through s

On Jan 22, 2009, at 10:17 , Philippe Hamelin wrote:

> Hello,
>
> I am also trying in my spare time to port Orocos under Windows with
> MinGW, which I think is the quickest way. However, it would be very
> interesting to have a Visual Studio port. Considering that MinGW
> uses the win32 API and CMake can generate Visual Studio projects, I
> am not very sure of the major differences between the two targets.
> To date, I managed without too many problems to:
>
> - Compile Boost with MinGW
> - Compile ACE + TAO with MinGW / MSYS
> - Generate Orocos project with CMake for Eclipse CDT / MinGW

You compiled boost and ACE/TAO from source? What about cmake?

> The next steps are:
> - Implement the FOSI for win32
> - Add a "win32" target in the CMake files

Have you looked at using the pthreads-win32 package? Using its posix
layer and a combination of the gnulinux/macosx fosi's seems the most
straight-forward direction to me. That is certainly the direction I'm
leaning towards, and it sounds like Peter has walked this path
somewhat before ...

Cheers
Stephen

Is it simple to control tasks through code rather than through

Well we are having a discussion on two separates threads :)<br><br><div class="gmail_quote">2009/1/23 S Roderick <span dir="ltr">&lt;<a href="http://kiwi.net">kiwi.net</a>@<a href="http://mac.com">mac.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">On Jan 22, 2009, at 10:17 , Philippe Hamelin wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br>
<br>
I am also trying in my spare time to port Orocos under Windows with MinGW, which I think is the quickest way. However, it would be very interesting to have a Visual Studio port. Considering that MinGW uses the win32 API and CMake can generate Visual Studio projects, I am not very sure of the major differences between the two targets. To date, I managed without too many problems to:<br>

<br>
- Compile Boost with MinGW<br>
- Compile ACE + TAO with MinGW / MSYS<br>
- Generate Orocos project with CMake for Eclipse CDT / MinGW<br>
</blockquote>
<br></div>
You compiled boost and ACE/TAO from source?<br><div class="Ih2E3d"></div></blockquote><div><br>Yes, I compiled Boost and ACE/TAO from source. To compile Boost from source, just download boost-src and bjam-ntx86. Unzip bjam in the boost source directory. Then execute :<br>
<br>bjam --toolset=gcc -sTOOL=mingw install<br><br>This will compile boost, install the headers and lib files in C:\Boost. <br><br>For ACE/TAO, it was quite easy except that I had a compilation problem. There&#39;s a typedef redefinition problem. I had to add a condition into os_types.h of ACE/TAO to not redefine the variable is we are using MINGW. <br>
<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">What about cmake?<br></blockquote><br>I used CMake to generate the Makefiles for MinGW. You can also use the Eclipse CDT/MinGW generator of CMake. <br>
&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The next steps are:<br>
- Implement the FOSI for win32<br>
- Add a &quot;win32&quot; target in the CMake files<br>
</blockquote>
<br></div>
Have you looked at using the pthreads-win32 package? Using its posix layer and a combination of the gnulinux/macosx fosi&#39;s seems the most straight-forward direction to me. &nbsp;That is certainly the direction I&#39;m leaning towards, and it sounds like Peter has walked this path somewhat before ...<br>

</blockquote><div><br>Yes pthreads for windows is something I will consider. However, the semaphore part of the FOSI has to be recoded anyways. Someone has already coded the win32 FOSI and we are still waiting for the patch :-). My direction is a bit different than Peter&#39;s way, since I&#39;m not using Cygwin. By using MinGW I can compile native win32 application without being dependant of the Cygwin DLL, which is not very fast.<br>
&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Cheers<br>
Stephen<br>
<br>
</blockquote></div><br>Regards,<br>Philippe Hamelin<br><br>