skm
skm

Reputation: 5679

Use dynamic reconfiguration to set the parameter value in ROS

I am new to ROS and i want to use Dynamic reconfiguration technique to set a parameter (rectangle_height).

Through internet i came across with the following method but its not working.

Problem: when i run rqt_reconfigure, in that my node (visual_analysis) is not visual so i can't change the parameter.

-In my Includes, i have included the following:

#include <dynamic_reconfigure/DoubleParameter.h>
#include <dynamic_reconfigure/Reconfigure.h>
#include <dynamic_reconfigure/Config.h>

-In my main() where my variable is declared, i have written the following:

int main( )
{
    double rectangle_height;

    ///////////////////Dynamic Reconfig
    dynamic_reconfigure::ReconfigureRequest srv_req;
    dynamic_reconfigure::ReconfigureResponse srv_resp;
    dynamic_reconfigure::DoubleParameter double_param;
    dynamic_reconfigure::Config conf;   

    //Entering values using Dynamic Reconfig
    double_param.name = "kurtana_pitch_joint";
    double_param.value = rectangle_height;
    conf.doubles.push_back(double_param);

    srv_req.config = conf;
    ros::service::call("/visual_analysis/set_parameters", srv_req, srv_resp);


    return 0; 
}

Upvotes: 1

Views: 5789

Answers (1)

user2756695
user2756695

Reputation: 696

You should follow the following steps to have the dynamic Reconfig working:

  • Make a cfg folder and create a .cfg file where you can declare the parameters you want to change using dynamic reconfig.

  • Make changes in your CMakeList.txt and MakeFile to adapt them for dynamic reconfig

  • Make a dynamicReconfigCallBack() in which you can receive/set the changed parameters.

You can follow this tutorial for further detials.

Upvotes: 2

Related Questions