Acquire the status of RTC (EC)

There are two ways to get the error. It can be easily realized with rtctree (library under rtshell), but first, I will explain from the principle point.

1) Poll the EC Query the current state with get_component_state () for the execution context (EC) attached to an RTC. Since this method is polling, if it is heavily used, the speed of the system will be reduced.

I will explain with pseudocode.

 rtc = <Obtain RTC object reference in some way>
 ec_list = rtc.get_owned_contexts();
 switch (ec_list[0].get_component_state(rtc)) {
  case CREATED_STATE:
    printf("Created state.");
    break;
  case INACTIVE_STATE:
    printf("Inactive state.");
    break;
  case ACTIVE_STATE:
    printf("Active state.");
    break;
  case ERROR_STATE:
    printf("Error state.");
   break;
  default:
     printf("Unknown state");
     break;
 }

We first acquire EC from RTC and obtain state by RTC as argument to that EC. The way of calling like this is from the following way of thinking.

The fact that the status of RTC is Inactive-Active-Error is that the state of the RTC It is not the state when an execution context (EC) is associated with an RTC. (That is, the idea is that the state is on the EC side.) It corresponds to figure 5.6 of http://www.omg.org/spec/RTC/.

Since there is usually only EC of its own, it is not a problem to equate the state of EC and state of RTC, but in fact it is understandable that one RTC may be attached to more than one EC Please give me.

2) Using ComponentObserver The other way is to use ComponentObserver (introduced in 1.1.0 or later). ComponentObserver has the following interface, you implement a servant on the side you want to query, and attach this object to RTC so that it calls back when the state changes.

http://svn.openrtm.org/OpenRTM-aist/tags/RELEASE_1_1_0/OpenRTM-aist/src/ext/sdo/observer/ComponentObserver.idl

See @interface ComponentObserver section.

obs_svt = new ComponentOberver_impl(); // servant OpenRTM::ComponentObserver obs_ref = obs_svt._this(); // Object reference SDO::ServiceProfile profile; profile.id = UUID(); profile.interface_type = CORBA_Util::toRepositoryId<OpenRTM::ComponentObserver>(); // rtm/Typename.h CORBA_SeqUtil.push_back(profile.properties, NVUtil::newNV("observed_status", "RTC_STATUS")); CORBA_SeqUtil.push_back(profile.properties, NVUtil::newNV("heartbeat.enable", "YES")); CORBA_SeqUtil.push_back(profile.properties, NVUtil::newNV("heartbeat.interval", "1.0")); profile.service = obs_ref;

rtc = <Obtain RTC object reference in some way> SDO::Configuration conf = rtc.get_configuration(); // SDO::get_configuration() conf.add_service_profile(profile);

When the status changes to ACTIVE, the above ovs_svt ComponentOberver_impl::update_status("RTC_STATUS", "ACTIVE:0"); When the state changes to INACTIVE, ComponentOberver_impl::update_status("RTC_STATUS", "INACTIVE:0"); When the status changes to ERROR, ComponentOberver_impl::update_status("RTC_STATUS", "ERROR:0"); Is called.

By the way, in rtctree under rtshell, for example in the constructor of RTCTree When dynamic = True is set, when the tree object acquires the state of RTC We will use ComponentObserver to get state.

https://github.com/gbiggs/rtctree/blob/master/rtctree/tree.py

Also, using TreeNode :: add_callback () seems to be able to hook events.

https://github.com/gbiggs/rtctree/blob/master/rtctree/node.py

The event name is defined at the bottom of this file. https://github.com/gbiggs/rtctree/blob/master/rtctree/component.py

Download

latest Releases

For Begginers

Windows msi(installer) package (only trying samples)

C++,Python,Java,
Toolsを含む
1.2.1-RELEASE

Development environment is required for RT-Component development. See download page for details.

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