From 409e7997a5a8a0458d8eea9f73c23eab5527fbbf Mon Sep 17 00:00:00 2001 From: odri <odri@furano.laas.fr> Date: Wed, 22 Sep 2021 10:24:03 +0200 Subject: [PATCH] Add yaml hardware config file as a parameter --- include/qrw/Params.hpp | 1 + python/gepadd.cpp | 1 + scripts/main_solo12_control.py | 2 +- src/Params.cpp | 6 +++++- src/config_solo12.yaml | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/qrw/Params.hpp b/include/qrw/Params.hpp index 6857dcd7..6599341a 100644 --- a/include/qrw/Params.hpp +++ b/include/qrw/Params.hpp @@ -48,6 +48,7 @@ class Params { // See .yaml file for meaning of parameters // General parameters + std::string config_file; // Name of the yaml file containing hardware information std::string interface; // Name of the communication interface (check with ifconfig) bool SIMULATION; // Enable/disable PyBullet simulation or running on real robot bool LOGGING; // Enable/disable logging during the experiment diff --git a/python/gepadd.cpp b/python/gepadd.cpp index d9fc8a7d..1af730f6 100644 --- a/python/gepadd.cpp +++ b/python/gepadd.cpp @@ -429,6 +429,7 @@ struct ParamsPythonVisitor : public bp::def_visitor<ParamsPythonVisitor<Params>> "Initialize Params from Python.\n") // Read Params from Python + .def_readwrite("config_file", &Params::config_file) .def_readwrite("interface", &Params::interface) .def_readwrite("SIMULATION", &Params::SIMULATION) .def_readwrite("LOGGING", &Params::LOGGING) diff --git a/scripts/main_solo12_control.py b/scripts/main_solo12_control.py index db15be6d..266c43a2 100644 --- a/scripts/main_solo12_control.py +++ b/scripts/main_solo12_control.py @@ -121,7 +121,7 @@ def control_loop(name_interface_clone=None, des_vel_analysis=None): device = PyBulletSimulator() qc = None else: - device = oci.robot_from_yaml_file('config_solo12.yaml') + device = oci.robot_from_yaml_file(params.config_file) qc = QualisysClient(ip="140.93.16.160", body_id=0) if name_interface_clone is not None: diff --git a/src/Params.cpp b/src/Params.cpp index 66a529a9..d9f3bd43 100644 --- a/src/Params.cpp +++ b/src/Params.cpp @@ -3,7 +3,8 @@ using namespace yaml_control_interface; Params::Params() - : interface(""), + : config_file(""), + interface(""), SIMULATION(false), LOGGING(false), PLOTTING(false), @@ -74,6 +75,9 @@ void Params::initialize(const std::string& file_path) { const YAML::Node& robot_node = param["robot"]; // Retrieve robot parameters + assert_yaml_parsing(robot_node, "robot", "config_file"); + config_file = robot_node["config_file"].as<std::string>(); + assert_yaml_parsing(robot_node, "robot", "interface"); interface = robot_node["interface"].as<std::string>(); diff --git a/src/config_solo12.yaml b/src/config_solo12.yaml index 39367cd4..e0f93df3 100644 --- a/src/config_solo12.yaml +++ b/src/config_solo12.yaml @@ -1,5 +1,6 @@ robot: # General parameters + config_file: config_solo12.yaml # Name of the yaml file containing hardware information interface: enp2s0 # Name of the communication interface (check with ifconfig) SIMULATION: true # Enable/disable PyBullet simulation or running on real robot LOGGING: false # Enable/disable logging during the experiment -- GitLab