-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
populate the covariance fields using the noise models #333
Changes from 2 commits
91740c1
f9885a8
a0a18e7
8a0fa77
de0e49b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
#include <gz/transport/Node.hh> | ||
|
||
#include "gz/sensors/ImuSensor.hh" | ||
#include "gz/sensors/GaussianNoiseModel.hh" | ||
#include "gz/sensors/Noise.hh" | ||
#include "gz/sensors/SensorFactory.hh" | ||
#include "gz/sensors/SensorTypes.hh" | ||
|
@@ -255,6 +256,41 @@ bool ImuSensor::Update(const std::chrono::steady_clock::duration &_now) | |
frame->set_key("frame_id"); | ||
frame->add_value(this->FrameId()); | ||
|
||
// Populate covariance | ||
for (int i = 0; i < 9; ++i) { | ||
msg.mutable_linear_acceleration_covariance()->add_data(0); | ||
msg.mutable_angular_velocity_covariance()->add_data(0); | ||
msg.mutable_orientation_covariance()->add_data(0); | ||
} | ||
|
||
auto getCov = [&](SensorNoiseType noiseType) -> float{ | ||
if (this->dataPtr->noises.find(noiseType) != this->dataPtr->noises.end()) { | ||
GaussianNoiseModelPtr gaussian = | ||
std::dynamic_pointer_cast<GaussianNoiseModel>( | ||
this->dataPtr->noises[noiseType]); | ||
ejalaa12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return (float) (gaussian->StdDev() * gaussian->StdDev()); | ||
ejalaa12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
return 0.001f; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's good question. I'm not entirely sure here.
In this case, I guess 0 is a good default, that is if we want to follow ros conventions in gz-sensors as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok let's keep it consistent with ROS and set it to 0 here. Can you also do that for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Friendly ping @ejalaa12, I would like to get this in for Harmonic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey sorry for the late reply. On a different tangent, should we consider applying noise to the orientation values (probably a separate PR). That would mean addind a new SensorNoiseType There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noising up orientation can be tricky as an IMU isn't really directly measuring that, but instead running it through some sort of filter. You end up with things that aren't linear and uncorrelated in a tidy way. I think we can open a ticket to follow up on that though, if you would like. |
||
}; | ||
|
||
{ | ||
msg.mutable_linear_acceleration_covariance()->set_data( | ||
0, getCov(ACCELEROMETER_X_NOISE_M_S_S)); | ||
msg.mutable_linear_acceleration_covariance()->set_data( | ||
4, getCov(ACCELEROMETER_Y_NOISE_M_S_S)); | ||
msg.mutable_linear_acceleration_covariance()->set_data( | ||
8, getCov(ACCELEROMETER_Z_NOISE_M_S_S)); | ||
msg.mutable_angular_velocity_covariance()->set_data( | ||
0, getCov(GYROSCOPE_X_NOISE_RAD_S)); | ||
msg.mutable_angular_velocity_covariance()->set_data( | ||
4, getCov(GYROSCOPE_Y_NOISE_RAD_S)); | ||
msg.mutable_angular_velocity_covariance()->set_data( | ||
8, getCov(GYROSCOPE_Z_NOISE_RAD_S)); | ||
msg.mutable_orientation_covariance()->set_data(0, 0.001); | ||
msg.mutable_orientation_covariance()->set_data(4, 0.001); | ||
msg.mutable_orientation_covariance()->set_data(8, 0.001); | ||
} | ||
|
||
if (this->dataPtr->orientationEnabled) | ||
{ | ||
// Set the IMU orientation | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number 9 as a const ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a problem, but wouldn't that be less easy to read ?