pal-robotics / ddynamic_reconfigure

89 stars 77 forks source link

Ddynamic_reconfigure doesn't work inside a class #15

Closed k-maheshkumar closed 4 years ago

k-maheshkumar commented 4 years ago

I want to use ddynamic_reconfigure within a class and tried the following example

#include <ros/ros.h>
#include <ddynamic_reconfigure/ddynamic_reconfigure.h>

class Example
{
public:
    Example()
    {
        ddynamic_reconfigure::DDynamicReconfigure ddr;

        int int_param = 10;
        ddr.registerVariable<int>("int_param", &int_param, "param description", -10, 10);
        ddr.publishServicesTopics();
        int_param = 10; //This will also update the dynamic_reconfigure tools with the new value 10
    }
};

int main(int argc, char **argv)
{
    // ROS init stage
    ros::init(argc, argv, "ddynamic_tutorials");
    ros::NodeHandle nh;
    Example e;
    ros::spin();
    return 0;
}

The above code doesn't show anything within the rqt_reconfigure GUI. Am I missing something?

v-lopez commented 4 years ago

The ddr object is destroyed when you exit Example constructo. Make it a member of the class.