@@ -351,7 +351,7 @@ class GlobalPositionPlugin : public plugin::Plugin
351351 vel_cov_out (0 ) = -1.0 ;
352352
353353 // Current fix in ECEF
354- Eigen::Vector3d map_point;
354+ Eigen::Vector3d map_point {} ;
355355
356356 try {
357357 /* *
@@ -387,6 +387,10 @@ class GlobalPositionPlugin : public plugin::Plugin
387387 }
388388 } catch (const std::exception & e) {
389389 RCLCPP_ERROR_STREAM (get_logger (), " GP: Caught exception: " << e.what () );
390+ gp_fix_pub->publish (fix);
391+ gp_rel_alt_pub->publish (relative_alt);
392+ gp_hdg_pub->publish (compass_heading);
393+ return ;
390394 }
391395
392396 // Compute the local coordinates in ECEF
@@ -519,9 +523,12 @@ class GlobalPositionPlugin : public plugin::Plugin
519523
520524 void home_position_cb (const mavros_msgs::msg::HomePosition::SharedPtr req)
521525 {
522- map_origin.x () = req->geo .latitude ;
523- map_origin.y () = req->geo .longitude ;
524- map_origin.z () = req->geo .altitude ;
526+ Eigen::Vector3d new_map_origin;
527+ Eigen::Vector3d new_ecef_origin;
528+
529+ new_map_origin.x () = req->geo .latitude ;
530+ new_map_origin.y () = req->geo .longitude ;
531+ new_map_origin.z () = req->geo .altitude ;
525532
526533 try {
527534 /* *
@@ -532,12 +539,15 @@ class GlobalPositionPlugin : public plugin::Plugin
532539
533540 // map_origin to ECEF
534541 map.Forward (
535- map_origin .x (), map_origin .y (), map_origin .z (),
536- ecef_origin .x (), ecef_origin .y (), ecef_origin .z ());
542+ new_map_origin .x (), new_map_origin .y (), new_map_origin .z (),
543+ new_ecef_origin .x (), new_ecef_origin .y (), new_ecef_origin .z ());
537544 } catch (const std::exception & e) {
538545 RCLCPP_ERROR_STREAM (get_logger (), " GP: Caught exception: " << e.what ());
546+ return ;
539547 }
540548
549+ map_origin = new_map_origin;
550+ ecef_origin = new_ecef_origin;
541551 is_map_init = true ;
542552 }
543553
0 commit comments