PX4 / PX4-GPSDrivers

Platform independent GPS drivers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GNSS accuracy loss for Trimble MB-two caused by wrong Type casting

qst0528 opened this issue · comments

Reproduced on: PX4-Autopilot 1.13.0 beta2
Symptom: lat and lon has only zeros after decimal point

Our Pixhawk6C with v1.13.0 beta2 cannot parse GNSS message from Trimble MB-two.
Accessing Trimble module via its built-in web server returns far accurate position.

We assume wrong type cast in 038a13f causing this problem.
I'm trying to build a firmware with fixed code, which I haven't succeeded yet.

Old:
_gps_position->lat = static_cast<int>((int(lat * 0.01) + (lat * 0.01 - int(lat * 0.01)) * 100.0 / 60.0) * 10000000);
New:
_gps_position->lat = static_cast<int>((static_cast<int>(lat * 0.01) + static_cast<int>(lat * 0.01 - int(lat * 0.01)) * 100.0 / 60.0) * 10000000);
Suggestion:
_gps_position->lat = static_cast<int>((static_cast<int>(lat * 0.01) + (lat * 0.01 - static_cast<int>(lat * 0.01)) * 100.0 / 60.0) * 10000000);

mb-two_accuracy_loss
IMG_7949

src/ashtech.cpp, line 420-421
038a13f

Indeed this change was incorrect and I overlooked the 2. part. Can you create a PR with your suggestion?

PR merged. Closing.