-
Notifications
You must be signed in to change notification settings - Fork 364
Add magnetic_field_sensor semantic component #2627
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
base: master
Are you sure you want to change the base?
Conversation
void update_data_from_interfaces() const | ||
{ | ||
for (auto i = 0u; i < data_.size(); ++i) | ||
{ | ||
const auto data = state_interfaces_[i].get().get_optional(); | ||
if (data.has_value()) | ||
{ | ||
data_[i] = data.value(); | ||
} | ||
} | ||
} |
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.
Do we want to have this as const?
The function name itself does the contrary
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.
Fixed in cab54b5
.
} | ||
|
||
// Array to store the data of the magnetic field sensor | ||
mutable std::array<double, 3> data_{{0.0, 0.0, 0.0}}; |
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 think it's right that the only variable you have is mutable.
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.
Fixed in cab54b5
.
bool get_values_as_message(sensor_msgs::msg::MagneticField & message) const | ||
{ | ||
update_data_from_interfaces(); | ||
message.magnetic_field.x = data_[0]; |
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.
Do we need it here too?
It is weird that it is compiling when calling a non const method from a const method
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.
Fixed in 8d8718a
.
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.
LGTM. Can you please add a line to the release notes that this component was added?
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.
Wait, the test is not added to the CMakeLists.txt, please add it there!
Thanks for the reviews! Everything is fixed except the release notes. I will fix them once #2646 is merged, to avoid merge conflicts. |
Adds a new semantic component for magnetometers/
magnetic_field_sensor
s.I plan to add support for magnetometers to the imu_broadcaster (this will come with a
has_magnetometer
parameter), as many IMUs have built-in magnetometers.Alongside this, I also plan on adding support for filtering to the broadcaster through the filters present in imu_tools.
Please review this PR and tell me if you are okay with the above.