Ask Your Question
4

auto-generated dynamic_reconfigure headers fail to compile depending on field names

asked 2012-10-24 14:50:44 -0500

ekaszubski gravatar image

updated 2012-10-30 13:30:02 -0500

In Fuerte, if a .cfg file used with dynamic_reconfigure contains a field named "i":

...
gen.add( "i", double_t, SensorLevels.RECONFIGURE_RUNNING, "i gain", 1, 0, 200 )
...

the header will fail to compile with:

no match for ‘operator=’ in ‘i = boost::any_cast [with ValueType = double]((* & val))’
The offending auto-generated code is:
class DEFAULT
{
  public:
    DEFAULT()
    {
      state = true;
      name = "Default";
    }

    void setParams(PIDConfig &config, const std::vector<abstractparamdescriptionconstptr> params)
    {
      for (std::vector<abstractparamdescriptionconstptr>::const_iterator i = params.begin(); i != params.end(); i++)
      {
        boost::any val;
        (*i)->getValue(config, val);

        if("p"==(*i)->name){p = boost::any_cast<double>(val);}
        if("i"==(*i)->name){i = boost::any_cast<double>(val);}
      }
    }

    double p;
double i;

    bool state;
    std::string name;


}groups;

Here, it's clear that setParams is using an iterator called "i", yet a member variable "i" of type "double" also exists within the same class.

While the obvious solution is to change the config field name from "i" to something like "i_gain" in this particular case, this issue breaks diamondback-compatible code and limits the names which may be used for dynamic_reconfigure fields.

To clarify, I'm using Ubuntu 12.04 64-bit/gcc 4.6.3 on a VM with a clean ROS install and the latest updates installed via dist-upgrade.


Additional Issues

It appears there are at least two more cases in which dynamic reconfigure param names can cause compilation issues.

When the class "DEFAULT" is added by the cfg generator:

class DEFAULT
{
  public:
    DEFAULT()
    {
      state = true;
      name = "Default";
    }

    ...

    // variables from user-specified fields

    ...

    // internal variables
    bool state;
    std::string name;

}groups;

the variables "state" and "name" appear to always be created, and will therefore conflict with any user-created variables with the same name.

To avoid these issues, it's probably a good idea to manually append "_param" or something similar to the name of all dynamic_reconfigure fields in .cfg files; however, as with the previous part of this issue, it would be great if this stuff would just work out-of-the-box.

edit retag flag offensive close merge delete

Comments

Wow, also it looks like there's no issue tracker for dynamic_reconfigure.

jbohren gravatar image jbohren  ( 2012-11-06 13:31:33 -0500 )edit

I just e-mailed Ze'ev about it, I'll post here when he gets back to me.

jbohren gravatar image jbohren  ( 2012-11-06 13:36:06 -0500 )edit

Thank you, sir :)

ekaszubski gravatar image ekaszubski  ( 2012-11-07 11:19:37 -0500 )edit

Btw it is a little surprising that Nameshttp://goo.gl/fqZut doesn't ban a single character parameter isn't it?

130s gravatar image 130s  ( 2012-11-09 11:25:41 -0500 )edit

Well single character parameters shouldn't be a problem. Meanwhile, still nothing from Ze'ev.

jbohren gravatar image jbohren  ( 2012-11-11 13:01:12 -0500 )edit
1

i just ran into this same issue, documenting it on ros.org...

Dave Coleman gravatar image Dave Coleman  ( 2013-07-08 19:15:35 -0500 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2014-06-18 12:26:00 -0500

esteve gravatar image

This issue is resolved in https://github.com/ros/dynamic_reconf... and released in dynamic_reconfigure v1.5.37. The fix will be available in the Hydro and Indigo Debian packages in the next few days.

edit flag offensive delete link more

Comments

The fix will be available soon in Groovy as well https://github.com/ros/rosdistro/pull/4798

esteve gravatar image esteve  ( 2014-06-20 10:33:17 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2012-10-24 14:50:44 -0500

Seen: 425 times

Last updated: Jun 18 '14