Skip to content

Commit dce11aa

Browse files
committed
Improve IMU NormalDistribution deactivation
Skip the randomization process altogether instead of disabling all errors and performing other operations that achieve nothing Signed-off-by: Mateusz Palczuk <[email protected]>
1 parent 045cd35 commit dce11aa

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

external/concealer/include/concealer/publisher.hpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ struct NormalDistributionError
4545
{
4646
static_assert(std::is_floating_point_v<std::decay_t<ValueType> >, "Unsupported error type");
4747

48-
/// @note set this to false to disable randomization
49-
bool active{true};
50-
5148
std::normal_distribution<ValueType> additive, multiplicative;
5249

5350
explicit NormalDistributionError(
@@ -66,11 +63,7 @@ struct NormalDistributionError
6663

6764
auto apply(std::mt19937_64 & engine, const ValueType value) -> ValueType
6865
{
69-
if (active) {
70-
return value * (multiplicative(engine) + static_cast<ValueType>(1)) + additive(engine);
71-
} else {
72-
return value;
73-
}
66+
return value * (multiplicative(engine) + static_cast<ValueType>(1)) + additive(engine);
7467
}
7568
};
7669

@@ -171,11 +164,12 @@ struct NormalDistribution<sensor_msgs::msg::Imu> : public RandomNumberEngine
171164
linear_acceleration_z_error;
172165
// clang-format on
173166

167+
/// @note set this to false to disable randomization
168+
bool active{true};
169+
174170
explicit NormalDistribution(
175171
const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr &, const std::string &);
176172

177-
auto deactivate() -> void;
178-
179173
auto operator()(sensor_msgs::msg::Imu imu) -> sensor_msgs::msg::Imu;
180174
};
181175

external/concealer/src/publisher.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,13 @@ NormalDistribution<sensor_msgs::msg::Imu>::NormalDistribution(
215215
{
216216
}
217217

218-
auto NormalDistribution<sensor_msgs::msg::Imu>::deactivate() -> void
219-
{
220-
orientation_r_error.active = false;
221-
orientation_p_error.active = false;
222-
orientation_y_error.active = false;
223-
angular_velocity_x_error.active = false;
224-
angular_velocity_y_error.active = false;
225-
angular_velocity_z_error.active = false;
226-
linear_acceleration_x_error.active = false;
227-
linear_acceleration_y_error.active = false;
228-
linear_acceleration_z_error.active = false;
229-
}
230-
231218
auto NormalDistribution<sensor_msgs::msg::Imu>::operator()(sensor_msgs::msg::Imu imu)
232219
-> sensor_msgs::msg::Imu
233220
{
221+
if (not active) {
222+
return imu;
223+
}
224+
234225
imu.orientation = math::geometry::convertEulerAngleToQuaternion([this, &imu] {
235226
auto rpy = math::geometry::convertQuaternionToEulerAngle(imu.orientation);
236227

simulation/simple_sensor_simulator/include/simple_sensor_simulator/sensor_simulation/imu/imu_sensor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class ImuSensor : public ImuSensorBase
9999
* If legacy is not overriden we don't want to recalculate covariance matrices, so return early
100100
*/
101101
if (not override_legacy_configuration_) {
102-
publish.getMutableRandomizer().deactivate();
102+
publish.getMutableRandomizer().active = false;
103103
return;
104104
}
105105

0 commit comments

Comments
 (0)