Ask Your Question
0

Using the orocos/rtt rosparam service in c++

asked 2012-04-18 15:34:08 -0600

jbohren gravatar image

I'd like to use the rtt_ros_integration rosparam service from within one of my own components in c++. The only documentation I can find for accessing the interface of a service plugin through c++ requires that the service has a class declaration in some header that can be included: http://www.orocos.org/stable/documentation/rtt/v2.x/doc-xml/orocos-rtt-plugins.html#idp216560

Is there a way to do this by leveraging the rtt operations defined in rtt_rosparam_service.cpp?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-04-18 15:58:39 -0600

psoetens gravatar image

updated 2012-04-18 15:59:23 -0600

What you need to do for this particular service is to first load the service:

// In your TaskContext subclass:
PluginLoader::Instance()->loadService("rosparam", this);

And then you could dynamic_cast the service pointer:

boost::shared_ptr<RosParam> rp = boost::dynamic_pointer_cast<RosParam>( this->provides("rosparam") );

rp->storeProperties(); // etc.

UNFORTUNATELY, this service was implemented fully in the .cpp file, so no header is available. What you can do, if you don't want to submit a patch which creates a nice hpp/cpp file and installs the hpp, you can write this as a workaround:

OperationCaller<bool(void)> storeProperties = this->provides("rosparam")->getOperation("storeProperties");

storeProperties(); // calls the Service's Operation.

Peter

edit flag offensive delete link more

Comments

Ahh! I see. After loading the plugin, I was trying this->requires("rosparam")->getOperation("storeProperties"). Thanks!

jbohren gravatar imagejbohren ( 2012-04-18 16:03:34 -0600 )edit
0

answered 2016-08-18 21:48:48 -0600

In my case, I used a simpler method to require the service.


// Within TaskContext class
if (this->loadService("rosparam"))
{
OperationCaller<bool(void)> storeProperties = this->provides("rosparam")->getOperation("storeProperties");
}
 

The benefit is that my code can try to load the service more than one time if it fails at the beginning.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-04-18 15:34:08 -0600

Seen: 523 times

Last updated: Apr 18 '12