orocos / rtt_ros_integration

Orocos-ROS integration libraries and tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rtt_dynamic_reconfigure example?

dustingooding opened this issue · comments

Is there a "hello world" level example of how to actually use rtt_dynamic_reconfigure?

Specifically, I'm trying to call advertise from within my component's configureHook and I'm struggling at getting the proper type.

This is as close as I've gotten:

# outside of the component
deployer.loadService("my_component", "my_pkg_reconfigure");

# inside my_component
boost::shared_ptr<rtt_dynamic_reconfigure::Server<my_namespace::MyPkgConfig>> reconfigure =
        this->getProvider<rtt_dynamic_reconfigure::Server<my_namespace::MyPkgConfig>>("reconfigure");
if (reconfigure)
{
    reconfigure->advertise();
}

But I get this error:

In file included from /opt/orocos/melodic/include/rtt/RTT.hpp:53:0,
                 from /root/my_ws/src/my_pkg/include/my_pkg/my_component.hpp:20,
                 from /root/my_ws/src/my_pkg/src/my_component.cpp:8:
/opt/orocos/melodic/include/rtt/TaskContext.hpp: In instantiation of ‘boost::shared_ptr<X> RTT::TaskContext::getProvider(const string&) [with ServiceType = rtt_dynamic_reconfigure::Server<my_namespace::MyPkgConfig>; std::__cxx11::string = std::__cxx11::basic_string<char>]’:
/root/my_ws/src/my_pkg/src/my_component.cpp:115:111:   required from here
/opt/orocos/melodic/include/rtt/TaskContext.hpp:306:17: error: ‘class rtt_dynamic_reconfigure::Server<my_namespace::MyPkgConfig>’ has no member named ‘connectTo’
             st->connectTo( provides(name) );

I've also tried with rtt_dynamic_reconfigure::Server<rtt_dynamic_reconfigure::AutoConfig> to no avail. Same error.

Can I get some help?

Turns out I was holding it wrong...

I was doing the right thing outside of the component. But this is what should be happening inside.

    RTT::Service::shared_ptr reconfigure = this->provides("my_pkg_reconfigure");

    if (reconfigure)
    {
        if (reconfigure->hasOperation("advertise"))
        {
            RTT::OperationCaller<void(std::string)> op_advertise = reconfigure->getOperation("advertise");

            op_advertise("~");
        }
    }

I guess this ticket is more about "can some form of this snippet be added to the README".