Closed ksschwabe closed 7 years ago
I agree, it's unnecessarily confusing. I was going clean this up a few months ago, but decided to leave it alone as these modules are EOL. If you'd like to improve it I'll happily review.
I don't know how to cope with the "3DR rotation convention". The user has no way to see the real chip orientation, and we have nothing to distinguish a 3DR module from a Drotek module.
I don't know how to cope with the "3DR rotation convention". The user has no way to see the real chip orientation, and we have nothing to distinguish a 3DR module from a Drotek module.
One thing I've seen is that most modules out there are designed like the 3DR module, so for most cases this was correct.
@dagar: Why is this module heading to EOL? What is going to be replacing it?
I'll issue a PR so that at least the x_raw, y_raw are in the same direction as x and y if the rotation is set to ROTATION_NONE. (I'll hopefully do this by tomorrow).
@julianoes : From personal experience (I have the two GPS modules in front of me), the Ublox NEO-M8T GPS + HMC5983 compass (XL) has the magnetometer rotated at 90 degrees to their Ublox NEO-M8N GPS + HMC5983 compass (XXL) (which is the same as the 3DR rotation).
@LorenzMeier, @tridge, @julianoes I was having a problem understanding the data coming from my magnetometer on my GPS. It wasn't making sense to me, so I had to dig into the driver and found some nastiness.
The x, and y values for the x, y, output are swapped and "y" is negated to rotate the frame to the GPS module frame.
But when you set the "raw" uint16_t values from the chip, you rotate the frame in the opposite 90 degree direction (x and y swapped but this time x is negated).
If you have no rotation (_rotation - ROTATION_NONE) and your scale offsets were 0 and your calibration scales were 1, then your raw values are off by 180 degrees from your final new_report.x, y,z values.
Here is the full section of the code from the collect() function in the hmc5883 driver:
Also, the negating of the axes for when the sensor is an onboard sensor is rather horrible, because this is just correcting the rotation that you have performed to cope with the 90 degree rotation of the magnetometer on the 3DR GPS modules. How do you cope with GPS modules that have magnetometers at different rotations than the 90 degrees on the 3DR GPS modules? I have noticed that the Drotek GPS modules have different rotations.
Is there any reason why we should keep this hard-coded rotation in the driver?
In any event, the negation of the x_raw and y_raw values must definitely be corrected so that they are rotated in the same direction as the "final reported" x, y values.