File tree Expand file tree Collapse file tree 3 files changed +9
-24
lines changed
simulation/simple_sensor_simulator/include/simple_sensor_simulator/sensor_simulation/imu Expand file tree Collapse file tree 3 files changed +9
-24
lines changed Original file line number Diff line number Diff line change @@ -45,9 +45,6 @@ struct NormalDistributionError
45
45
{
46
46
static_assert (std::is_floating_point_v<std::decay_t <ValueType> >, " Unsupported error type" );
47
47
48
- // / @note set this to false to disable randomization
49
- bool active{true };
50
-
51
48
std::normal_distribution<ValueType> additive, multiplicative;
52
49
53
50
explicit NormalDistributionError (
@@ -66,11 +63,7 @@ struct NormalDistributionError
66
63
67
64
auto apply (std::mt19937_64 & engine, const ValueType value) -> ValueType
68
65
{
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);
74
67
}
75
68
};
76
69
@@ -171,11 +164,12 @@ struct NormalDistribution<sensor_msgs::msg::Imu> : public RandomNumberEngine
171
164
linear_acceleration_z_error;
172
165
// clang-format on
173
166
167
+ // / @note set this to false to disable randomization
168
+ bool active{true };
169
+
174
170
explicit NormalDistribution (
175
171
const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr &, const std::string &);
176
172
177
- auto deactivate () -> void;
178
-
179
173
auto operator ()(sensor_msgs::msg::Imu imu) -> sensor_msgs::msg::Imu;
180
174
};
181
175
Original file line number Diff line number Diff line change @@ -215,22 +215,13 @@ NormalDistribution<sensor_msgs::msg::Imu>::NormalDistribution(
215
215
{
216
216
}
217
217
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
-
231
218
auto NormalDistribution<sensor_msgs::msg::Imu>::operator ()(sensor_msgs::msg::Imu imu)
232
219
-> sensor_msgs::msg::Imu
233
220
{
221
+ if (not active) {
222
+ return imu;
223
+ }
224
+
234
225
imu.orientation = math::geometry::convertEulerAngleToQuaternion ([this , &imu] {
235
226
auto rpy = math::geometry::convertQuaternionToEulerAngle (imu.orientation );
236
227
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ class ImuSensor : public ImuSensorBase
99
99
* If legacy is not overriden we don't want to recalculate covariance matrices, so return early
100
100
*/
101
101
if (not override_legacy_configuration_) {
102
- publish.getMutableRandomizer ().deactivate () ;
102
+ publish.getMutableRandomizer ().active = false ;
103
103
return ;
104
104
}
105
105
You can’t perform that action at this time.
0 commit comments