apollo icon indicating copy to clipboard operation
apollo copied to clipboard

Question: GNSS driver measurement_time comparison?

Open draturi opened this issue 8 years ago • 3 comments

I have been working through the GNSS driver code and in the novatel_parser.cpp file I found this:

double seconds = gps_week * SECONDS_PER_WEEK + gps_millisecs * 1e-3;
  if (_gnss.measurement_time() != seconds) {
    _gnss.set_measurement_time(seconds);
    return false;
  }
  1. This seems to be a bug! you are comparing 2 doubles that have been computed by 2 different methods. This comparison is bound to fail (as it did in my tests)
  2. What is point of the if (_gnss....) statement?
  • how is measurement_time() set?
  • wouldn't the measurement time always be less than seconds?
    • if it is always less than seconds, this function will return false and this message (in this case the best velocity) will never get published?

Please help, this same problem exists with handle_corr_imu as well. Due to this if.... statement the GNSS driver is not publishing corrected_imu message/topic, even though the raw data is being read.

draturi avatar May 03 '18 02:05 draturi

gnss message contains two NovAtel messages as below:

  • best pos, generated by "log bestposb ontime 1\r\n"command;
  • best vel,generated by "log bestgnssvelb ontime 1\r\n" NovAtel command. After configure NovAtel log command as below:
    log bestposb ontime 1\r\n
    log bestgnssvelb ontime 1\r\n

NovAtel will generated best pos and best vel message periodically,and the timestamp in the both message is strict equality. measurement_time is used to combine the two kind NovAtel messages in the same period. In each period:

  • measurement_time() will be set when the first kind NovAtel message has been received,
  • second kind NovAtel message will trigger publish the gnss message.

Ins message is the same to gnss message.

hillbrook avatar May 05 '18 05:05 hillbrook

Thank you for the reply!

  1. with respect to "strict equality": I understand that the measurement time of the 2 messages should be in strict equality, but comparing 2 double's (_gnss.measurement_time() and seconds) using != is very error prone because of rounding errors that exist in the double type. This is the bug I was trying to flag (in my system this comparison fails). here is a good explanation of the bug/solution https://stackoverflow.com/questions/18971533/c-comparison-of-two-double-values-not-working-properly

  2. If I understand this correctly, for every protobuff _gnss, _ins ... There are multiple different messages that novatel sends out that are used to fill up the protobuffs. When the first message shows up, it will fail the if (_gnss.measurement_time() != seconds) { equality and set the measurement_time. After which, when the next message used to fill this protobuff comes in, it will pass the equality and then publish the corresponding message. Is that correct??

draturi avatar May 07 '18 18:05 draturi

  1. It is not a good idea to compare 2 double's (_gnss.measurement_time() and seconds) using != . We will fix it later. Thank you for your attention.
  2. That is correct.

hillbrook avatar May 08 '18 14:05 hillbrook