Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtt_dynamic_reconfigure example? #160

Open
dustingooding opened this issue Nov 12, 2020 · 1 comment
Open

rtt_dynamic_reconfigure example? #160

dustingooding opened this issue Nov 12, 2020 · 1 comment

Comments

@dustingooding
Copy link

dustingooding commented Nov 12, 2020

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?

@dustingooding
Copy link
Author

dustingooding commented Nov 12, 2020

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant