Skip to content

Only set magnetometer gain if param is set #169

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
3 changes: 2 additions & 1 deletion phidgets_spatial/launch/spatial-launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def generate_launch_description():
'ahrs_bias_time': 1.25,

# optional param algorithm_magnetometer_gain, default is 0.005
'algorithm_magnetometer_gain': 0.005,
# WARNING: do not set on PhidgetSpatial MOT0110 onwards (not supported)!
# 'algorithm_magnetometer_gain': 0.005,

# optional param heating_enabled, not modified by default
'heating_enabled': False,
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 @@ -92,11 +92,14 @@ SpatialRosI::SpatialRosI(const rclcpp::NodeOptions &options)
this->get_parameter("ahrs_bias_time", ahrsBiasTime);

double algorithm_magnetometer_gain;
bool set_algorithm_magnetometer_gain = true;
if (!this->get_parameter("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 @@ -267,7 +270,9 @@ SpatialRosI::SpatialRosI(const rclcpp::NodeOptions &options)
ahrsBiasTime);
}

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

if (has_compass_params)
Expand Down