From 9573138cc44134ac76d0948010a554595373b004 Mon Sep 17 00:00:00 2001 From: Alexis Duburcq Date: Tue, 19 Mar 2024 11:34:03 +0100 Subject: [PATCH] [core] Fix bias/noise check for EncoderSensor. --- core/src/hardware/basic_sensors.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/src/hardware/basic_sensors.cc b/core/src/hardware/basic_sensors.cc index 31ba1e4c2..c42f40eed 100644 --- a/core/src/hardware/basic_sensors.cc +++ b/core/src/hardware/basic_sensors.cc @@ -108,12 +108,12 @@ namespace jiminy "to all sensor signal.\n" " - the next six are respectively gyroscope and accelerometer additive bias."); } - if (noiseStd.size() && noiseStd.size() != 6) + if (noiseStd.size() && static_cast(noiseStd.size()) != getSize()) { THROW_ERROR( std::invalid_argument, "Wrong noise std vector. It must contain 6 values corresponding respectively to " - "gyroscope and accelerometer additive bias."); + "gyroscope and accelerometer additive noise."); } // Set options now that sanity check were made @@ -232,11 +232,11 @@ namespace jiminy const Eigen::VectorXd & bias = boost::get(sensorOptions.at("bias")); const Eigen::VectorXd & noiseStd = boost::get(sensorOptions.at("noiseStd")); - if (bias.size() && bias.size() != 3) + if (bias.size() && static_cast(bias.size()) != getSize()) { THROW_ERROR(std::invalid_argument, "Wrong bias vector size."); } - if (noiseStd.size() && noiseStd.size() != 3) + if (noiseStd.size() && static_cast(noiseStd.size()) != getSize()) { THROW_ERROR(std::invalid_argument, "Wrong noise std vector size."); } @@ -329,11 +329,11 @@ namespace jiminy const Eigen::VectorXd & bias = boost::get(sensorOptions.at("bias")); const Eigen::VectorXd & noiseStd = boost::get(sensorOptions.at("noiseStd")); - if (bias.size() && bias.size() != 6) + if (bias.size() && static_cast(bias.size()) != getSize()) { THROW_ERROR(std::invalid_argument, "Wrong bias vector size."); } - if (noiseStd.size() && noiseStd.size() != 6) + if (noiseStd.size() && static_cast(noiseStd.size()) != getSize()) { THROW_ERROR(std::invalid_argument, "Wrong noise std vector size."); } @@ -444,11 +444,11 @@ namespace jiminy const Eigen::VectorXd & bias = boost::get(sensorOptions.at("bias")); const Eigen::VectorXd & noiseStd = boost::get(sensorOptions.at("noiseStd")); - if (bias.size() && bias.size() != 1) + if (bias.size() && static_cast(bias.size()) != getSize()) { THROW_ERROR(std::invalid_argument, "Wrong bias vector size."); } - if (noiseStd.size() && noiseStd.size() != 1) + if (noiseStd.size() && static_cast(noiseStd.size()) != getSize()) { THROW_ERROR(std::invalid_argument, "Wrong noise std vector size."); } @@ -557,11 +557,11 @@ namespace jiminy const Eigen::VectorXd & bias = boost::get(sensorOptions.at("bias")); const Eigen::VectorXd & noiseStd = boost::get(sensorOptions.at("noiseStd")); - if (bias.size() && bias.size() != 1) + if (bias.size() && static_cast(bias.size()) != getSize()) { THROW_ERROR(std::invalid_argument, "Wrong bias vector size."); } - if (noiseStd.size() && noiseStd.size() != 1) + if (noiseStd.size() && static_cast(noiseStd.size()) != getSize()) { THROW_ERROR(std::invalid_argument, "Wrong noise std vector size."); }