Commands from taskbrowser

Hi,


I'm having problems calling commands from taskbrowser. When I call myTask.myCommand() it returns true and the command code executes fine. Afterwards the updateHook finishes processing the command and sets myCommandDone variable to true. However, whenever I press Enter I can see how the completion condition (which checks myCommandDone) is checked, but it always returns false, as if myCommandDone was not set to true.

I've read something about different copies of the command, done depending of the caller, and I guess this has something to do with my problem, but I can't figure it out.

By the way, myCommandDone is a member variable of myTask, as well as myCommand and it's two associated functions.

Any guess of what might I be doing wrong?

Thanks,
Miguel.

Commands from taskbrowser

On Friday 18 July 2008 17:37:10 Miguel Prada Sarasola wrote:
> Hi,
>
> I'm having problems calling commands from taskbrowser. When I call
> myTask.myCommand() it returns true and the command code executes fine.
> Afterwards the updateHook finishes processing the command and sets
> myCommandDone variable to true. However, whenever I press Enter I can
> see how the completion condition (which checks myCommandDone) is
> checked, but it always returns false, as if myCommandDone was not set
> to true.
>
> I've read something about different copies of the command, done
> depending of the caller, and I guess this has something to do with my
> problem, but I can't figure it out.

I don't think so. Even if there are copies, they all call the same functions
(which return the same myCommandDone value). Could you just set 'return
true;' in your completion condition function and see what that gives ?
normally, everytime you press enter in the TB, the completion condition is
checked, until it returns true.

>
> By the way, myCommandDone is a member variable of myTask, as well as
> myCommand and it's two associated functions.

That sound all ok.

>
> Any guess of what might I be doing wrong?

For fast debugging, just do a 'cout'/'printf' in the functions of what you're
doing/returning. That should solve it.

Commands from taskbrowser

El 19/07/2008, a las 18:40, Peter Soetens escribió:

> On Friday 18 July 2008 17:37:10 Miguel Prada Sarasola wrote:
>> Hi,
>>
>> I'm having problems calling commands from taskbrowser. When I call
>> myTask.myCommand() it returns true and the command code executes
>> fine.
>> Afterwards the updateHook finishes processing the command and sets
>> myCommandDone variable to true. However, whenever I press Enter I can
>> see how the completion condition (which checks myCommandDone) is
>> checked, but it always returns false, as if myCommandDone was not set
>> to true.
>>
>> I've read something about different copies of the command, done
>> depending of the caller, and I guess this has something to do with my
>> problem, but I can't figure it out.
>
> I don't think so. Even if there are copies, they all call the same
> functions
> (which return the same myCommandDone value). Could you just set
> 'return
> true;' in your completion condition function and see what that gives ?
> normally, everytime you press enter in the TB, the completion
> condition is
> checked, until it returns true.
>
>>
>> By the way, myCommandDone is a member variable of myTask, as well as
>> myCommand and it's two associated functions.
>
> That sound all ok.
>
>>
>> Any guess of what might I be doing wrong?
>
> For fast debugging, just do a 'cout'/'printf' in the functions of
> what you're
> doing/returning. That should solve it.

In fact, I'm doing some logging and nothing makes sense for me. Here's
how the functions are implemented.

Client.hpp:

class Client : public RTT::TaskContext
{
public:
RTT::Command)> setGains;
...

protected:
bool setGainsFunction(std::vector K);
bool setGainsDone(void);
...

bool KChangeRequested;
bool KChangeAccepted;
}

Client.cpp:

Client::Client( {...} ) : setGains( "SetGains" ,
&Client::setGainsFunction , &Client::setGainsDone , this), ...
{
...
}

bool Client::setGainsFunction(std::vector K)
{
... // do stuff

KChangeRequested = true;

RTT::log << "Requested" << RTT::endlog();

return true;
}

bool Client::setGainsDone(void)
{
if( KChangeAccepted ) {
...
RTT::log << "Gains set" << RTT::endlog();
return true;
}
else {
RTT::log << "Not yet" << RTT::endlog();
return false;
}
}

void Client::updateHook(void)
{
if( KChangeRequested & COMPLETIONCONDITION ) {
KChangeAccepted = true;
RTT::log << "Accepted" << RTT::endlog();
}
}

The thing is that when I call the command, I can see "Requested", a
bit afterwards "Accepted" (which means KChangeAccepted is set to true)
and after that, if I hit Enter I always see "Not yet".

I hope I made myself clear enough. Tell me something if the code is
not understandable enough.

Thanks.
Miguel.

Commands from taskbrowser

On Monday 21 July 2008 13:11:30 Miguel Prada Sarasola wrote:
> > For fast debugging, just do a 'cout'/'printf' in the functions of
> > what you're
> > doing/returning. That should solve it.
>
> In fact, I'm doing some logging and nothing makes sense for me. Here's
> how the functions are implemented.
>
>
> Client.hpp:
>
> class Client : public RTT::TaskContext
> {
> public:
> RTT::Command)> setGains;
> ...
>
> protected:
> bool setGainsFunction(std::vector K);
> bool setGainsDone(void);
> ...
>
> bool KChangeRequested;
> bool KChangeAccepted;
> }
>
>
> Client.cpp:
>
> Client::Client( {...} ) : setGains( "SetGains" ,
> &Client::setGainsFunction , &Client::setGainsDone , this), ...
> {
> ...
> }
>
> bool Client::setGainsFunction(std::vector K)
> {
> ... // do stuff
>
> KChangeRequested = true;
>
> RTT::log << "Requested" << RTT::endlog();
>
> return true;
> }
>
> bool Client::setGainsDone(void)
> {
> if( KChangeAccepted ) {
> ...
> RTT::log << "Gains set" << RTT::endlog();
> return true;
> }
> else {
> RTT::log << "Not yet" << RTT::endlog();
> return false;
> }
> }
>
> void Client::updateHook(void)
> {
> if( KChangeRequested & COMPLETIONCONDITION ) {
> KChangeAccepted = true;
> RTT::log << "Accepted" << RTT::endlog();
> }
> }
>
>
>
> The thing is that when I call the command, I can see "Requested", a
> bit afterwards "Accepted" (which means KChangeAccepted is set to true)
> and after that, if I hit Enter I always see "Not yet".
>
> I hope I made myself clear enough. Tell me something if the code is
> not understandable enough.

Orocos can not influence the value of KChangeAccepted. For some reason, it is
overwritten after updateHook() has been executed. If you can't see what is
going wrong, compile the same program with debugging info (-g -O0) and run it
with valgrind ./my-program. That might show where your bug is, but it might
also not. Look for places where KChangeAccepted is being set to false again.

Peter

Commands from taskbrowser

El 21/07/2008, a las 18:51, Peter Soetens escribió:

> On Monday 21 July 2008 13:11:30 Miguel Prada Sarasola wrote:
>>> For fast debugging, just do a 'cout'/'printf' in the functions of
>>> what you're
>>> doing/returning. That should solve it.
>>
>> In fact, I'm doing some logging and nothing makes sense for me.
>> Here's
>> how the functions are implemented.
>>
>>
>> Client.hpp:
>>
>> class Client : public RTT::TaskContext
>> {
>> public:
>> RTT::Command)> setGains;
>> ...
>>
>> protected:
>> bool setGainsFunction(std::vector K);
>> bool setGainsDone(void);
>> ...
>>
>> bool KChangeRequested;
>> bool KChangeAccepted;
>> }
>>
>>
>> Client.cpp:
>>
>> Client::Client( {...} ) : setGains( "SetGains" ,
>> &Client::setGainsFunction , &Client::setGainsDone , this), ...
>> {
>> ...
>> }
>>
>> bool Client::setGainsFunction(std::vector K)
>> {
>> ... // do stuff
>>
>> KChangeRequested = true;
>>
>> RTT::log << "Requested" << RTT::endlog();
>>
>> return true;
>> }
>>
>> bool Client::setGainsDone(void)
>> {
>> if( KChangeAccepted ) {
>> ...
>> RTT::log << "Gains set" << RTT::endlog();
>> return true;
>> }
>> else {
>> RTT::log << "Not yet" << RTT::endlog();
>> return false;
>> }
>> }
>>
>> void Client::updateHook(void)
>> {
>> if( KChangeRequested & COMPLETIONCONDITION ) {
>> KChangeAccepted = true;
>> RTT::log << "Accepted" << RTT::endlog();
>> }
>> }
>>
>>
>>
>> The thing is that when I call the command, I can see "Requested", a
>> bit afterwards "Accepted" (which means KChangeAccepted is set to
>> true)
>> and after that, if I hit Enter I always see "Not yet".
>>
>> I hope I made myself clear enough. Tell me something if the code is
>> not understandable enough.
>
> Orocos can not influence the value of KChangeAccepted.

That's why, when I read about various copies of the Command, I thought
that it may had something to do with the problem.

> For some reason, it is
> overwritten after updateHook() has been executed.

Well, I'll re-check all the code. It seems that there must be a
mistake somewhere.

> If you can't see what is
> going wrong, compile the same program with debugging info (-g -O0)
> and run it
> with valgrind ./my-program. That might show where your bug is, but
> it might
> also not. Look for places where KChangeAccepted is being set to
> false again.

That can be helpful, thanks.

Commands from taskbrowser

El 22/07/2008, a las 12:47, Miguel Prada Sarasola escribió:

>
> El 21/07/2008, a las 18:51, Peter Soetens escribió:
>
>> On Monday 21 July 2008 13:11:30 Miguel Prada Sarasola wrote:
>>>> For fast debugging, just do a 'cout'/'printf' in the functions of
>>>> what you're
>>>> doing/returning. That should solve it.
>>>
>>> In fact, I'm doing some logging and nothing makes sense for me.
>>> Here's
>>> how the functions are implemented.
>>>
>>>
>>> Client.hpp:
>>>
>>> class Client : public RTT::TaskContext
>>> {
>>> public:
>>> RTT::Command)> setGains;
>>> ...
>>>
>>> protected:
>>> bool setGainsFunction(std::vector K);
>>> bool setGainsDone(void);
>>> ...
>>>
>>> bool KChangeRequested;
>>> bool KChangeAccepted;
>>> }
>>>
>>>
>>> Client.cpp:
>>>
>>> Client::Client( {...} ) : setGains( "SetGains" ,
>>> &Client::setGainsFunction , &Client::setGainsDone , this), ...
>>> {
>>> ...
>>> }
>>>
>>> bool Client::setGainsFunction(std::vector K)
>>> {
>>> ... // do stuff
>>>
>>> KChangeRequested = true;
>>>
>>> RTT::log << "Requested" << RTT::endlog();
>>>
>>> return true;
>>> }
>>>
>>> bool Client::setGainsDone(void)
>>> {
>>> if( KChangeAccepted ) {
>>> ...
>>> RTT::log << "Gains set" << RTT::endlog();
>>> return true;
>>> }
>>> else {
>>> RTT::log << "Not yet" << RTT::endlog();
>>> return false;
>>> }
>>> }
>>>
>>> void Client::updateHook(void)
>>> {
>>> if( KChangeRequested & COMPLETIONCONDITION ) {
>>> KChangeAccepted = true;
>>> RTT::log << "Accepted" << RTT::endlog();
>>> }
>>> }
>>>
>>>
>>>
>>> The thing is that when I call the command, I can see "Requested", a
>>> bit afterwards "Accepted" (which means KChangeAccepted is set to
>>> true)
>>> and after that, if I hit Enter I always see "Not yet".
>>>
>>> I hope I made myself clear enough. Tell me something if the code is
>>> not understandable enough.
>>
>> Orocos can not influence the value of KChangeAccepted.
>
> That's why, when I read about various copies of the Command, I
> thought that it may had something to do with the problem.
>
>> For some reason, it is
>> overwritten after updateHook() has been executed.
>
> Well, I'll re-check all the code. It seems that there must be a
> mistake somewhere.

Well, I feel kind of stupid. In update hook, when I was supposed to
assign KChangeAccepted = true I mistyped, and the line read
KChangeAccepted == true. Comparing, not setting. Sigh...

Now it works fine, sorry for bothering you.

>
>> If you can't see what is
>> going wrong, compile the same program with debugging info (-g -O0)
>> and run it
>> with valgrind ./my-program. That might show where your bug is, but
>> it might
>> also not. Look for places where KChangeAccepted is being set to
>> false again.
>
> That can be helpful, thanks.

Commands from taskbrowser

On Fri, Jul 18, 2008 at 5:37 PM, Miguel Prada Sarasola
<miguel [dot] prada [dot] sarasola [..] ...> wrote:
> Hi,
> I'm having problems calling commands from taskbrowser. When I call
> myTask.myCommand() it returns true and the command code executes fine.
> Afterwards the updateHook finishes processing the command and
> sets myCommandDone variable to true. However, whenever I press Enter I can
> see how the completion condition (which checks myCommandDone) is checked,
> but it always returns false, as if myCommandDone was not set to true.
> I've read something about different copies of the command, done depending of
> the caller, and I guess this has something to do with my problem, but I
> can't figure it out.
> By the way, myCommandDone is a member variable of myTask, as well as
> myCommand and it's two associated functions.
> Any guess of what might I be doing wrong?

Can you show some pseudo code and what you see/expect to see in the
task browser ?

I'm not sure what you mean, but IIRC (i.e., don't take this for
granted!!) the status variable [queued/done/fail] you see in the
taskbrowser normally indicates *only* if a command is
*accepted/rejected* by the receiving taskcontext's commandProcessor,
and does not say anything about the completion condition of the
command.

See

HTH,

Klaas