Recent implementation for HIL_STATE_QUATERNION is causing quite a few issues
sytelus opened this issue · comments
Recently user @kd0aij added HIL_STATE_QUATERNION message along with few other changes such as removing nav_mode check. This is causing following issues:
- With all default HIL setup (see steps in this issue if needed for repro) you will flickers in qGroundControl where Altitude keeps switching between 0 and 480m.
- With RC control, you will frequently see quadcopter suddenly flip over and dive to ground.
- You may see heading for the vehicle at 90 degrees instead of 0.
The cause of this is below problem is in the implementation:
- altitude (alt) is set to z value of vehicle position. This is incorrect. The z position needs to be projected on global frame to get altitude.
- The lat and lon fields of message are not set at all.
- The ind_windspeed is not set at all (this might be ok, however).
- The quaternion has some issue which is causing wrong heading.
Additionally, I also think this message is possibly interfering PX4 autopilot. See the function MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
in the PX4 code.
I reverted the MAVLinkHILSystem.java file to version before Sep 1 and above problems went away with vehicle having stable flight.
Looks like @lovettchris already tried this change #41. BTW, the reason GPS is 0,0 because lat and lon fields of HIL_STATE_QATERNION are not set. Also alt is set wrongly to z instead of projected value of z.
@kd0aij, @bkueng I think I now understand the purpose of HIL_STATE_QUATERNION . So basically, HIL can be used in two modes: (1) "state-level" mode (2) "sensor-level" mode. In Mode 1, pose estimation is disabled. This mode is useful for high throughput simulation where you don't care about errors from sensors. Mode 2 is normal simulation mode where pose estimation is enabled. Mode 2 should be the default and should be used majority of the times. So basically jMavSim should provide a command line switch to select one of these two modes instead of always sending HIL_STATE_QUATERNION all the time as it is doing now and thus always enforcing Mode 1.
Reference: https://pixhawk.org/dev/hil/start
The reference is outdated and I don't think we support state-level HIL anymore. As I wrote in #41 (comment), HIL_STATE_QUATERNION is only used for logging.
Yes it is, as it provides the ground-truth.
Ah ok.