Skip to content

Only set magnetometer gain if param is set #170

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

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions phidgets_spatial/launch/spatial.launch
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<param name="ahrs_bias_time" value="1.25"/> -->

# optional param algorithm_magnetometer_gain, default is 0.005
# WARNING: do not set on PhidgetSpatial MOT0110 onwards (not supported)!
<!-- <param name="algorithm_magnetometer_gain" value="0.005"/> -->

# optional param heating_enabled, not modified by default
Expand Down
11 changes: 8 additions & 3 deletions phidgets_spatial/src/spatial_ros_i.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,14 @@ SpatialRosI::SpatialRosI(ros::NodeHandle nh, ros::NodeHandle nh_private)
nh_private_.getParam("ahrs_bias_time", ahrsBiasTime);

double algorithm_magnetometer_gain;
bool set_algorithm_magnetometer_gain = true;
if (!nh_private_.getParam("algorithm_magnetometer_gain",
algorithm_magnetometer_gain))
{
algorithm_magnetometer_gain =
0.005; // default to 0.005 (similar to phidgets api)
algorithm_magnetometer_gain = 0.0;
set_algorithm_magnetometer_gain =
false; // if parameter not set, do not call api (because this
// function is not available from MOT0110 onwards)
}

bool heating_enabled;
Expand Down Expand Up @@ -272,7 +275,9 @@ SpatialRosI::SpatialRosI(ros::NodeHandle nh, ros::NodeHandle nh_private)
ahrsBiasTime);
}

spatial_->setAlgorithmMagnetometerGain(algorithm_magnetometer_gain);
if (set_algorithm_magnetometer_gain)
spatial_->setAlgorithmMagnetometerGain(
algorithm_magnetometer_gain);
}

if (has_compass_params)
Expand Down