max number of commands called on a component

Using Orocos 1.10

Hello, I try to call many many commands on a component. I would like to know if there is a limitation of the number of command which could be called before the receiver component executed it (I think 16 :-P).

I don't care of the activity of ComponentA. ComponentB has nonPeriodicActivity, is scheduled RT (on linux, for the test :-P)

To explain, an example of code

ComponentA::mthDoPostCommandToB(nbPosts)
{
    TaskContext* ComponentB = getPeer("ComponentB");
    Command<bool()> cmdDisplayOfB;
 
    boost::array <Command<bool()>, 500> listCmd;
 
    cmdDisplayOfB = ComponentB->commands()->getCommand<bool()>("cmdDisplay");
    if( cmdDisplayOfB.ready() == false)
    {
        log(Error) << "cmdDisplayOfB is not ready" << endlog();
    }
    else
    {
       for (int32_t i = 0 ; i < nbPosts; ++i)
    {
        list[i] = cmdDisplayOfB; //making a copy
    }
    for (int32_t i = 0 ; i < nbAppel; ++i)
    {
        list[i]();
        cout << "cmdDisplayOfB: " << &list[i] << endl;
    }
    sleep(1000); //to not loose the commands of the list
}
 
bool
ComponentB::cmdDoDisplay()
{
    cout << "Step " << m_i << endl;
    ++m_i; 
    static int i = 0;
    if (i == 0)
    {
        sleep(1);
        ++i;
    }
    return true;
}
bool
ComponentB::cmdDisplayDone()
{
    return true;
}
So on the TaskBrowser:
ComponentA.mthDoPostCommandToB(50)
 
The display is
 
Post 0 (the first execution is begun because all the posts, but is long (because sleep(1))
 
Post 1
Post 2
...
Post 16

Am I right? How can I increase the number of commands? Thanks. Guillaume

max number of commands called on a component

On Thursday 23 December 2010 12:30:53 gde [..] ... wrote:
> Using Orocos 1.10
>
> Hello,
> I try to call many many commands on a component. I would like to know if
> there is a limitation of the number of command which could be called
> before the receiver component executed it (I think 16 :-P).
>
> I don't care of the activity of ComponentA.
> ComponentB has nonPeriodicActivity, is scheduled RT (on linux, for the test
> :-P)
>
> To explain, an example of code
> &#10;&gt; ComponentA::mthDoPostCommandToB(nbPosts)&#10;&gt; {&#10;&gt;     TaskContext* ComponentB = getPeer(&quot;ComponentB&quot;);&#10;&gt;     Command&lt;bool()&gt; cmdDisplayOfB;&#10;&gt; &#10;&gt;     boost::array &lt;Command&lt;bool()&gt;, 500&gt; listCmd;&#10;&gt; &#10;&gt;     cmdDisplayOfB =&#10;&gt; ComponentB-&gt;commands()-&gt;getCommand&lt;bool()&gt;(&quot;cmdDisplay&quot;); if(&#10;&gt; cmdDisplayOfB.ready() == false)&#10;&gt;     {&#10;&gt;         log(Error) &lt;&lt; &quot;cmdDisplayOfB is not ready&quot; &lt;&lt; endlog();&#10;&gt;     }&#10;&gt;     else&#10;&gt;     {&#10;&gt;        for (int32_t i = 0 ; i &lt; nbPosts; ++i)&#10;&gt;     {&#10;&gt;         list[i] = cmdDisplayOfB; //making a copy&#10;&gt;     }&#10;&gt;     for (int32_t i = 0 ; i &lt; nbAppel; ++i)&#10;&gt;     {&#10;&gt;         list[i]();&#10;&gt;         cout &lt;&lt; &quot;cmdDisplayOfB: &quot; &lt;&lt; &amp;list[i] &lt;&lt; endl;&#10;&gt;     }&#10;&gt;     sleep(1000); //to not loose the commands of the list&#10;&gt; }&#10;&gt; &#10;&gt; bool&#10;&gt; ComponentB::cmdDoDisplay()&#10;&gt; {&#10;&gt;     cout &lt;&lt; &quot;Step &quot; &lt;&lt; m_i &lt;&lt; endl;&#10;&gt;     ++m_i;&#10;&gt;     static int i = 0;&#10;&gt;     if (i == 0)&#10;&gt;     {&#10;&gt;         sleep(1);&#10;&gt;         ++i;&#10;&gt;     }&#10;&gt;     return true;&#10;&gt; }&#10;&gt; bool&#10;&gt; ComponentB::cmdDisplayDone()&#10;&gt; {&#10;&gt;     return true;&#10;&gt; }&#10;&gt;
> So on the TaskBrowser:
> &#10;&gt; ComponentA.mthDoPostCommandToB(50)&#10;&gt; &#10;&gt; The display is&#10;&gt; &#10;&gt; Post 0 (the first execution is begun because all the posts, but is long&#10;&gt; (because sleep(1))&#10;&gt; &#10;&gt; Post 1&#10;&gt; Post 2&#10;&gt; ...&#10;&gt; Post 16&#10;&gt;
>
> Am I right?
> How can I increase the number of commands?

Startup ccmake and change the ORONUM_EXECUTION_PROC_QUEUE_SIZE flag from 16 to
something else (this is at compile time, for all components).

If you want even more control, you'll need to use
engine()->setCommandProcessor( new CommandProcessor(100) ) in each component
that requires it (for example, hard-coding it in the component's constructor).

Peter

max number of commands

Thanks a lot : I tried the second way (using engine()->setCommandProcessor( new CommandProcessor(100) ) ) ... but the new engine must be created before the initialization of the command.
So, we cannot write (without a seg fault):
&#10;ComponentB::ComponentB(const std::string&amp; name) :&#10;                 TaskContext(),&#10;                        cmdDisplay(&quot;cmdDisplay&quot;, &amp;ComponentB::cmdDoDisplay, &amp;ComponentB::cmdDisplayDone, this)&#10;{&#10;    engine()-&gt;setCommandProcessor( new CommandProcessor(100) );&#10;    this-&gt;commands()-&gt;addCommand(&amp;cmdDisplay, &quot;cmdDisplay&quot;);&#10;}&#10;

We must write :
&#10;ComponentB::ComponentB(const std::string&amp; name) :&#10;                 TaskContext()&#10;{&#10;    engine()-&gt;setCommandProcessor( new CommandProcessor(100) );&#10;    cmdDisplay = Command(&quot;cmdDisplay&quot;, &amp;ComponentB::cmdDoDisplay, &amp;ComponentB::cmdDisplayDone, this);&#10;    this-&gt;commands()-&gt;addCommand(&amp;cmdDisplay, &quot;cmdDisplay&quot;);&#10;}&#10;

A last question : is the original CommandProcessor deleted by anybody when we replace it by "new CommandProcessor(16)" ?

max number of commands called on a component

Thanks a lot : I tried the second way (using engine()->setCommandProcessor( new CommandProcessor(100) ) ) ... but the new engine must be created before the initialization of the command. So, we cannot write (without a seg fault):

ComponentB::ComponentB(const std::string& name) :
            TaskContext(),
                        cmdDisplay("cmdDisplay", &ComponentB::cmdDoDisplay, &ComponentB::cmdDisplayDone, this)
{
    engine()->setCommandProcessor( new CommandProcessor(100) );
    this->commands()->addCommand(&cmdDisplay, "cmdDisplay");
}

We must write :

ComponentB::ComponentB(const std::string& name) :
            TaskContext()
{
    engine()->setCommandProcessor( new CommandProcessor(100) );
    cmdDisplay = Command("cmdDisplay", &ComponentB::cmdDoDisplay, &ComponentB::cmdDisplayDone, this);
    this->commands()->addCommand(&cmdDisplay, "cmdDisplay");
}

A last question : is the original CommandProcessor deleted by anybody when we replace it by "new CommandProcessor(16)" ?

max number of commands

On Thursday 23 December 2010 14:47:05 gde [..] ... wrote:
> Thanks a lot : I tried the second way (using engine()->setCommandProcessor(
> new CommandProcessor(100) ) ) ... but the new engine must be created
> before the initialization of the command. So, we cannot write (without a
> seg fault):
> &#10;&gt; ComponentB::ComponentB(const std::string&amp; name) :&#10;&gt;                        TaskContext(),&#10;&gt;                         cmdDisplay(&quot;cmdDisplay&quot;, &amp;ComponentB::cmdDoDisplay,&#10;&gt; &amp;ComponentB::cmdDisplayDone, this) {&#10;&gt;     engine()-&gt;setCommandProcessor( new CommandProcessor(100) );&#10;&gt;     this-&gt;commands()-&gt;addCommand(&amp;cmdDisplay, &quot;cmdDisplay&quot;);&#10;&gt; }&#10;&gt;
>
> We must write :
> &#10;&gt; ComponentB::ComponentB(const std::string&amp; name) :&#10;&gt;                        TaskContext()&#10;&gt; {&#10;&gt;     engine()-&gt;setCommandProcessor( new CommandProcessor(100) );&#10;&gt;     cmdDisplay = Command(&quot;cmdDisplay&quot;, &amp;ComponentB::cmdDoDisplay,&#10;&gt; &amp;ComponentB::cmdDisplayDone, this);&#10;&gt; this-&gt;commands()-&gt;addCommand(&amp;cmdDisplay, &quot;cmdDisplay&quot;);&#10;&gt; }&#10;&gt;
>
> A last question : is the original CommandProcessor deleted by anybody when
> we replace it by "new CommandProcessor(16)" ?

Yes. the setCommandProcessor deletes the old instance. That's why you got the
crash as well. You might, for convenience, write a base class component that
has this larger commandprocessor such that you can keep your existing command
initialisation code in the constructor.

Peter

max number of commands

I got the same conclusion : but does my component herit some command from TaskContext?
Increase the number of command does have effect on performances (if all the capacity is not used)?

max number of commands

I got the same conclusion : but does my component herit some command from TaskContext? Increase the number of command does have effect on performances (if all the capacity is not used)?

max number of commands

On Thursday 23 December 2010 15:44:30 gde [..] ... wrote:
> I got the same conclusion : but does my component herit some command from
> TaskContext?

They are all methods. So they don't use the command processor.

> Increase the number of command does have effect on
> performances (if all the capacity is not used)?

No, but you shouldn't have a queue much larger than 100-200 items, since the
lock-free algorithms in 1.x can't handle much more than that efficiently.

Peter

max number of commands called on a component

Using Orocos 1.10

Hello,
I try to call many many commands on a component. I would like to know if there is a limitation of the number of command which could be called before the receiver component executed it (I think 16 :-P).

I don't care of the activity of ComponentA.
ComponentB has nonPeriodicActivity, is scheduled RT (on linux, for the test :-P)

To explain, an example of code
&#10;ComponentA::mthDoPostCommandToB(nbPosts)&#10;{&#10;    TaskContext* ComponentB = getPeer(&quot;ComponentB&quot;);&#10;    Command&lt;bool()&gt; cmdDisplayOfB;&#10;&#10;    boost::array &lt;Command&lt;bool()&gt;, 500&gt; listCmd;&#10;&#10;    cmdDisplayOfB = ComponentB-&gt;commands()-&gt;getCommand&lt;bool()&gt;(&quot;cmdDisplay&quot;);&#10;    if( cmdDisplayOfB.ready() == false)&#10;    {&#10;        log(Error) &lt;&lt; &quot;cmdDisplayOfB is not ready&quot; &lt;&lt; endlog();&#10;    }&#10;    else&#10;    {&#10;       for (int32_t i = 0 ; i &lt; nbPosts; ++i)&#10;    {&#10;        list[i] = cmdDisplayOfB; //making a copy&#10;    }&#10;    for (int32_t i = 0 ; i &lt; nbAppel; ++i)&#10;    {&#10;        list[i]();&#10;        cout &lt;&lt; &quot;cmdDisplayOfB: &quot; &lt;&lt; &amp;list[i] &lt;&lt; endl;&#10;    }&#10;    sleep(1000); //to not loose the commands of the list&#10;}&#10;&#10;bool&#10;ComponentB::cmdDoDisplay()&#10;{&#10;    cout &lt;&lt; &quot;Step &quot; &lt;&lt; m_i &lt;&lt; endl;&#10;    ++m_i; &#10;    static int i = 0;&#10;    if (i == 0)&#10;    {&#10;        sleep(1);&#10;        ++i;&#10;    }&#10;    return true;&#10;}&#10;bool&#10;ComponentB::cmdDisplayDone()&#10;{&#10;    return true;&#10;}&#10;
So on the TaskBrowser:
&#10;ComponentA.mthDoPostCommandToB(50)&#10;&#10;The display is&#10;&#10;Post 0 (the first execution is begun because all the posts, but is long (because sleep(1))&#10;&#10;Post 1&#10;Post 2&#10;...&#10;Post 16&#10;

Am I right?
How can I increase the number of commands?
Thanks.
Guillaume