Skip to content
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

Gazebo simulation: Used Gazebo GPS plugin #21187

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ahcorde
Copy link
Contributor

@ahcorde ahcorde commented Feb 23, 2023

Added Gps sensor that allows to setup the GPS in Gazebo

I'm getting these errors. Any thoughts?

WARN  [health_and_arming_checks] Preflight Fail: Strong magnetic interference
WARN  [health_and_arming_checks] Preflight Fail: Yaw estimate error

FYI @Jaeyoung-Lim @bperseghetti @dagar

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Copy link
Member

@Jaeyoung-Lim Jaeyoung-Lim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahcorde Thanks for already looking into these!

Are the mag issues present when just adding the GPS sensor? If this is the case, wondering if it is related to the WMM magnetic model or something related to the geolocation and mag consistency

/**
* Magnetic field strength test selection
*
* When set, the EKF checks the strength of the magnetic field
* to decide whether the magnetometer data is valid.
* If GPS data is received, the magnetic field is compared to a World
* Magnetic Model (WMM), otherwise an average value is used.
* This check is useful to reject occasional hard iron disturbance.
*
* @group EKF2
* @boolean
*/
PARAM_DEFINE_INT32(EKF2_MAG_CHECK, 1);

src/modules/simulation/gz_bridge/GZBridge.hpp Outdated Show resolved Hide resolved
src/modules/simulation/gz_bridge/GZBridge.cpp Outdated Show resolved Hide resolved
src/modules/simulation/gz_bridge/GZBridge.cpp Outdated Show resolved Hide resolved
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
@ahcorde
Copy link
Contributor Author

ahcorde commented Feb 23, 2023

@ahcorde Thanks for already looking into these!

Are the mag issues present when just adding the GPS sensor? If this is the case, wondering if it is related to the WMM magnetic model or something related to the geolocation and mag consistency

/**
* Magnetic field strength test selection
*
* When set, the EKF checks the strength of the magnetic field
* to decide whether the magnetometer data is valid.
* If GPS data is received, the magnetic field is compared to a World
* Magnetic Model (WMM), otherwise an average value is used.
* This check is useful to reject occasional hard iron disturbance.
*
* @group EKF2
* @boolean
*/
PARAM_DEFINE_INT32(EKF2_MAG_CHECK, 1);

I was trying to include both at the same time (gps and magnetometer) but it's not clear for me how to match the values:

The magnetometer from Gazebo has magnetic field strength (in Tesla) along body-frame axis. I checked the PX4Magnetometer class but I couldn't find documentation.

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Feb 23, 2023

I was trying to include both at the same time (gps and magnetometer) but it's not clear for me how to match the values:

Does this mean that in gazebo, when there is a spherical coordinate defined as geo coordinates, the magnetic field is not consistent with the geolocation of the world? If this is the case, would it be something desired to add this feature?

This was how it was being done for gazebo classic: https://github.com/PX4/PX4-SITL_gazebo-classic/blob/ec8641d48753b20d431842f88e95557f22ec318a/src/gazebo_magnetometer_plugin.cpp#L184-L197

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
@ahcorde
Copy link
Contributor Author

ahcorde commented Feb 24, 2023

I was trying to include both at the same time (gps and magnetometer) but it's not clear for me how to match the values:

Does this mean that in gazebo, when there is a spherical coordinate defined as geo coordinates, the magnetic field is not consistent with the geolocation of the world? If this is the case, would it be something desired to add this feature?

This was how it was being done for gazebo classic: https://github.com/PX4/PX4-SITL_gazebo-classic/blob/ec8641d48753b20d431842f88e95557f22ec318a/src/gazebo_magnetometer_plugin.cpp#L184-L197

Yep, this feature was not implemented in Gazebo, but here it is gazebosim/gz-sim#1907.

I still have some issue with the NED -> ENU conversion. The velocity published in the navsat msg is in ENU, but the internal px4 message is in NED coordinates. may this affect the magnetometer too ?

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Feb 26, 2023

I still have some issue with the NED -> ENU conversion. The velocity published in the navsat msg is in ENU, but the internal px4 message is in NED coordinates. may this affect the magnetometer too ?

I would doubt that this makes a difference unless it happens during motion. Could you try disabling EKF2_MAG_CHECK and see if it fixes the mag warning? I would say then it is good enough to be in and we can wait until the gazebo changes are available

Signed-off-by: Alejandro Hernández Cordero <[email protected]>
@ahcorde
Copy link
Contributor Author

ahcorde commented Feb 27, 2023

EKF2_MAG_CHECK

I added this param but I still have the issue

quad_copter_fail_gps

@Jaeyoung-Lim
Copy link
Member

EKF2_MAG_CHECK
I added this param but I still have the issue

@bresch @dagar Any ideas how to fix this?

@Jaeyoung-Lim Jaeyoung-Lim added the Sim: gazebo Gazebo simulator (gz) label Feb 27, 2023
@bresch
Copy link
Member

bresch commented Mar 1, 2023

I tried in sim to fake a large mag field and I can arm without issues in alt mode if EKF2_MAG_CHECK is set to 0 or if COM_ARM_MAG_STR is set to 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sim: gazebo Gazebo simulator (gz)
Projects
No open projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants