Skip to content

Commit

Permalink
[core] Fix bias/noise check for EncoderSensor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Duburcq committed Mar 19, 2024
1 parent 7521aa3 commit 9573138
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions core/src/hardware/basic_sensors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::size_t>(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
Expand Down Expand Up @@ -232,11 +232,11 @@ namespace jiminy
const Eigen::VectorXd & bias = boost::get<Eigen::VectorXd>(sensorOptions.at("bias"));
const Eigen::VectorXd & noiseStd =
boost::get<Eigen::VectorXd>(sensorOptions.at("noiseStd"));
if (bias.size() && bias.size() != 3)
if (bias.size() && static_cast<std::size_t>(bias.size()) != getSize())
{
THROW_ERROR(std::invalid_argument, "Wrong bias vector size.");
}
if (noiseStd.size() && noiseStd.size() != 3)
if (noiseStd.size() && static_cast<std::size_t>(noiseStd.size()) != getSize())
{
THROW_ERROR(std::invalid_argument, "Wrong noise std vector size.");
}
Expand Down Expand Up @@ -329,11 +329,11 @@ namespace jiminy
const Eigen::VectorXd & bias = boost::get<Eigen::VectorXd>(sensorOptions.at("bias"));
const Eigen::VectorXd & noiseStd =
boost::get<Eigen::VectorXd>(sensorOptions.at("noiseStd"));
if (bias.size() && bias.size() != 6)
if (bias.size() && static_cast<std::size_t>(bias.size()) != getSize())
{
THROW_ERROR(std::invalid_argument, "Wrong bias vector size.");
}
if (noiseStd.size() && noiseStd.size() != 6)
if (noiseStd.size() && static_cast<std::size_t>(noiseStd.size()) != getSize())
{
THROW_ERROR(std::invalid_argument, "Wrong noise std vector size.");
}
Expand Down Expand Up @@ -444,11 +444,11 @@ namespace jiminy
const Eigen::VectorXd & bias = boost::get<Eigen::VectorXd>(sensorOptions.at("bias"));
const Eigen::VectorXd & noiseStd =
boost::get<Eigen::VectorXd>(sensorOptions.at("noiseStd"));
if (bias.size() && bias.size() != 1)
if (bias.size() && static_cast<std::size_t>(bias.size()) != getSize())
{
THROW_ERROR(std::invalid_argument, "Wrong bias vector size.");
}
if (noiseStd.size() && noiseStd.size() != 1)
if (noiseStd.size() && static_cast<std::size_t>(noiseStd.size()) != getSize())
{
THROW_ERROR(std::invalid_argument, "Wrong noise std vector size.");
}
Expand Down Expand Up @@ -557,11 +557,11 @@ namespace jiminy
const Eigen::VectorXd & bias = boost::get<Eigen::VectorXd>(sensorOptions.at("bias"));
const Eigen::VectorXd & noiseStd =
boost::get<Eigen::VectorXd>(sensorOptions.at("noiseStd"));
if (bias.size() && bias.size() != 1)
if (bias.size() && static_cast<std::size_t>(bias.size()) != getSize())
{
THROW_ERROR(std::invalid_argument, "Wrong bias vector size.");
}
if (noiseStd.size() && noiseStd.size() != 1)
if (noiseStd.size() && static_cast<std::size_t>(noiseStd.size()) != getSize())
{
THROW_ERROR(std::invalid_argument, "Wrong noise std vector size.");
}
Expand Down

0 comments on commit 9573138

Please sign in to comment.