Skip to content

Commit

Permalink
Fixed issues with plotting magnetometer data.
Browse files Browse the repository at this point in the history
Scaled points to more easily be seen. Fixed apparent typo in .rviz.
  • Loading branch information
iandareid committed Aug 30, 2024
1 parent a2a4110 commit 7ed6f5d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rosflight_gcs/rviz/viz_mag.rviz
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Visualization Manager:
Value: true
- Class: rviz_default_plugins/Marker
Enabled: true
Marker Topic: /viz/cloud
Topic: /viz/cloud
Name: Mag Measurements
Namespaces:
"": true
Expand Down
12 changes: 7 additions & 5 deletions rosflight_gcs/src/viz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Viz::Viz()
// retrieve params

// initialize variables
mag_skip_ = 20;
mag_skip_ = 1;
mag_throttle_ = 0;

// Magnetometer visualization
Expand All @@ -61,9 +61,11 @@ void Viz::magCallback(const sensor_msgs::msg::MagneticField::ConstSharedPtr & ms
{
if (mag_throttle_ > mag_skip_) {
// unpack message
double x = msg->magnetic_field.x;
double y = msg->magnetic_field.y;
double z = msg->magnetic_field.z;

float SCALING_FACTOR = 100'000.; // To make the changes appear.
double x = msg->magnetic_field.x*SCALING_FACTOR;
double y = msg->magnetic_field.y*SCALING_FACTOR;
double z = msg->magnetic_field.z*SCALING_FACTOR;

// get euler angles from vector (assume no roll)
double yaw = atan2(y, x);
Expand Down Expand Up @@ -102,7 +104,7 @@ void Viz::magCallback(const sensor_msgs::msg::MagneticField::ConstSharedPtr & ms
pts_msg.action = visualization_msgs::msg::Marker::ADD;

// set points style
pts_msg.scale.x = 0.1;
pts_msg.scale.x = 0.05;
pts_msg.scale.y = pts_msg.scale.x;
pts_msg.scale.z = pts_msg.scale.x;
pts_msg.color.a = 1.0;
Expand Down

0 comments on commit 7ed6f5d

Please sign in to comment.