Class MagnetometerBiasRemover

Class Documentation

class MagnetometerBiasRemover

Remove known bias from 3-axis magnetometer.

Public Types

using NodeLoggingInterface = rclcpp::node_interfaces::NodeLoggingInterface
using NodeParametersInterface = rclcpp::node_interfaces::NodeParametersInterface
using RequiredInterfaces = rclcpp::node_interfaces::NodeInterfaces<NodeLoggingInterface, NodeParametersInterface>

Public Functions

explicit MagnetometerBiasRemover(RequiredInterfaces node)
virtual ~MagnetometerBiasRemover()
void configFromParams()

Configure the bias remover from ROS parameters.

The following parameters are read:

  • ~initial_mag_bias_x (double, no default, optional): Magnetometer bias in the X axis.

  • ~initial_mag_bias_y (double, no default, optional): Magnetometer bias in the Y axis.

  • ~initial_mag_bias_z (double, no default, optional): Magnetometer bias in the Z axis.

  • ~initial_scaling_matrix (double[9], optional): Magnetometer scaling matrix (row-major).

bool hasBias() const

Whether bias has already been set.

Returns:

Whether bias has already been set.

bool hasScale() const

Whether bias has already been set and is different from identity.

Returns:

Whether bias has already been set.

void setBias(const sensor_msgs::msg::MagneticField &bias)

Callback for magnetometer bias.

Parameters:

bias[in] The bias value. If magnetic_field_covariance has non-zero elements, it is interpreted as a row-wise scaling matrix.

cras::expected<sensor_msgs::msg::MagneticField, std::string> removeBias(const sensor_msgs::msg::MagneticField &mag)

Callback for magnetometer measurements.

Parameters:

mag[in] The raw measured magnetic field strength.

Returns:

The measured magnetic field corrected for bias, or error message.