Deactivate RT-component from within a program

9 posts / 0 new
Last post
hong
Offline
Last seen: 12 years 3 months ago
Joined: 2012-01-30 18:19
Deactivate RT-component from within a program

Hi,

How can I deactivate RT-component from within the program? For example, from onExecute, or from other method. An illustrative case is that a user input toggled a bool variable, which is being checked in onExecute to decide if to deactivate (NOT exit) the component. Hope to get some help.

Thanks. Hong

English
hong
Offline
Last seen: 12 years 3 months ago
Joined: 2012-01-30 18:19
[openrtm-users 02409] Deactivate RT-component from within a prog

Hi, How can I deactivate RT-component from within the program? For example,
from onExecute, or from other method. An illustrative case is that a user
input toggled a bool variable, which is being checked in onExecute to decide
if to deactivate (NOT exit) the component. Hope to get some help. Thanks.
Hong

_______________________________________________
openrtm-users mailing list
openrtm-users@openrtm.org
http://www.openrtm.org/mailman/listinfo/openrtm-users

Hajime SAITO
Offline
Last seen: 12 years 4 months ago
Joined: 2011-05-19 11:20
[openrtm-users 02410] Deactivate RT-component from within a pro

Hi,

Are you asking whether the component deactivates itself? Or do you
want to trigger this from outside the component?

You have a choice of using a service port for the trigger, or you can
use a property value that you check from within the onExecute
function.

Cheers,

Hajime

2012年1月31日17:38 :
> Hi, How can I deactivate RT-component from within the program? For example,
> from onExecute, or from other method. An illustrative case is that a user
> input toggled a bool variable, which is being checked in onExecute to decide
> if to deactivate (NOT exit) the component. Hope to get some help. Thanks.
> Hong
>
> _______________________________________________
> openrtm-users mailing list
> openrtm-users@openrtm.org
> http://www.openrtm.org/mailman/listinfo/openrtm-users
_______________________________________________
openrtm-users mailing list
openrtm-users@openrtm.org
http://www.openrtm.org/mailman/listinfo/openrtm-users

root
Offline
Last seen: 10 hours 34 min ago
Joined: 2009-06-23 14:31
[openrtm-users 02411] Deactivate RT-component from within a pro

Hello,

This is an example code in C++.

ReturnCode_t RTObject_impl::onExecute(RTC::UniqueId ec_id)
{
: // you code
if (gotoInactiveState)
{
RTC::ExecutionContext_var ec = get_context(ec_id);
if (CORBA::is_nil(ec))
{
ec->deactivate_component(::RTC::RTObject::_duplicate(getObjRef()));
}
}
: // your code
return RTC::RTC_OK;
}

In the next execution tick, onDeactivated() will be called and
RTC will be in the INACTIVE state.

From OpenRTM-aist-1.1.0, getExecutionContext(), deactivate(),
activate() and reset() functions are introduced in DataflowComponentBase.

Best regards,
Noriaki ANDO

2012年1月31日17:38 :
> Hi, How can I deactivate RT-component from within the program? For example,
> from onExecute, or from other method. An illustrative case is that a user
> input toggled a bool variable, which is being checked in onExecute to decide
> if to deactivate (NOT exit) the component. Hope to get some help. Thanks.
> Hong
>
> _______________________________________________
> openrtm-users mailing list
> openrtm-users@openrtm.org
> http://www.openrtm.org/mailman/listinfo/openrtm-users
_______________________________________________
openrtm-users mailing list
openrtm-users@openrtm.org
http://www.openrtm.org/mailman/listinfo/openrtm-users

hong
Offline
Last seen: 12 years 3 months ago
Joined: 2012-01-30 18:19
[openrtm-users 02412] Deactivate RT-component from within a pro

Thank you very much, Ando-san, Hajime-san.I had to invert the condition to !CORBA::is_nil(ec) to make it work.Hope I am not doing anything wrong.  I don't exactly get the meaning of CORBA::is_null(obj), however the document says it checks if the obj is nil.

RegardsHong2012/1/31 Ando Noriaki <n-ando@aist.go.jp>

Hello,

This is an example code in C++.

 ReturnCode_t RTObject_impl::onExecute(RTC::UniqueId ec_id)
 {
    : // you code
 if (gotoInactiveState)
   {
     RTC::ExecutionContext_var ec = get_context(ec_id);
     if (CORBA::is_nil(ec))
      {
         ec->deactivate_component(::RTC::RTObject::_duplicate(getObjRef()));
      }
   }
    : // your code
  return RTC::RTC_OK;
 }

 In the next execution tick, onDeactivated() will be called and
RTC will be in the INACTIVE state.

From OpenRTM-aist-1.1.0, getExecutionContext(), deactivate(),
activate() and reset() functions are introduced in DataflowComponentBase.

Best regards,
Noriaki ANDO

2012年1月31日17:38  <owh@ieee.org>:
> Hi, How can I deactivate RT-component from within the program? For example,
> from onExecute, or from other method. An illustrative case is that a user
> input toggled a bool variable, which is being checked in onExecute to decide
> if to deactivate (NOT exit) the component. Hope to get some help. Thanks.
> Hong
>
> _______________________________________________
> openrtm-users mailing list
> openrtm-users@openrtm.org
> http://www.openrtm.org/mailman/listinfo/openrtm-users
_______________________________________________
openrtm-users mailing list
openrtm-users@openrtm.org
http://www.openrtm.org/mailman/listinfo/openrtm-users

root
Offline
Last seen: 10 hours 34 min ago
Joined: 2009-06-23 14:31
[openrtm-users 02414] Deactivate RT-component from within a pro

Hello

Oh! It's my mistake.

CORBA::is_nil(object) means the object's reference is invalid.
# It's almost same as null pointer in C/C++ or Java.

If CORBA::is_nil(object) == true, you cannot call any operations of the object.

2012年1月31日22:16 Ong Wee Hong :
> Thank you very much, Ando-san, Hajime-san.
>
> I had to invert the condition to !CORBA::is_nil(ec) to make it work.
> Hope I am not doing anything wrong. I don't exactly get the meaning of
> CORBA::is_null(obj), however the document says it checks if the obj is nil.
>
> Regards
> Hong
>
> 2012/1/31 Ando Noriaki
>>
>> Hello,
>>
>> This is an example code in C++.
>>
>> ReturnCode_t RTObject_impl::onExecute(RTC::UniqueId ec_id)
>> {
>> : // you code
>> if (gotoInactiveState)
>> {
>> RTC::ExecutionContext_var ec = get_context(ec_id);
>> if (CORBA::is_nil(ec))
>> {
>>
>> ec->deactivate_component(::RTC::RTObject::_duplicate(getObjRef()));
>> }
>> }
>> : // your code
>> return RTC::RTC_OK;
>> }
>>
>> In the next execution tick, onDeactivated() will be called and
>> RTC will be in the INACTIVE state.
>>
>> From OpenRTM-aist-1.1.0, getExecutionContext(), deactivate(),
>> activate() and reset() functions are introduced in DataflowComponentBase.
>>
>> Best regards,
>> Noriaki ANDO
>>
>> 2012年1月31日17:38 :
>> > Hi, How can I deactivate RT-component from within the program? For
>> > example,
>> > from onExecute, or from other method. An illustrative case is that a
>> > user
>> > input toggled a bool variable, which is being checked in onExecute to
>> > decide
>> > if to deactivate (NOT exit) the component. Hope to get some help.
>> > Thanks.
>> > Hong
>> >
>> > _______________________________________________
>> > openrtm-users mailing list
>> > openrtm-users@openrtm.org
>> > http://www.openrtm.org/mailman/listinfo/openrtm-users
>> _______________________________________________
>> openrtm-users mailing list
>> openrtm-users@openrtm.org
>> http://www.openrtm.org/mailman/listinfo/openrtm-users
>
>
>
> _______________________________________________
> openrtm-users mailing list
> openrtm-users@openrtm.org
> http://www.openrtm.org/mailman/listinfo/openrtm-users
>

hong
Offline
Last seen: 12 years 3 months ago
Joined: 2012-01-30 18:19
[openrtm-users 02415] Deactivate RT-component from within a pro

Thanks a lot for the clarification!
Regards
Hong
在 2012-1-31 下午11:01,"Ando Noriaki" <n-ando@aist.go.jp>写道:
>
> Hello
>
> Oh! It's my mistake.
>
> CORBA::is_nil(object) means the object's reference is invalid.
> # It's almost same as null pointer in C/C++ or Java.
>
> If CORBA::is_nil(object) == true, you cannot call any operations of the object.
>
>
> 2012年1月31日22:16 Ong Wee Hong <owh@ieee.org>:
> > Thank you very much, Ando-san, Hajime-san.
> >
> > I had to invert the condition to !CORBA::is_nil(ec) to make it work.
> > Hope I am not doing anything wrong.  I don't exactly get the meaning of
> > CORBA::is_null(obj), however the document says it checks if the obj is nil.
> >
> > Regards
> > Hong

hong
Offline
Last seen: 12 years 3 months ago
Joined: 2012-01-30 18:19
Deactivate RT-component from

Thank you very much, Ando-san, Hajime-san.

I had to invert the condition to !CORBA::is_nil(ec) to make it work. Hope I am not doing anything wrong. I don't exactly get the meaning of CORBA::is_null(obj), however the document says it checks if the obj is nil.

Regards Hong PS. Apology for the mess of the posts, still getting accustomed to the forum. I hope this one goes to the right place.

hong
Offline
Last seen: 12 years 3 months ago
Joined: 2012-01-30 18:19
[openrtm-users 02413] Deactivate RT-component from

Thank you very much, Ando-san, Hajime-san. I had to invert the condition to
!CORBA::is_nil(ec) to make it work. Hope I am not doing anything wrong. I
don't exactly get the meaning of CORBA::is_null(obj), however the document
says it checks if the obj is nil. Regards Hong PS. Apology for the mess of
the posts, still getting accustomed to the forum. I hope this one goes to the
right place.

_______________________________________________
openrtm-users mailing list
openrtm-users@openrtm.org
http://www.openrtm.org/mailman/listinfo/openrtm-users

Log in or register to post comments

Download

latest Releases : 2.0.0-RELESE

2.0.0-RELESE Download page

Number of Projects

Choreonoid

Motion editor/Dynamics simulator

OpenHRP3

Dynamics simulator

OpenRTP

Integrated Development Platform

AIST RTC collection

RT-Components collection by AIST

TORK

Tokyo Opensource Robotics Association

DAQ-Middleware

Middleware for DAQ (Data Aquisition) by KEK