[openrtm-users 02549] Re: (no subject)

Geoffrey Biggs geoffrey.biggs @ aist.go.jp
2012年 5月 28日 (月) 18:23:57 JST


There are a few ways to get the state of a component. Which one you should use depends on from where you want to get the state:

- If you want to get the state of a component from another system, such as a tool, you should use the RTC API. THis is the get_component_state() method that ExecutionContexts provide. You need to get object references to the ExecutionContext object and the RT-Component object to use this method. Getting an RT-Component object via the CORBA API will allow you to get the ExecutionObject reference via methods of the RT-Component object (see the LightweightRTObject interface in the RTC standard or the documentation).
- If you want to get the state from inside the component, you can use the same get_component_state() method, but the way to get the ExecutionContext is different. You need to be in one of the life cycle callback methods (onExecute(), onActivated(), etc.), where you receive an ec_id value. You can use that ec_id value, which is known as an ExecutionContextHandle, to get the ExecutionContext object via the RT-Component's context() method. Then you can call get_component_state() on that, passing in a reference to the component. The component must be alive and active for this to work from all methods except for on_startup() and on_shutdown().
- Finally, you can register a callback with the component that will be called when its state changes. This is not part of the RTC API. It uses the SDO interface. There is an example of doing this in the C++ version of OpenRTM-aist. Look under src/ext/sdo/observer/ in the source. This works both from an external program and internally.

Geoff

On May 28, 2012, at 3:52 PM, shanshan1370 @ sina.com wrote:

> There is 'get_component_state()' in ExecutionContext. Is there any other
> method can get the state even when the component was not started?
> 
> _______________________________________________
> openrtm-users mailing list
> openrtm-users @ openrtm.org
> http://www.openrtm.org/mailman/listinfo/openrtm-users



More information about the openrtm-users mailing list