resibots / inria_wbc

Generic whole-body controller based on quadratic programming
14 stars 0 forks source link

Yaml node #40

Closed jbmouret closed 3 years ago

jbmouret commented 3 years ago

This is a substantial refactoring of the configuration process: instead of taking a Controller::Params structure, then parsing yaml file, we now take YAML::Nodereferences.

The general idea is that YAML::Node is a general purpose map that can be used to store our parameters in a generic way.

This makes it possible to:

 auto controller_config = IWBC_CHECK(YAML::LoadFile(controller_path));
 // do some modifications
 controller_config["CONTROLLER"]["base_path"] = "../etc";// we assume that we run in ./build
 controller_config["CONTROLLER"]["urdf"] = robot->model_filename();
 controller_config["CONTROLLER"]["mimic_dof_names"] = robot->mimic_dof_names();
  auto controller_name = IWBC_CHECK(controller_config["CONTROLLER"]["name"].as<std::string>());
 auto controller = inria_wbc::controllers::Factory::instance().create(controller_name, controller_config);

One open question is to keep the CONTROLLER and BEHAVIOR sections (since they are typically in different files). I kept them because I find it clearer/convenient to have CONTROLLER as the first line of a file that describe parameters of controllers, instead of a bunch of parameters. But this makes some code a bit less elegant.

Last, be careful that test_controller now has a -c option for the controller and -b option for the behavior.

ibergonzani commented 3 years ago

Everything seems to work fine. Keep the section names still make it possible to have a single configuration file which is not a bad option to me.