Browse Source

tool_calibgpsheading. fix divide zero.

yuchuli 1 year ago
parent
commit
0d9cf01daa

+ 2 - 0
src/tool/map_lanetoxodr/function/geofit.cpp

@@ -914,6 +914,8 @@ int geofit::CreateBezier(double xstart, double ystart, double hdg_start, double
 //    yc1 = 0; xc1 = x2 * uratio;
     yc1 = 0; xc1 = c2base * uratio;
 
+ //   yc1 = yc1 + c2base * 0.1;
+
 
     double xoff = c2base * vratio * cos(hdg2) *(-1);
     double yoff = c2base * vratio * sin(hdg2)* (-1);

+ 4 - 0
src/tool/tool_calibgpsheading/main.cpp

@@ -2,8 +2,12 @@
 
 #include <QApplication>
 
+//#include <assert.h>
+
 int main(int argc, char *argv[])
 {
+//    int x = 0;
+//    assert(x != 0);
     QApplication a(argc, argv);
     MainWindow w;
     w.show();

+ 5 - 1
src/tool/tool_calibgpsheading/mainwindow.cpp

@@ -19,7 +19,11 @@ double calib(double lon1,double lat1,double heading1,double lon2,double lat2,dou
     rel_x = rel_x0 * cos(-hdg_o) - rel_y0 * sin(-hdg_o);
     rel_y = rel_x0 * sin(-hdg_o) + rel_y0 * cos(-hdg_o);
 
-    double diffang = (-1) *atan(rel_y/rel_x) * 180.0/M_PI;
+    double diffang = M_PI;
+    if(fabs(rel_x)<1e-9)
+    {
+        diffang = (-1) *atan(rel_y/rel_x) * 180.0/M_PI;
+    }
 
     fdis = dis;
 

+ 2 - 2
src/tool/tool_calibgpsheading/mainwindow.ui

@@ -109,7 +109,7 @@
    <widget class="QLabel" name="label_4">
     <property name="geometry">
      <rect>
-      <x>336</x>
+      <x>330</x>
       <y>123</y>
       <width>61</width>
       <height>20</height>
@@ -145,7 +145,7 @@
    <widget class="QLabel" name="label_6">
     <property name="geometry">
      <rect>
-      <x>290</x>
+      <x>330</x>
       <y>190</y>
       <width>67</width>
       <height>17</height>