rosparam_handler icon indicating copy to clipboard operation
rosparam_handler copied to clipboard

Add custom types

Open ahoarau opened this issue 7 years ago • 4 comments

That would really awesome if we could have something like this :


# gen.addcustomType(type,class_name,lambda);

gen = ParameterGenerator()
gen.addCustomType("std::vector<double>","Eigen::VectorXd",Array,"[](std::vector<double> array){ return Eigen::Map<Eigen::VectorXd>(array.data(),array.size());  }")

That would generate something like :

Eigen::VectorXd __param_name;
std::function<Eigen::VectorXd(std::vector<double>)> array_to__param_name = [](std::vector<double> array){ return Eigen::Map<Eigen::VectorXd>(array.data(),array.size());  };

void fromYaml()
{
    // load the array as usual
  __param_name = array_to__param_name(   array_from_yaml);
}



ahoarau avatar Sep 27 '18 16:09 ahoarau

The std::vector<double> could even be hidden in gen.addArrayType to be able to transform to geometry_msgs, tf msgs, eigen, etc.

ahoarau avatar Sep 27 '18 16:09 ahoarau

Hi, this is an interesting idea ! Adding support for Eigen is on the todo list since a while (something similar to rosparam_shortcuts) however I couldn't get started due to a lack of time. Your proposal (use of a lambdas) is interesting in that it generalizes well, however I'm concerned by the implications in terms of dependencies (missing includes etc) that it adds. Maybe you could propose some proof-of-concept implementation so that we can discuss it further and see how rosparam_handler could be made even more generic ! Cheers.

artivis avatar Sep 28 '18 07:09 artivis

Includes could be added as an extra argument (easy), but you should make sure to link against the said library. Making sure this happens is much more difficult. Maybe out of scope as well.

ahoarau avatar Sep 28 '18 15:09 ahoarau

You are right, although Eigen being template only, this particular dependency could be handled similarly to what's already done with dynamic_reconfigure (see e.g. here or there).

artivis avatar Oct 02 '18 07:10 artivis