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)) {
    printf("Created state.");
    printf("Inactive state.");
    printf("Active state.");
    printf("Error state.");
     printf("Unknown state");

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

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.

See @interface ComponentObserver section.

obs_svt = new ComponentOberver_impl(); // servant OpenRTM::ComponentObserver obs_ref = obs_svt._this(); // Object reference SDO::ServiceProfile profile; = UUID(); profile.interface_type = CORBA_Util::toRepositoryId<OpenRTM::ComponentObserver>(); // rtm/Typename.h CORBA_SeqUtil.push_back(, NVUtil::newNV("observed_status", "RTC_STATUS")); CORBA_SeqUtil.push_back(, NVUtil::newNV("heartbeat.enable", "YES")); CORBA_SeqUtil.push_back(, 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.

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

The event name is defined at the bottom of this file.


latest Releases : 2.0.0-RELESE

2.0.0-RELESE Download page

Number of Projects


Motion editor/Dynamics simulator


Dynamics simulator


Integrated Development Platform

AIST RTC collection

RT-Components collection by AIST


Tokyo Opensource Robotics Association


Middleware for DAQ (Data Aquisition) by KEK