Git Product home page Git Product logo

ddynamic_reconfigure's Introduction

ddynamic_reconfigure

The ddynamic_reconfigure package is a C++ extension of dynamic_reconfigure that allows modifying parameters of a ROS node using the dynamic_reconfigure framework without having to write cfg files.

Usage

This package requires at least C++11. If you have cmake version at least 3.1 the easiest way to do it is: set (CMAKE_CXX_STANDARD 11)

Modifying in place a variable:

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

int main(int argc, char **argv) {
    // ROS init stage
    ros::init(argc, argv, "ddynamic_tutorials");
    ros::NodeHandle nh;
    ddynamic_reconfigure::DDynamicReconfigure ddr;
    int int_param = 0;
    ddr.registerVariable<int>("int_param", &int_param, "param description");
    ddr.publishServicesTopics();
    // Now parameter can be modified from the dynamic_reconfigure GUI or other tools and the variable int_param is updated automatically
    
    int_param = 10; //This will also update the dynamic_reconfigure tools with the new value 10
    ros::spin();
    return 0;
 }

Modifying a variable via a callback:

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

int global_int;

void paramCb(int new_value)
{
   global_int = new_value;
   ROS_INFO("Param modified");
}

int main(int argc, char **argv) {
    // ROS init stage
    ros::init(argc, argv, "ddynamic_tutorials");
    ros::NodeHandle nh;
    ddynamic_reconfigure::DDynamicReconfigure ddr;
    
    ddr.registerVariable<int>("int_param", 10 /* initial value */, boost::bind(paramCb, _1), "param description");
    ddr.publishServicesTopics();
    // Now parameter can be modified from the dynamic_reconfigure GUI or other tools and the callback is called on each update
    ros::spin();
    return 0;
 }

Registering an enum:

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

int main(int argc, char **argv) {
    // ROS init stage
    ros::init(argc, argv, "ddynamic_tutorials");
    ros::NodeHandle nh;
    ddynamic_reconfigure::DDynamicReconfigure ddr;
    
    std::map<std::string, std::string> enum_map = {{"Key 1", "Value 1"}, {"Key 2", "Value 2"}};
    std::string enum_value = enum_map["Key 1"];
    ddr.registerEnumVariable<std::string>("string_enum", &enum_value,"param description", enum_map);
    ddr.publishServicesTopics();
    ros::spin();
    return 0;
 }

Registering variables in a private namespace "ddynamic_tutorials/other_namespace/int_param":

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

int main(int argc, char **argv) {
    // ROS init stage
    ros::init(argc, argv, "ddynamic_tutorials");
    ros::NodeHandle nh("~/other_namespace");
    ddynamic_reconfigure::DDynamicReconfigure ddr(nh);

    int int_param = 0;
    ddr.registerVariable<int>("int_param", &int_param, "param description");
    ddr.publishServicesTopics();
    
    ros::spin();
    return 0;
}

Same scenario, but with the NodeHandle created after the ddr instantiation:

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

std::unique_ptr<ddynamic_reconfigure::DDynamicReconfigure> ddr;
int main(int argc, char **argv) {
    // ROS init stage
    ros::init(argc, argv, "ddynamic_tutorials");
    ros::NodeHandle nh("~/other_namespace");

    ddr.reset(new ddynamic_reconfigure::DDynamicReconfigure(nh));
    int int_param = 0;
    ddr->registerVariable<int>("int_param", &int_param, "param description");
    ddr->publishServicesTopics();
    
    ros::spin();
    return 0;
}

Issues

Undefined reference to registerVariable or registerEnumVariable

These methods are templated, but the implementation is hidden, and there are explicit template instantiations for int, bool, double and std::string. If you are getting an undefined reference to one of these methods, make sure that you are passing parameters of this type.

ddynamic_reconfigure's People

Contributors

adriaroig avatar awesomebytes avatar guillaumeautran avatar lucamarchionni avatar ooeygui avatar reinzor avatar saikishor avatar v-lopez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ddynamic_reconfigure's Issues

Using ddynamic_reconfigure as a client

Hi!

Many thanks for making this package! I find it very useful!

I've looked through the readme and scrolled to the code and it seems to me that currently it's not possible to use ddynamic_reconfigure as a client to a dynamic reconfigure started by another node. Can someone confirm this is a case?

ros2 support

Hi,

We are working on our ros2 migration and we use this package quite a lot in our private ros1 codebase. Just a FYI that we are going to make a ros2 fork of this package here: https://github.com/eurogroep/ddynamic_reconfigure and work on a ros2 branch. We can eventually merge this back into this repo if desired. Having this package ros2 compatible would smoothen the transition to ros2 for us.

Our goal is to keep the API somewhat the same but use the rclcpp parameter features.

Let me know your thoughts. This issue is also for people that are in the same boat so that they know we are working on this :).

Cheers.

ROS_INFO on parameter change

We use the callback function often only to print a ROS_INFO statement. This is mostly helpful in analysing bagfiles afterwards.
It would be nice if it was possible to enable a ROS_INFO statement for every parameter change.

Would you be interested in a feature like this?

CMake Error: "Cannot specify link libraries for target "ddynamic_reconfigure-test""

Similar to #4, I couldn't build this repo right away, but this time under melodic getting this error:

CMake Error at /home/matthias/Workspaces/rss_ws/src/libs/ddynamic_reconfigure/CMakeLists.txt:57 (target_link_libraries):
  Cannot specify link libraries for target "ddynamic_reconfigure-test" which is not built by this project

It that's this in the CMakeLists:

if (CATKIN_ENABLE_TESTING)
    find_package(rostest REQUIRED)
    add_rostest_gmock(ddynamic_reconfigure-test test/ddynamic_reconfigure.test test/test_ddynamic_reconfigure.cpp)
    target_link_libraries(ddynamic_reconfigure-test
                                ${PROJECT_NAME})

It doesn't look all that wrong following some information about add_rostest_gmock and obviously it compiles using catkin build --cmake-args -DCATKIN_ENABLE_TESTING=False, but that's only a workaround.

Does somebody know how the proper solution would look like?

Interaction with paramater server

With standard dynamic reconfigure, new paramaters are mirrored on the ros paramater server such that you can do rosparam list and see your paramaters.

With this library however I can't see the paramaters at all with rosparam list. They appear in rqt_reconfigure but are apparently invisible to the rosparam api. Am I misunderstanding the library or have I done something wrong? Just making a small modification to the sample code on the readme to printout the keys :

int main(int argc, char **argv) {

        ros::init(argc, argv, "ddynamic_tutorials");
        ros::NodeHandle nh("~/other_namespace");
        ddynamic_reconfigure::DDynamicReconfigure ddr(nh);

        int int_param = 0;
        ddr.registerVariable<int>("int_param", &int_param, "param description");
        ddr.publishServicesTopics();

        std::vector<std::string> keys;
        nh.getParamNames(keys);

        // Print out keys on param server
        for(auto k : keys){
            printf("Key is %s\n", k.c_str());
        }
        ros::spin();
        return 0;
}

The only printed keys are the default roscore ones. I am on ROS Melodic, 18.04.

Any guidance is much appreciated. I am trying to use this vastly superior package with control_toolbox.

Ddynamic_reconfigure doesn't work inside a class

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?

Crash in DDynamicReconfigure::setConfigCallback

If the setConfigCallback ros service is called before the node if fully initialized, there is a risk of a crash while trying to publish on the update_pub_ publisher.
The reason is because the publisher is created after the rosservice is advertized. reversing this order is enough to address the crash.

Support for groups

Dynamic reconfigure has support for group. Ddynamic reconfigure has not. Open to accept a PR for this? What are your thoughts?

What is version 0.4?

I see this package has versions 0.4 and 0.4.1 which are ABI-breaks for 0.3.x versions. I somehow assumed 0.4.x will be released into Noetic, but currently, Noetic has 0.3.2. So what are the plans with 0.4.x versions? Is there will to have them in Noetic, or are they source-build only?

Is this thread safe?

If I changing the value of a variable, and this operation will call the Callback Function in main thread, while another thread is using this variable. Is this will cause a thread safe problem?

Specifying node handle for ddr

First thanks for this tool that simplifies dynamic_reconfigure. But I have one small problem. I cannot specify the node handle for a specific ddr.
In the first picture there is rqt working with the classic dynamic_reconfigure and there is inside the nodelet r2000_nodelet_manager, 2 dynamic reconfigure implementation : AngularBoundsFilter and IntensityFilter.

dr

In this image I replaced the dr of the intensity filter with the ddr, and ddr is linked with the nodelet manager
ddr

How can I do to specify the node handle and have the same result as in the first picture ?

Here is my instantiation of the ddr :

public:

  double lower_threshold_ ;
  double upper_threshold_ ;
  int disp_hist_ ;
  bool disp_hist_enabled_;
  ddynamic_reconfigure::DDynamicReconfigure ddr;

  bool configure()
  {
    ros::NodeHandle nh_("~/IntensityFilter");

    lower_threshold_ = 8000.0;
    upper_threshold_ = 100000.0;
    disp_hist_ = 1;

    getParam("lower_threshold", lower_threshold_);
    getParam("upper_threshold", upper_threshold_) ;
    getParam("disp_histogram",  disp_hist_) ;


    ddr.registerVariable<double>("Lower_intensity", &lower_threshold_, "Lower intensity threshold", 0, 3000);
    ddr.registerVariable<double>("Upper_intensity", &upper_threshold_, "Upper intensity threshold", 0, 3000);
    ddr.publishServicesTopics();

    disp_hist_enabled_ = (disp_hist_ == 0) ? false : true;

    return true;
  }

Thanks for your help

support for `float` type

Hi,

I have a use case where a 3rd party library has float inputs, that I want to reconfigure in my code.

right now I am resorting to double and implicit conversions but would it be good to have instantiations for float also?

compiler error

With ros kinetic I get following compiler error:

-- +++ processing catkin package: 'ddynamic_reconfigure'
-- ==> add_subdirectory(dev_drivers/ddynamic_reconfigure)
CMake Error at dev_drivers/ddynamic_reconfigure/CMakeLists.txt:54 (target_link_libraries):
  Cannot specify link libraries for target "ddynamic_reconfigure-test" which
  is not built by this project.


-- Configuring incomplete, errors occurred!
See also "/home/dji/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/dji/catkin_ws/build/CMakeFiles/CMakeError.log".
Makefile:2502: recipe for target 'cmake_check_build_system' failed
make: *** [cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed

Might also be helpful,

dji@MANIFOLD-2-C:~/catkin_ws/src/dev_drivers/ddynamic_reconfigure$ git status 
On branch kinetic-devel
Your branch is up-to-date with 'origin/kinetic-devel'.
nothing to commit, working directory clean
dji@MANIFOLD-2-C:~/catkin_ws/src/dev_drivers/ddynamic_reconfigure$ git remote -v
origin	https://github.com/pal-robotics/ddynamic_reconfigure (fetch)
origin	https://github.com/pal-robotics/ddynamic_reconfigure (push)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.