Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom types #61

Open
ahoarau opened this issue Sep 27, 2018 · 4 comments
Open

Add custom types #61

ahoarau opened this issue Sep 27, 2018 · 4 comments

Comments

@ahoarau
Copy link
Contributor

ahoarau commented Sep 27, 2018

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
Copy link
Contributor Author

ahoarau commented Sep 27, 2018

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

@artivis
Copy link
Collaborator

artivis commented Sep 28, 2018

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.

@ahoarau
Copy link
Contributor Author

ahoarau commented Sep 28, 2018

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.

@artivis
Copy link
Collaborator

artivis commented Oct 2, 2018

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants