Browse Source

merge some conflicts

fujiankuan 4 years ago
parent
commit
7d6f1307da
78 changed files with 4908 additions and 646 deletions
  1. 1 1
      include/ivversion.h
  2. 146 0
      sh/tagv1.1/autodeploy.sh
  3. 58 0
      sh/tagv1.1/autodeploylib.sh
  4. 10 0
      sh/tagv1.1/autogen.bat
  5. 309 0
      sh/tagv1.1/autogen.sh
  6. 23 0
      sh/tagv1.1/gen.bat
  7. 25 0
      sh/tagv1.1/genlib.bat
  8. 13 0
      sh/tagv1.1/windowsdus.txt
  9. 8 1
      src/controller/controller_yuhesen/control/control_status.cpp
  10. 1 0
      src/controller/controller_yuhesen/control/control_status.h
  11. 10 3
      src/controller/controller_yuhesen/control/controller.cpp
  12. 2 2
      src/controller/controller_yuhesen/control/controller.h
  13. 17 15
      src/controller/controller_yuhesen/main.cpp
  14. 14 11
      src/decition/decition_brain/decition/adc_adapter/yuhesen_adapter.cpp
  15. 5 5
      src/decition/decition_brain/decition/adc_adapter/yuhesen_adapter.h
  16. 1 2
      src/decition/decition_brain/decition/adc_adapter/zhongche_adapter.cpp
  17. 4 4
      src/decition/decition_brain/decition/brain.cpp
  18. 9 4
      src/decition/decition_brain/decition/decide_gps_00.cpp
  19. 5 1
      src/decition/decition_brain/decition/decide_gps_00.h
  20. 5 3
      src/decition/decition_brain/decition/decition.pri
  21. 1 1
      src/decition/decition_brain_sf/decition/brain.cpp
  22. 5 0
      src/decition/decition_brain_sf/decition/decide_gps_00.cpp
  23. 2 0
      src/decition/decition_brain_sf/decition/decide_gps_00.h
  24. 11 0
      src/detection/detection_chassis/decodechassis.cpp
  25. 1 0
      src/detection/detection_chassis/decodechassis.h
  26. 8 1
      src/detection/detection_chassis/main.cpp
  27. 115 111
      src/detection/detection_mobileye/main.cpp
  28. 54 38
      src/detection/detection_radar_delphi_esr_send/main.cpp
  29. 1 1
      src/driver/driver_cloud_grpc_client_BS/VehicleControl_service.proto
  30. 2 2
      src/driver/driver_cloud_grpc_client_BS/VehiclePatrol.proto
  31. 1 1
      src/driver/driver_cloud_grpc_client_BS/VehicleUpload_service.proto
  32. 6 2
      src/driver/driver_cloud_grpc_client_BS/driver_cloud_grpc_client_BS.pro
  33. 5 4
      src/driver/driver_cloud_grpc_client_BS/driver_cloud_grpc_client_BS.yaml
  34. 94 396
      src/driver/driver_cloud_grpc_client_BS/main.cpp
  35. 2 2
      src/driver/driver_cloud_grpc_client_BS/prototocpp.txt
  36. 201 0
      src/driver/driver_cloud_grpc_client_BS/vehicle_control.cpp
  37. 67 0
      src/driver/driver_cloud_grpc_client_BS/vehicle_control.h
  38. 131 0
      src/driver/driver_cloud_grpc_client_BS/vehicle_patrol.cpp
  39. 68 0
      src/driver/driver_cloud_grpc_client_BS/vehicle_patrol.h
  40. 207 0
      src/driver/driver_cloud_grpc_client_BS/vehicle_upload.cpp
  41. 91 0
      src/driver/driver_cloud_grpc_client_BS/vehicle_upload.h
  42. 2 1
      src/driver/driver_map_xodrload/globalplan.cpp
  43. 104 0
      src/tool/map_lanetoxodr/adcxodrviewer.pro
  44. 120 0
      src/tool/map_lanetoxodr/adcxodrviewer_android.pro
  45. 270 0
      src/tool/map_lanetoxodr/dialogroadmerge.cpp
  46. 35 0
      src/tool/map_lanetoxodr/dialogroadmerge.h
  47. 78 0
      src/tool/map_lanetoxodr/dialogroadmerge.ui
  48. 146 0
      src/tool/map_lanetoxodr/dialogroadmirror.cpp
  49. 32 0
      src/tool/map_lanetoxodr/dialogroadmirror.h
  50. 101 0
      src/tool/map_lanetoxodr/dialogroadmirror.ui
  51. 102 0
      src/tool/map_lanetoxodr/dialogroadmove.cpp
  52. 32 0
      src/tool/map_lanetoxodr/dialogroadmove.h
  53. 78 0
      src/tool/map_lanetoxodr/dialogroadmove.ui
  54. 117 0
      src/tool/map_lanetoxodr/dialogroadrotate.cpp
  55. 32 0
      src/tool/map_lanetoxodr/dialogroadrotate.h
  56. 55 0
      src/tool/map_lanetoxodr/dialogroadrotate.ui
  57. 257 9
      src/tool/map_lanetoxodr/dialogroadsplit.cpp
  58. 8 0
      src/tool/map_lanetoxodr/dialogroadsplit.h
  59. 47 2
      src/tool/map_lanetoxodr/main.cpp
  60. 104 4
      src/tool/map_lanetoxodr/mainwindow.cpp
  61. 15 0
      src/tool/map_lanetoxodr/mainwindow.h
  62. 18 3
      src/tool/map_lanetoxodr/map_lanetoxodr.pro
  63. 10 0
      src/tool/map_lanetoxodr/myview.cpp
  64. 265 0
      src/tool/map_lanetoxodr/roaddigit.cpp
  65. 56 0
      src/tool/map_lanetoxodr/roaddigit.h
  66. 152 6
      src/tool/map_lanetoxodr/roadeditdialog.cpp
  67. 20 0
      src/tool/map_lanetoxodr/roadeditdialog.h
  68. 53 1
      src/tool/map_lanetoxodr/roadeditdialog.ui
  69. 2 0
      src/tool/map_lanetoxodr/roadviewitem.cpp
  70. 2 2
      src/tool/map_lanetoxodr/roadviewitem.h
  71. 154 1
      src/tool/map_lanetoxodr/xodrfunc.cpp
  72. 11 0
      src/tool/map_lanetoxodr/xodrfunc.h
  73. 226 0
      src/tool/map_lanetoxodr/xodrscenfunc.cpp
  74. 26 0
      src/tool/map_lanetoxodr/xodrscenfunc.h
  75. 296 0
      src/tool/map_lanetoxodr/xvmainwindow.cpp
  76. 70 0
      src/tool/map_lanetoxodr/xvmainwindow.h
  77. 73 0
      src/tool/map_lanetoxodr/xvmainwindow.ui
  78. 0 6
      src/ui/ui_ads_hmi/ADCIntelligentVehicle.cpp

+ 1 - 1
include/ivversion.h

@@ -1,5 +1,5 @@
 
 
-#define VERSION "1.0.0-develop"
+#define VERSION "1.1.0-develop"
 
 
 
 
 #include <iostream>
 #include <iostream>

+ 146 - 0
sh/tagv1.1/autodeploy.sh

@@ -0,0 +1,146 @@
+PRO_DIR=`pwd`
+CONFIG_IVSysMan="IVSysMan.xml"
+
+
+cd ../../ 
+
+app_name=(
+controller_bus
+controller_jinlong_peisong
+controller_midcar
+controller_problue
+controller_ge3
+controller_vv7
+controller_tju_vv7
+decition_brain
+driver_camera_usb
+driver_can_kvaser
+driver_can_vci
+driver_can_nvidia_agx
+driver_cloud_grpc_client_stream
+driver_grpc_server
+driver_gps_ins550d
+driver_gps_hcp2
+driver_lidar_bk16
+driver_lidar_hesai40line
+driver_lidar_hesai40p
+driver_lidar_hesaipandar64
+driver_lidar_rs16
+driver_lidar_rs32
+driver_lidar_vlp16
+driver_lidar_vlp32c
+driver_lidar_vtdpoint
+driver_map_trace
+driver_map_xodrload
+driver_piccompress
+driver_radio_p900
+driver_rpc_client
+driver_rpc_server
+driver_vbox_gaohong
+driver_ota_client
+driver_ota_server
+detection_chassis
+detection_gps_hcp2
+detection_gps_vtd
+#detection_lidar_cnn_segmentation
+detection_lidar_cnntogrid
+detection_lidar_grid
+detection_lidar_ukf_pda
+detection_mobileye
+#detection_ndt_matching_gpu_multi
+detection_radar_delphi_esr
+detection_state_delphi_ins500d
+fusion_gpsndt
+fusion_pointcloud_bus
+adciv_record
+adciv_replay
+adcndtmultimapping
+bqev_lidar_cnn_detect_view
+bqev_multilidarcalib
+bqev_pcdview
+ivmapmake
+ivmapmake_sharemem
+IVSysMan
+map_lanetoxodr
+map_mobieye
+PerceptionShow
+picview
+pointcloudviewer
+RemoteCtrl
+tool_calcmd5
+tool_querymsg
+tool_xodrobj
+view_gps
+view_ivlog
+view_pcdmap
+view_radar
+view_rawcan
+ui_ads_hmi
+tool_configivsysman
+RemoteCtrl_Stream
+)
+
+for x in ${app_name[@]}
+do
+	echo "deploy $x"
+	cp ./bin/${x} ./
+	./deploywithfind.sh $x
+	rm ${x}
+done
+
+#cp ./thirdpartylib/QtWebApp/lib/*.s* ./bin
+#patchelf --set-rpath '$ORIGIN' ./bin/libQtWebAppGlobal.so
+#patchelf --set-rpath '$ORIGIN' ./bin/llibQtWebAppHttpServer.so
+
+#cp ./bin/libQtWebApp*  ./deploy/app/lib/
+
+
+
+
+lib_name=(
+	libmodulecomm.so
+	libndt_cpu.so
+#	libndt_gpu.so
+	libxmlparam.so
+	libivfault.so
+	libivlog.so
+	libivbacktrace.so
+	libivexit.so
+)
+
+
+
+for x in ${lib_name[@]}
+do
+#	echo "link lib $x"
+#	patchelf --set-rpath '$ORIGIN' ./bin/$x
+	echo "deploylib $x"
+	cp ./bin/${x} ./
+	./deploylib.sh $x
+	rm ${x}
+done
+
+
+xlib=`ls ./deploy/app/lib/lib*`  
+for fileName in $xlib
+  do
+     patchelf --set-rpath '$ORIGIN' $fileName
+  done
+
+   
+
+#echo "creat IVSysMan.xml"
+#cp ./sh/tju64/xml/$CONFIG_IVSysMan ./deploy/app/IVSysMan.xml
+#cp ./other/ADS_decision.xml ./deploy/app/ADS_decision.xml
+#sed -i "s|xxxxxx|$PRO_DIR/|g" ./deploy/app/IVSysMan.xml
+
+#cp ./bin/*.so ./deploy/app/lib/
+
+#cp ./sh/tju64/xml/*  ./deploy/app/
+
+
+
+echo ""
+echo "***************"
+echo "***  done!  ***"
+echo "***************"

+ 58 - 0
sh/tagv1.1/autodeploylib.sh

@@ -0,0 +1,58 @@
+PRO_DIR=`pwd`
+CONFIG_IVSysMan="IVSysMan.xml"
+
+
+cd ../../ 
+
+
+
+
+
+
+lib_name=(
+	libmodulecomm.so
+	libndt_cpu.so
+#	libndt_gpu.so
+	libxmlparam.so
+	libivfault.so
+	libivlog.so
+	libivbacktrace.so
+	libivexit.so
+)
+
+
+
+for x in ${lib_name[@]}
+do
+#	echo "link lib $x"
+#	patchelf --set-rpath '$ORIGIN' ./bin/$x
+	echo "deploylib $x"
+	cp ./bin/${x} ./
+	./deploylib.sh $x
+	rm ${x}
+done
+
+
+xlib=`ls ./deploy/app/lib/lib*`  
+for fileName in $xlib
+  do
+     patchelf --set-rpath '$ORIGIN' $fileName
+  done
+
+   
+
+#echo "creat IVSysMan.xml"
+#cp ./sh/tju64/xml/$CONFIG_IVSysMan ./deploy/app/IVSysMan.xml
+#cp ./other/ADS_decision.xml ./deploy/app/ADS_decision.xml
+#sed -i "s|xxxxxx|$PRO_DIR/|g" ./deploy/app/IVSysMan.xml
+
+#cp ./bin/*.so ./deploy/app/lib/
+
+#cp ./sh/tju64/xml/*  ./deploy/app/
+
+
+
+echo ""
+echo "***************"
+echo "***  done!  ***"
+echo "***************"

+ 10 - 0
sh/tagv1.1/autogen.bat

@@ -0,0 +1,10 @@
+
+call genlib.bat src\common modulecomm 
+call genlib.bat src\common xmlparam
+call genlib.bat src\common ivbacktrace
+call genlib.bat src\common ivfault
+call genlib.bat src\common ivexit
+call genlib.bat src\common ivlog
+call genlib.bat src\common ivsyschange
+
+call gen.bat src\driver driver_gps_hcp2

+ 309 - 0
sh/tagv1.1/autogen.sh

@@ -0,0 +1,309 @@
+
+#qtmake="/opt/qt/5.10.1/gcc_64/bin/qmake"
+
+qtmake=" "
+
+if [ ${#qtmake} -lt 5 ]; then
+  echo "now need find qmake "
+  optfiles=`find /opt -name 'qmake'` 
+  for entry in $optfiles
+  do
+     x=${entry:0-17:17}
+     if [ "$x" == "/gcc_64/bin/qmake" ];  then
+        qtmake="$entry"
+	echo "  -----find qmake"
+	echo "$qtmake"
+     fi
+  done
+fi
+
+if [ ${#qtmake} -lt 5 ]; then
+  echo "maybe agx,find qmake in usr folder "
+  optfiles=`find /usr -name 'qmake'` 
+  for entry in $optfiles
+  do
+     x=${entry:0-14:14}
+     if [ "$x" == "/qt5/bin/qmake" ];  then
+        qtmake="$entry"
+	echo "  -----find qmake"
+	echo "$qtmake"
+     fi
+  done
+fi
+
+
+MAKEOPT=-j2
+
+cd ../../
+
+mkdir bin
+
+cd src/include/proto
+sh ./protomake.sh
+cd ../../../
+
+cd src/include/proto3
+sh ./protomake.sh
+cd ../../../
+
+cd src/common/modulecomm/
+$qtmake modulecomm.pro
+make $MAKEOPT
+make clean
+cp libmodulecomm.so ./../../../bin/
+rm Makefile
+rm .qmake.stash
+cd ../../../
+
+cd src/common/xmlparam/
+$qtmake xmlparam.pro
+make $MAKEOPT
+make clean
+cp libxmlparam.so ./../../../bin/
+rm Makefile
+rm .qmake.stash
+cd ../../../
+
+cd src/common/ndt_cpu/
+$qtmake ndt_cpu.pro
+make $MAKEOPT
+make clean
+cp libndt_cpu.so ./../../../bin/
+rm Makefile
+rm .qmake.stash
+cd ../../../
+
+#cd src/common/ndt_gpu/
+#$qtmake ndt_gpu.pro
+#make $MAKEOPT
+#make clean
+#cp libndt_gpu.so ./../../../bin/
+#rm Makefile
+#rm .qmake.stash
+#cd ../../../
+
+cd src/common/ivlog/
+$qtmake ivlog.pro
+make $MAKEOPT
+make clean
+cp libivlog.so ./../../../bin/
+rm Makefile
+rm .qmake.stash
+cd ../../../
+
+cd src/common/ivfault/
+$qtmake ivfault.pro
+make $MAKEOPT
+make clean
+cp libivfault.so ./../../../bin/
+rm Makefile
+rm .qmake.stash
+cd ../../../
+
+
+cd src/common/ivbacktrace/
+$qtmake ivbacktrace.pro
+make $MAKEOPT
+make clean
+cp libivbacktrace.so ./../../../bin/
+rm Makefile
+rm .qmake.stash
+cd ../../../
+
+cd src/common/ivexit/
+$qtmake ivexit.pro
+make $MAKEOPT
+make clean
+cp libivexit.so ./../../../bin/
+rm Makefile
+rm .qmake.stash
+cd ../../../
+
+controller_app_name=(
+controller_bus
+controller_jinlong_peisong
+controller_midcar
+controller_problue
+controller_ge3
+controller_vv7
+controller_tju_vv7
+)
+
+for x in ${controller_app_name[@]}
+do
+cd src/controller/${x}/
+$qtmake ${x}.pro
+make $MAKEOPT
+make clean
+cp ${x} ./../../../bin/
+rm Makefile
+rm .qmake.stash
+rm ${x}
+cd ../../../
+done
+
+decition_app_name=(
+decition_brain
+)
+
+for x in ${decition_app_name[@]}
+do
+cd src/decition/${x}/
+$qtmake ${x}.pro
+make $MAKEOPT
+make clean
+cp ${x} ./../../../bin/
+rm Makefile
+rm .qmake.stash
+rm ${x}
+cd ../../../
+done
+
+driver_app_name=(
+driver_camera_usb
+driver_can_kvaser
+driver_can_vci
+driver_can_nvidia_agx
+#driver_cloud_grpc_client
+#driver_cloud_grpc_pc
+#driver_cloud_grpc_server
+driver_gps_ins550d
+driver_gps_hcp2
+driver_lidar_bk16
+driver_lidar_hesai40line
+driver_lidar_hesai40p
+driver_lidar_hesaipandar64
+driver_lidar_rs16
+driver_lidar_rs32
+driver_lidar_vlp16
+driver_lidar_vlp32c
+driver_lidar_vtdpoint
+driver_map_trace
+driver_map_xodrload
+driver_piccompress
+driver_radio_p900
+#driver_rpc_client
+#driver_rpc_server
+driver_vbox_gaohong
+)
+
+for x in ${driver_app_name[@]}
+do
+cd src/driver/${x}/
+$qtmake ${x}.pro
+make $MAKEOPT
+make clean
+cp ${x} ./../../../bin/
+rm Makefile
+rm .qmake.stash
+rm ${x}
+cd ../../../
+done
+
+detect_app_name=(
+detection_chassis
+detection_gps_hcp2
+detection_gps_vtd
+#detection_lidar_cnn_segmentation
+detection_lidar_cnntogrid
+detection_lidar_grid
+detection_lidar_ukf_pda
+detection_mobileye
+#detection_ndt_matching_gpu_multi
+detection_radar_delphi_esr
+detection_state_delphi_ins500d
+
+)
+
+for x in ${detect_app_name[@]}
+do
+cd src/detection/${x}/
+$qtmake ${x}.pro
+make $MAKEOPT
+make clean
+cp ${x} ./../../../bin/
+rm Makefile
+rm .qmake.stash
+rm ${x}
+cd ../../../
+done
+
+fusion_app_name=(
+fusion_gpsndt
+fusion_pointcloud_bus
+)
+
+for x in ${fusion_app_name[@]}
+do
+cd src/fusion/${x}/
+$qtmake ${x}.pro
+make $MAKEOPT
+make clean
+cp ${x} ./../../../bin/
+rm Makefile
+rm .qmake.stash
+rm ${x}
+cd ../../../
+done
+
+tool_app_name=(
+adciv_record
+adciv_replay
+adcndtmultimapping
+bqev_lidar_cnn_detect_view
+bqev_multilidarcalib
+bqev_pcdview
+ivmapmake
+ivmapmake_sharemem
+IVSysMan
+map_lanetoxodr
+map_mobieye
+PerceptionShow
+picview
+pointcloudviewer
+#RemoteCtrl
+tool_calcmd5
+tool_querymsg
+tool_xodrobj
+view_gps
+view_ivlog
+view_pcdmap
+view_radar
+view_rawcan
+tool_configivsysman
+)
+
+for x in ${tool_app_name[@]}
+do
+cd src/tool/${x}/
+$qtmake ${x}.pro
+make $MAKEOPT
+make clean
+cp ${x} ./../../../bin/
+rm Makefile
+rm .qmake.stash
+rm ${x}
+cd ../../../
+done
+
+ui_app_name=(
+ui_ads_hmi
+)
+
+for x in ${ui_app_name[@]}
+do
+cd src/ui/${x}/
+$qtmake ${x}.pro
+make $MAKEOPT
+make clean
+cp ${x} ./../../../bin/
+rm Makefile
+rm .qmake.stash
+rm ${x}
+cd ../../../
+done
+
+
+
+
+

+ 23 - 0
sh/tagv1.1/gen.bat

@@ -0,0 +1,23 @@
+set qmake=C:\Qt\Qt5.13.2\5.13.2\mingw73_64\bin\qmake.exe
+set make=C:/Qt/Qt5.13.2/Tools/mingw730_64/bin/mingw32-make
+set shdir=%cd%
+cd ..
+cd ..
+set modulename=%2
+set rootdir=%cd%
+set prodir=%rootdir%\%1\%2
+cd %prodir%
+set profile=%2.pro
+%qmake% %profile%
+%make% -f Makefile.Release -j8
+cd release
+copy %modulename%.exe %rootdir%\bin
+cd ..
+del .qmake.stash
+del Makefile
+del Makefile.Debug
+del Makefile.Release
+del %2%_resource.rc
+rd debug
+rd /s /q release
+cd %shdir%

+ 25 - 0
sh/tagv1.1/genlib.bat

@@ -0,0 +1,25 @@
+set qmake=C:\Qt\Qt5.13.2\5.13.2\mingw73_64\bin\qmake.exe
+set make=C:/Qt/Qt5.13.2/Tools/mingw730_64/bin/mingw32-make
+set shdir=%cd%
+cd ..
+cd ..
+set modulename=%2
+set rootdir=%cd%
+set prodir=%rootdir%\%1\%2
+cd %prodir%
+set profile=%2.pro
+echo %profile%
+%qmake% %profile%
+%make% -f Makefile.Release -j8
+cd release
+copy lib%modulename%.a %rootdir%\bin
+copy %modulename%.dll %rootdir%\bin
+cd ..
+del .qmake.stash
+del Makefile
+del Makefile.Debug
+del Makefile.Release
+del %2%_resource.rc
+rd debug
+rd /s /q release
+cd %shdir%

+ 13 - 0
sh/tagv1.1/windowsdus.txt

@@ -0,0 +1,13 @@
+https://github.com/WangTingMan/WinDbusBinary
+
+在Windows上面使用DBUS
+DBUS是一种进程间远程调用的机制。 官方网站是: https://www.freedesktop.org/wiki/Software/dbus/ 通过这里提供的DBUS Windows移植版本,你可以在windows上面开发dbus程序啦!
+
+如何使用
+复制dbus-1.dll到你的计算机的系统目录中,以便使用DBUS的程序可以找到它并且加载它。部分DBUS程序是动态从系统中加载该dll 的,因此请需要注意系统加载dll的搜索路径。
+在桌面上创建dbus-daemon.exe的快捷方式
+修改步骤2创建的快捷方式,在该快捷方式上右键,在“目标”栏位中填写:xxx\dbus-daemon.exe --config-file=system.conf 注意,xxx指的是dbus-daemon.exe所在的文件夹。
+开始运行dbus-daemon.exe吧!
+在QT中测试
+QT中有很多DBUS的示例程序,可以使用它们来测试DBUS通信。 不过使用qdbusviewer.exe,你会发现浏览org.freedesktop.DBUs的DBUS接口时,会报一部分错误,不过这并不影响你实际的DBUS通信 开发哦!
+

+ 8 - 1
src/controller/controller_yuhesen/control/control_status.cpp

@@ -14,7 +14,7 @@ void iv::control::ControlStatus::set_wheel_angle(float angle)
 
 
 void iv::control::ControlStatus::set_brake(bool enable)
 void iv::control::ControlStatus::set_brake(bool enable)
 {
 {
-    command.bit.brake=(unsigned)true;
+    command.bit.brake=(unsigned)enable;
 }
 }
 
 
 void iv::control::ControlStatus::set_velocity(float vel)
 void iv::control::ControlStatus::set_velocity(float vel)
@@ -54,3 +54,10 @@ void iv::control::ControlStatus::set_horn(bool enable)
 {
 {
     command.bit.horn = (unsigned char)enable;
     command.bit.horn = (unsigned char)enable;
 }
 }
+
+void iv::control::ControlStatus::set_mode(bool enable)
+{
+    command.bit.drive_mode = (unsigned char)enable;
+}
+
+

+ 1 - 0
src/controller/controller_yuhesen/control/control_status.h

@@ -24,6 +24,7 @@ namespace iv {
             void set_highbeam(bool enable);
             void set_highbeam(bool enable);
             void set_dangwei(int dangwei);
             void set_dangwei(int dangwei);
             void set_horn(bool enable);
             void set_horn(bool enable);
+            void set_mode(bool enable);
         };
         };
         typedef boost::serialization::singleton<iv::control::ControlStatus> ControlStatusSingleton;
         typedef boost::serialization::singleton<iv::control::ControlStatus> ControlStatusSingleton;
     }
     }

+ 10 - 3
src/controller/controller_yuhesen/control/controller.cpp

@@ -19,9 +19,13 @@ void iv::control::Controller::control_wheel(float angle) {
     ServiceControlStatus.set_wheel_angle(angle);
     ServiceControlStatus.set_wheel_angle(angle);
 }
 }
 
 
-void iv::control::Controller::control_brake(bool enable)
+void iv::control::Controller::control_brake(float enable)
 {
 {
-    ServiceControlStatus.set_brake(enable);
+    if(enable>0){
+    ServiceControlStatus.set_brake(true);
+    }else{
+       ServiceControlStatus.set_brake(false);
+    }
 }
 }
 
 
 void iv::control::Controller::control_velocity(float vel)
 void iv::control::Controller::control_velocity(float vel)
@@ -54,7 +58,10 @@ void iv::control::Controller::control_horn(bool enable)
     ServiceControlStatus.set_horn(enable);
     ServiceControlStatus.set_horn(enable);
 }
 }
 
 
-
+void iv::control::Controller::control_mode(bool enable)
+{
+    ServiceControlStatus.set_mode(enable);
+}
 
 
 
 
 
 

+ 2 - 2
src/controller/controller_yuhesen/control/controller.h

@@ -6,7 +6,6 @@
 #define _IV_CONTROL_CONTROLLER_
 #define _IV_CONTROL_CONTROLLER_
 
 
 #include <boost.h>
 #include <boost.h>
-#include <control/control_status.h>
 
 
 namespace iv {
 namespace iv {
     namespace control {
     namespace control {
@@ -18,13 +17,14 @@ namespace iv {
             void inialize();// 初始化
             void inialize();// 初始化
 
 
             void control_wheel(float angle);		//方向盘控制
             void control_wheel(float angle);		//方向盘控制
-            void control_brake(bool enable);
+            void control_brake(float enable);
             void control_velocity(float vel);
             void control_velocity(float vel);
             void control_left_light(bool enable);
             void control_left_light(bool enable);
             void control_right_light(bool enable);
             void control_right_light(bool enable);
             void control_highbeam(bool enable);
             void control_highbeam(bool enable);
             void control_dangwei(int dangwei);
             void control_dangwei(int dangwei);
             void control_horn(bool enable);
             void control_horn(bool enable);
+            void control_mode(bool enable);
 
 
         private:
         private:
         };
         };

+ 17 - 15
src/controller/controller_yuhesen/main.cpp

@@ -54,10 +54,11 @@ boost::shared_ptr<iv::control::Controller> gcontroller;	//实际车辆控制器
 
 
 void executeDecition(const iv::brain::decition decition)
 void executeDecition(const iv::brain::decition decition)
 {
 {
-    std::cout<<"acc is "<<decition.torque()<<" ang is "<<decition.wheelangle()<<std::endl;
-    std::cout<<"limitspeed is "<<decition.speed()<<" brake is "<<decition.brake()<<std::endl;
-    std::cout<<"drive_mode is "<<decition.mode()<<" elec_brake is "<<decition.handbrake()<<std::endl;
-    std::cout<<"brake_light is "<<decition.brakelamp()<<" dangwei is "<<decition.gear()<<std::endl;
+    std::cout<<" ang is "<<decition.wheelangle()<<std::endl;
+    std::cout<<" brake is "<<decition.brake()<<std::endl;
+    std::cout<<"drive_mode is "<<decition.mode()<<std::endl;
+    std::cout<<" dangwei is "<<decition.gear()<<std::endl;
+    std::cout<<"dspeed is " << decition.speed()<<std::endl;
     gcontroller->inialize();
     gcontroller->inialize();
     gcontroller->control_wheel(decition.wheelangle());
     gcontroller->control_wheel(decition.wheelangle());
     gcontroller->control_brake(decition.brake());
     gcontroller->control_brake(decition.brake());
@@ -66,6 +67,7 @@ void executeDecition(const iv::brain::decition decition)
     gcontroller->control_right_light(decition.rightlamp());
     gcontroller->control_right_light(decition.rightlamp());
     gcontroller->control_highbeam(decition.highbeam());
     gcontroller->control_highbeam(decition.highbeam());
     gcontroller->control_dangwei(decition.gear());
     gcontroller->control_dangwei(decition.gear());
+    gcontroller->control_mode(decition.mode());
 }
 }
 
 
 
 
@@ -90,18 +92,18 @@ void ListenRemotectrl(const char * strdata,const unsigned int nSize,const unsign
     else
     else
     {
     {
         gbAutoDriving = false;
         gbAutoDriving = false;
-        xdecition.set_torque(xrc.acc());
+        //xdecition.set_torque(xrc.acc());
         xdecition.set_brake(xrc.brake());
         xdecition.set_brake(xrc.brake());
         xdecition.set_wheelangle(xrc.wheel()*5.5f);
         xdecition.set_wheelangle(xrc.wheel()*5.5f);
         xdecition.set_speed(5);
         xdecition.set_speed(5);
         xdecition.set_gear(1);
         xdecition.set_gear(1);
-        xdecition.set_handbrake(0);
-        xdecition.set_grade(1);
+        //xdecition.set_handbrake(0);
+       // xdecition.set_grade(1);
         xdecition.set_mode(1);
         xdecition.set_mode(1);
-        xdecition.set_speak(0);
-        xdecition.set_headlight(false);
-        xdecition.set_engine(0);
-        xdecition.set_taillight(false);
+        //xdecition.set_speak(0);
+        //xdecition.set_headlight(false);
+       // xdecition.set_engine(0);
+       // xdecition.set_taillight(false);
         gMutex.lock();
         gMutex.lock();
         gdecition_remote.CopyFrom(xdecition);
         gdecition_remote.CopyFrom(xdecition);
         gMutex.unlock();
         gMutex.unlock();
@@ -205,14 +207,14 @@ int main(int argc, char *argv[])
      QString strpath = QCoreApplication::applicationDirPath();
      QString strpath = QCoreApplication::applicationDirPath();
 
 
     if(argc < 2)
     if(argc < 2)
-        strpath = strpath + "/controller_midcar.xml";
+        strpath = strpath + "/controller_yuhesen.xml";
     else
     else
         strpath = argv[1];
         strpath = argv[1];
     std::cout<<strpath.toStdString()<<std::endl;
     std::cout<<strpath.toStdString()<<std::endl;
 
 
-    gdecition_def.set_brake(0);
-    gdecition_def.set_torque(0);
-    gdecition_def.set_speed(105);
+//    gdecition_def.set_brake(0);
+//    gdecition_def.set_torque(0);
+//    gdecition_def.set_speed(105);
     gTime.start();
     gTime.start();
 
 
     gcontroller = boost::shared_ptr<iv::control::Controller>(new iv::control::Controller());
     gcontroller = boost::shared_ptr<iv::control::Controller>(new iv::control::Controller());

+ 14 - 11
src/decition/decition_brain/decition/adc_adapter/yuhesen_adapter.cpp

@@ -76,16 +76,11 @@ iv::decition::Decition iv::decition::YuHeSenAdapter::getAdapterDeciton(GPS_INS n
 
 
     (*decition)->wheel_angle+=ServiceCarStatus.mfEPSOff;
     (*decition)->wheel_angle+=ServiceCarStatus.mfEPSOff;
 
 
-    (*decition)->wheel_angle=max((float)-500.0,(*decition)->wheel_angle);
-     (*decition)->wheel_angle=min((float)500.0,(*decition)->wheel_angle);
+    (*decition)->wheel_angle=max((float)-40.0,(*decition)->wheel_angle);
+     (*decition)->wheel_angle=min((float)40.0,(*decition)->wheel_angle);
+
 
 
-    if((*decition)->accelerator>=0){
-        (*decition)->torque= (*decition)->accelerator;
         (*decition)->brake=0;
         (*decition)->brake=0;
-    }else{
-        (*decition)->torque=0;
-        (*decition)->brake=0-(*decition)->accelerator;
-    }
 
 
 
 
 
 
@@ -94,13 +89,21 @@ std::cout<<"==========================================="<<std::endl;
      std::cout<<"dSpeed:"<<dSpeed<<"   realSpeed:"<<realSpeed<<"   acc:"<<accAim
      std::cout<<"dSpeed:"<<dSpeed<<"   realSpeed:"<<realSpeed<<"   acc:"<<accAim
     <<std::endl;
     <<std::endl;
 std::cout<<"========================================="<<std::endl;
 std::cout<<"========================================="<<std::endl;
-
+(*decition)->speed = dSpeed/3.6;
+(*decition)->wheel_angle=(*decition)->wheel_angle*0.1;
+(*decition)->wheel_angle=max((float)-40.0,(*decition)->wheel_angle);
+(*decition)->wheel_angle=min((float)40.0,(*decition)->wheel_angle);
+(*decition)->mode=1;
+(*decition)->dangWei=1;
+if((*decition)->brake>0){
+    (*decition)->speed=0;
+}
     return *decition;
     return *decition;
 }
 }
 
 
 
 
 
 
-float iv::decition::VV7Adapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decition::YuHeSenAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
 
     //刹车限制
     //刹车限制
 
 
@@ -140,7 +143,7 @@ float iv::decition::VV7Adapter::limitBrake(float realSpeed, float controlBrake,f
 
 
 }
 }
 
 
-float iv::decition::VV7Adapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decition::YuHeSenAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
 
 
     controlSpeed=min((float)5.0,controlSpeed);
     controlSpeed=min((float)5.0,controlSpeed);
     controlSpeed=max((float)-7.0,controlSpeed);
     controlSpeed=max((float)-7.0,controlSpeed);

+ 5 - 5
src/decition/decition_brain/decition/adc_adapter/yuhesen_adapter.h

@@ -1,5 +1,5 @@
-#ifndef VV7_ADAPTER_H
-#define VV7_ADAPTER_H
+#ifndef YUHESEN_ADAPTER_H
+#define YUHESEN_ADAPTER_H
 
 
 
 
 
 
@@ -15,7 +15,7 @@
 
 
 namespace iv {
 namespace iv {
      namespace decition {
      namespace decition {
-         class VV7Adapter: public BaseAdapter {
+         class YuHeSenAdapter: public BaseAdapter {
                     public:
                     public:
 
 
                         float lastTorque;
                         float lastTorque;
@@ -23,8 +23,8 @@ namespace iv {
                         int lastDangWei=0;
                         int lastDangWei=0;
                         int seizingCount=0;
                         int seizingCount=0;
 
 
-                        VV7Adapter();
-                        ~VV7Adapter();
+                        YuHeSenAdapter();
+                        ~YuHeSenAdapter();
 
 
                         iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
                         iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
                                                                                  float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);
                                                                                  float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decition);

+ 1 - 2
src/decition/decition_brain/decition/adc_adapter/zhongche_adapter.cpp

@@ -1,3 +1,4 @@
+
 #include <decition/adc_adapter/zhongche_adapter.h>
 #include <decition/adc_adapter/zhongche_adapter.h>
 #include <common/constants.h>
 #include <common/constants.h>
 #include <common/car_status.h>
 #include <common/car_status.h>
@@ -5,7 +6,6 @@
 #include <iostream>
 #include <iostream>
 #include <fstream>
 #include <fstream>
 
 
-
 using namespace std;
 using namespace std;
 
 
 
 
@@ -18,7 +18,6 @@ iv::decition::ZhongcheAdapter::~ZhongcheAdapter(){
 }
 }
 
 
 
 
-
 iv::decition::Decition iv::decition::ZhongcheAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
 iv::decition::Decition iv::decition::ZhongcheAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
 
 

+ 4 - 4
src/decition/decition_brain/decition/brain.cpp

@@ -1,4 +1,4 @@
-#include <decition/brain.h>
+ #include <decition/brain.h>
 #include <fstream>
 #include <fstream>
 #include <time.h>
 #include <time.h>
 #include <exception>
 #include <exception>
@@ -272,7 +272,7 @@ void iv::decition::BrainDecition::run() {
     ServiceCarStatus.msysparam.mstrvin = xp.GetParam("vin","10000000000000001");
     ServiceCarStatus.msysparam.mstrvin = xp.GetParam("vin","10000000000000001");
     ServiceCarStatus.msysparam.mstrid = xp.GetParam("id","1");
     ServiceCarStatus.msysparam.mstrid = xp.GetParam("id","1");
     ServiceCarStatus.msysparam.mstriccid = xp.GetParam("iccid","11111111111111111111");
     ServiceCarStatus.msysparam.mstriccid = xp.GetParam("iccid","11111111111111111111");
-    ServiceCarStatus.msysparam.mvehtype= xp.GetParam("vehType","ge3");
+    ServiceCarStatus.msysparam.mvehtype= xp.GetParam("vehType","yuhesen");
 
 
     ServiceCarStatus.msysparam.vehWidth = atof(xp.GetParam("vehWidth","2.1").data());
     ServiceCarStatus.msysparam.vehWidth = atof(xp.GetParam("vehWidth","2.1").data());
     ServiceCarStatus.msysparam.vehLenth = atof(xp.GetParam("vehLenth","4.6").data());
     ServiceCarStatus.msysparam.vehLenth = atof(xp.GetParam("vehLenth","4.6").data());
@@ -403,7 +403,7 @@ void iv::decition::BrainDecition::run() {
         ServiceCarStatus.useObsPredict = true;
         ServiceCarStatus.useObsPredict = true;
     }
     }
 
 
-    std::string inRoadAvoid = xp.GetParam("inRoadAvoid","true");  //If Use MPC set true
+    std::string inRoadAvoid = xp.GetParam("inRoadAvoid","false");  //If Use MPC set true
     if(inRoadAvoid == "true")
     if(inRoadAvoid == "true")
     {
     {
         ServiceCarStatus.inRoadAvoid = true;
         ServiceCarStatus.inRoadAvoid = true;
@@ -1024,7 +1024,7 @@ void iv::decition::BrainDecition::UpdateMap(const char *mapdata, const int mapda
         }
         }
 
 
         mmpcapi.SetMAP(xvectorMAP);
         mmpcapi.SetMAP(xvectorMAP);
-
+                                                                                                    
         if(ServiceCarStatus.speed_control==true){
         if(ServiceCarStatus.speed_control==true){
         Compute00().getDesiredSpeed(navigation_data);}
         Compute00().getDesiredSpeed(navigation_data);}
         mMutexMap.unlock();
         mMutexMap.unlock();

+ 9 - 4
src/decition/decition_brain/decition/decide_gps_00.cpp

@@ -986,6 +986,10 @@ iv::decition::Decition iv::decition::DecideGps00::getDecideFromGPS(GPS_INS now_g
          gpsMapLine[PathPoint]->runMode=0;
          gpsMapLine[PathPoint]->runMode=0;
     }
     }
 
 
+    if(roadNowStart){
+        roadNow=roadOri;
+        roadNowStart=false;
+    }
 
 
  //   avoidX = (roadOri-roadNow)*roadWidth;
  //   avoidX = (roadOri-roadNow)*roadWidth;
     avoidX=computeAvoidX(roadNow,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
     avoidX=computeAvoidX(roadNow,roadOri,gpsMapLine[PathPoint],ServiceCarStatus.msysparam.vehWidth);
@@ -2057,15 +2061,13 @@ void iv::decition::DecideGps00::initMethods(){
     zhongche_Adapter = new ZhongcheAdapter();
     zhongche_Adapter = new ZhongcheAdapter();
     bus_Adapter = new BusAdapter();
     bus_Adapter = new BusAdapter();
     hapo_Adapter = new HapoAdapter();
     hapo_Adapter = new HapoAdapter();
+    yuhesen_Adapter = new YuHeSenAdapter();
 
 
 
 
     mpid_Controller.reset(pid_Controller);
     mpid_Controller.reset(pid_Controller);
-    mge3_Adapter.reset(ge3_Adapter);
-    mqingyuan_Adapter.reset(qingyuan_Adapter);
-    mvv7_Adapter.reset(vv7_Adapter);
-    mzhongche_Adapter.reset(zhongche_Adapter);
     mbus_Adapter.reset(bus_Adapter);
     mbus_Adapter.reset(bus_Adapter);
     mhapo_Adapter.reset(hapo_Adapter);
     mhapo_Adapter.reset(hapo_Adapter);
+    myuhesen_Adapter.reset(yuhesen_Adapter);
 
 
     frenetPlanner = new FrenetPlanner();
     frenetPlanner = new FrenetPlanner();
     //    laneChangePlanner = new LaneChangePlanner();
     //    laneChangePlanner = new LaneChangePlanner();
@@ -2093,6 +2095,9 @@ void iv::decition::DecideGps00::phaseSpeedDecition(iv::decition::Decition  decit
     }else if(ServiceCarStatus.msysparam.mvehtype=="hapo"){
     }else if(ServiceCarStatus.msysparam.mvehtype=="hapo"){
         hapo_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
         hapo_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
     }
     }
+    else if(ServiceCarStatus.msysparam.mvehtype=="yuhesen"){
+        yuhesen_Adapter->getAdapterDeciton(gpsIns, gpsTraceNow, dSpeed, obsDis,obsSpeed,  decition->accelerator,ServiceCarStatus.mfCalAcc  ,changingDangWei, &decition);
+    }
 }
 }
 
 
 
 

+ 5 - 1
src/decition/decition_brain/decition/decide_gps_00.h

@@ -15,6 +15,8 @@
 #include <decition/adc_adapter/zhongche_adapter.h>
 #include <decition/adc_adapter/zhongche_adapter.h>
 #include <decition/adc_adapter/bus_adapter.h>
 #include <decition/adc_adapter/bus_adapter.h>
 #include <decition/adc_adapter/hapo_adapter.h>
 #include <decition/adc_adapter/hapo_adapter.h>
+#include <decition/adc_adapter/zhongche_adapter.h>
+#include <decition/adc_adapter/yuhesen_adapter.h>
 #include "perception/perceptionoutput.h"
 #include "perception/perceptionoutput.h"
 #include "ivlog.h"
 #include "ivlog.h"
 #include <memory>
 #include <memory>
@@ -125,6 +127,7 @@ public:
     BaseAdapter *zhongche_Adapter;
     BaseAdapter *zhongche_Adapter;
     BaseAdapter *bus_Adapter;
     BaseAdapter *bus_Adapter;
     BaseAdapter *hapo_Adapter;
     BaseAdapter *hapo_Adapter;
+    BaseAdapter *yuhesen_Adapter;
 
 
     std::shared_ptr<BaseController> mpid_Controller;
     std::shared_ptr<BaseController> mpid_Controller;
     std::shared_ptr<BaseAdapter> mge3_Adapter;
     std::shared_ptr<BaseAdapter> mge3_Adapter;
@@ -133,7 +136,7 @@ public:
     std::shared_ptr<BaseAdapter> mzhongche_Adapter;
     std::shared_ptr<BaseAdapter> mzhongche_Adapter;
     std::shared_ptr<BaseAdapter> mbus_Adapter;
     std::shared_ptr<BaseAdapter> mbus_Adapter;
     std::shared_ptr<BaseAdapter> mhapo_Adapter;
     std::shared_ptr<BaseAdapter> mhapo_Adapter;
-
+    std::shared_ptr<BaseAdapter> myuhesen_Adapter;
 
 
 	FrenetPlanner *frenetPlanner;
 	FrenetPlanner *frenetPlanner;
 //    BasePlanner *laneChangePlanner;
 //    BasePlanner *laneChangePlanner;
@@ -230,6 +233,7 @@ public:
     double ObsTimeEnd=-1;
     double ObsTimeEnd=-1;
     float ObsTimeWidth=1500;
     float ObsTimeWidth=1500;
     std::vector<iv::TracePoint> planTrace;
     std::vector<iv::TracePoint> planTrace;
+    bool roadNowStart=true;
 private:
 private:
     //  void changeRoad(int roadNum);
     //  void changeRoad(int roadNum);
 
 

+ 5 - 3
src/decition/decition_brain/decition/decition.pri

@@ -24,7 +24,8 @@ HEADERS += \
     $$PWD/adc_tools/dubins.h \
     $$PWD/adc_tools/dubins.h \
     $$PWD/adc_adapter/bus_adapter.h \
     $$PWD/adc_adapter/bus_adapter.h \
     $$PWD/fanyaapi.h \
     $$PWD/fanyaapi.h \
-    $$PWD/adc_adapter/hapo_adapter.h
+    $$PWD/adc_adapter/hapo_adapter.h \
+    $$PWD/adc_adapter/yuhesen_adapter.h
 
 
 SOURCES += \
 SOURCES += \
     $$PWD/decide_gps_00.cpp \
     $$PWD/decide_gps_00.cpp \
@@ -44,9 +45,10 @@ SOURCES += \
     $$PWD/adc_adapter/base_adapter.cpp \
     $$PWD/adc_adapter/base_adapter.cpp \
     $$PWD/adc_adapter/qingyuan_adapter.cpp \
     $$PWD/adc_adapter/qingyuan_adapter.cpp \
     $$PWD/adc_adapter/vv7_adapter.cpp \
     $$PWD/adc_adapter/vv7_adapter.cpp \
-    $$PWD/adc_adapter/zhongche_adapter.cpp \
     $$PWD/adc_planner/dubins_planner.cpp \
     $$PWD/adc_planner/dubins_planner.cpp \
     $$PWD/adc_tools/dubins.cpp \
     $$PWD/adc_tools/dubins.cpp \
     $$PWD/adc_adapter/bus_adapter.cpp \
     $$PWD/adc_adapter/bus_adapter.cpp \
     $$PWD/fanyaapi.cpp \
     $$PWD/fanyaapi.cpp \
-    $$PWD/adc_adapter/hapo_adapter.cpp
+    $$PWD/adc_adapter/hapo_adapter.cpp \
+    $$PWD/adc_adapter/zhongche_adapter.cpp \
+    $$PWD/adc_adapter/yuhesen_adapter.cpp

+ 1 - 1
src/decition/decition_brain_sf/decition/brain.cpp

@@ -372,7 +372,7 @@ void iv::decition::BrainDecition::run() {
     }
     }
     //map
     //map
 
 
-    std::string inRoadAvoid = xp.GetParam("inRoadAvoid","true");  //If Use MPC set true
+    std::string inRoadAvoid = xp.GetParam("inRoadAvoid","false");  //If Use MPC set true
     if(inRoadAvoid == "true")
     if(inRoadAvoid == "true")
     {
     {
         ServiceCarStatus.inRoadAvoid = true;
         ServiceCarStatus.inRoadAvoid = true;

+ 5 - 0
src/decition/decition_brain_sf/decition/decide_gps_00.cpp

@@ -978,6 +978,11 @@ iv::decition::Decition iv::decition::DecideGps00::getDecideFromGPS(GPS_INS now_g
         roadSum = gpsMapLine[PathPoint]->roadSum*3;
         roadSum = gpsMapLine[PathPoint]->roadSum*3;
     }
     }
 
 
+    if(roadNowStart){
+        roadNow=roadOri;
+        roadNowStart=false;
+    }
+
     if(ServiceCarStatus.avoidObs){
     if(ServiceCarStatus.avoidObs){
          gpsMapLine[PathPoint]->runMode=1;
          gpsMapLine[PathPoint]->runMode=1;
     }else{
     }else{

+ 2 - 0
src/decition/decition_brain_sf/decition/decide_gps_00.h

@@ -226,6 +226,8 @@ public:
     double ObsTimeEnd=-1;
     double ObsTimeEnd=-1;
     float ObsTimeWidth=1500;
     float ObsTimeWidth=1500;
     std::vector<iv::TracePoint> planTrace;
     std::vector<iv::TracePoint> planTrace;
+
+    bool roadNowStart=true;
 private:
 private:
     //  void changeRoad(int roadNum);
     //  void changeRoad(int roadNum);
 
 

+ 11 - 0
src/detection/detection_chassis/decodechassis.cpp

@@ -369,3 +369,14 @@ int ProcHAPOChassis(void * pa, iv::can::canmsg * pmsg)
     return nRtn;
     return nRtn;
 
 
 }
 }
+
+
+int ProcYUHESENChassis(void * pa, iv::can::canmsg * pmsg)
+{
+    int i;
+    int nRtn = 0;
+
+
+    return nRtn;
+
+}

+ 1 - 0
src/detection/detection_chassis/decodechassis.h

@@ -19,5 +19,6 @@ int ProcMIDBUSChassis(void * pa, iv::can::canmsg * pmsg);
 
 
 int ProcHAPOChassis(void * pa, iv::can::canmsg * pmsg);
 int ProcHAPOChassis(void * pa, iv::can::canmsg * pmsg);
 
 
+int ProcYUHESENChassis(void * pa, iv::can::canmsg * pmsg);
 
 
 #endif // DECODECHASSIS_H
 #endif // DECODECHASSIS_H

+ 8 - 1
src/detection/detection_chassis/main.cpp

@@ -26,7 +26,7 @@ QTime gTime;
 
 
 namespace  iv {
 namespace  iv {
 
 
-enum VehicleTypeDef {GE3,VV7,MIDCAR,PROBLUE,MIDBUS,HAPO,UNKNOWN} gVehicleType;  //车辆类型
+enum VehicleTypeDef {GE3,VV7,MIDCAR,PROBLUE,MIDBUS,HAPO,UNKNOWN, YUHESEN} gVehicleType;  //车辆类型
 
 
 
 
 }
 }
@@ -77,6 +77,9 @@ void Listencan0(const char * strdata,const unsigned int nSize,const unsigned int
     case iv::HAPO:
     case iv::HAPO:
         nRtn = ProcHAPOChassis(gpa,&xmsg);
         nRtn = ProcHAPOChassis(gpa,&xmsg);
         break;
         break;
+    case iv::YUHESEN:
+        nRtn = ProcYUHESENChassis(gpa,&xmsg);
+        break;
     default:
     default:
         break;
         break;
     }
     }
@@ -172,6 +175,10 @@ int main(int argc, char *argv[])
     {
     {
         iv::gVehicleType = iv::HAPO;
         iv::gVehicleType = iv::HAPO;
     }
     }
+ if(strncmp(strvehicletype.data(),"YUHESEN",255) == 0)
+    {
+        iv::gVehicleType = iv::YUHESEN;
+    }
 
 
 //iv::gVehicleType = iv::MIDBUS;
 //iv::gVehicleType = iv::MIDBUS;
 
 

+ 115 - 111
src/detection/detection_mobileye/main.cpp

@@ -2,7 +2,7 @@
 
 
 #include <iostream>
 #include <iostream>
 #include <QDateTime>
 #include <QDateTime>
-
+#include <QDebug>
 #include "modulecomm.h"
 #include "modulecomm.h"
 #include "xmlparam.h"
 #include "xmlparam.h"
 #include "ivversion.h"
 #include "ivversion.h"
@@ -74,11 +74,11 @@ void ProcCANMsg(iv::can::canraw xmsg)
         double curv, head, yaw, pitch;
         double curv, head, yaw, pitch;
         int ldw_left, ldw_right;
         int ldw_left, ldw_right;
         short ihead;
         short ihead;
-        for(int i = 0; i< 8; i++)
-        {
+//        for(int i = 0; i< 8; i++)
+//        {
 
 
-            gMobEyeIvlog->verbose("mobileye","i:%d %x %d\n ",i, xdata[i], xdata[i]);
-        }
+//            gMobEyeIvlog->verbose("mobileye","i:%d %x %d\n ",i, xdata[i], xdata[i]);
+//        }
         tmp = 0;
         tmp = 0;
         //lane curv
         //lane curv
         tmp = (xdata[1] << 8) | xdata[0];
         tmp = (xdata[1] << 8) | xdata[0];
@@ -199,47 +199,51 @@ void ProcCANMsg(iv::can::canraw xmsg)
      *  is_obstacle_brake_lights bool                  /             0,1            0 object's brake light off or not identified, 1 object's brake light on
      *  is_obstacle_brake_lights bool                  /             0,1            0 object's brake light off or not identified, 1 object's brake light on
      *  obstacle_valid           int/enum              /            [1:2]           1 new valid(detected this frame), 2 older valid
      *  obstacle_valid           int/enum              /            [1:2]           1 new valid(detected this frame), 2 older valid
      *************************************************************************************************************************************************************/
      *************************************************************************************************************************************************************/
-    else if((xmsg.id()-0x739)/3 == 0)
+    else if(xmsg.id() > 0x738 && xmsg.id() < 0x766)
     {
     {
-        //obstacle id
-        gobs.set_id(xdata[0]);
+        if((xmsg.id()-0x739)%3 == 0)
+        {
+            //obstacle id
+            gobs.set_id(xdata[0]);
 
 
-        //obstacle pos x
-        tmp = ((xdata[2] & 0xf) << 8) | xdata[1];
-        gobs.set_pos_x(tmp * 0.0625);
-        tmp = 0;
+            //obstacle pos x
+            tmp = ((xdata[2] & 0xf) << 8) | xdata[1];
+            gobs.set_pos_x(tmp * 0.0625);
+            tmp = 0;
 
 
-        //obstacle pos y
-        tmp = ((xdata[4] & 0x3) << 8) | xdata[3];
-        tmp <<= 22;
-        tmp >>= 22;
-        gobs.set_pos_y(tmp * 0.0625);
+            //obstacle pos y
+            tmp = ((xdata[4] & 0x3) << 8) | xdata[3];
+            tmp <<= 22;
+            tmp >>= 22;
+            gobs.set_pos_y(tmp * 0.0625);
 
 
-        //blinker info
-        gobs.set_blinkerinfo((xdata[4] >> 2) & 0x7);
+            //blinker info
+            gobs.set_blinkerinfo((xdata[4] >> 2) & 0x7);
 
 
-        //cut in and out
-        gobs.set_cutstate(iv::mobileye::obs_CUTSTATE(xdata[4] >> 5));
+            //cut in and out
+            gobs.set_cutstate(iv::mobileye::obs_CUTSTATE(xdata[4] >> 5));
+            //        gobs.set_cutstate(xdata[4] >> 5);
 
 
-        //obstacle rel vel x
-        tmp = ((xdata[6] & 0xf) << 8) | xdata[5];
-        tmp <<= 20;
-        tmp >>= 20;
-        gobs.set_obs_rel_vel_x(tmp * 0.0625);
+            //obstacle rel vel x
+            tmp = ((xdata[6] & 0xf) << 8) | xdata[5];
+            tmp <<= 20;
+            tmp >>= 20;
+            gobs.set_obs_rel_vel_x(tmp * 0.0625);
 
 
-        //obstacle type
-        gobs.set_obstype(iv::mobileye::obs_OBSTYPE((xdata[6] >> 4) & 0x7));
+            //obstacle type
+            gobs.set_obstype(iv::mobileye::obs_OBSTYPE((xdata[6] >> 4) & 0x7));
 
 
-        //obstacle status
-        gobs.set_obssatus(iv::mobileye::obs_OBSSTATE(xdata[7] & 0x7));
+            //obstacle status
+            gobs.set_obssatus(iv::mobileye::obs_OBSSTATE(xdata[7] & 0x7));
 
 
-        //obstacle brake lights
-        gobs.set_obsbrakelights((xdata[7] >> 3) & 0x1);
+            //obstacle brake lights
+            gobs.set_obsbrakelights((xdata[7] >> 3) & 0x1);
 
 
-        //obstacle valid
-        gobs.set_obsvalid((xdata[7] >> 6) & 0x7);
-    }
-    /****************************************************  mobileye obstacle data b  ****************************************************************************
+            //obstacle valid
+            gobs.set_obsvalid((xdata[7] >> 6) & 0x7);
+
+        }
+        /****************************************************  mobileye obstacle data b  ****************************************************************************
      *  message ID:0x73a
      *  message ID:0x73a
      *  member:                  type           physical unit       range               note
      *  member:                  type           physical unit       range               note
      *  obstacle_length          double                m           [0,31]           length of the obstacle(longitude axis)
      *  obstacle_length          double                m           [0,31]           length of the obstacle(longitude axis)
@@ -256,50 +260,50 @@ void ProcCANMsg(iv::can::canraw xmsg)
      *                                                                              vision and radar measurements higher->smaller error, 5 high confidence match
      *                                                                              vision and radar measurements higher->smaller error, 5 high confidence match
      *  matched_radar_id         int                   /           [0:127]          ID of Primary radar target matched to the vision target if applicable
      *  matched_radar_id         int                   /           [0:127]          ID of Primary radar target matched to the vision target if applicable
      *************************************************************************************************************************************************************/
      *************************************************************************************************************************************************************/
-    else if((xmsg.id()-0x73a)/3 == 0)
-    {
-        //obstacle length
-        tmp = xdata[0];
-        gobs.set_obslen(tmp * 0.5);
-        tmp = 0;
+        else if((xmsg.id()-0x73a)%3 == 0)
+        {
+            //obstacle length
+            tmp = xdata[0];
+            gobs.set_obslen(tmp * 0.5);
+            tmp = 0;
 
 
-        //obstacle width
-        tmp = xdata[1];
-        gobs.set_obswidth(tmp * 0.05);
+            //obstacle width
+            tmp = xdata[1];
+            gobs.set_obswidth(tmp * 0.05);
 
 
-        tmp = 0;
+            tmp = 0;
 
 
-        //obstacle age
-        gobs.set_obsage(xdata[2]);
+            //obstacle age
+            gobs.set_obsage(xdata[2]);
 
 
-        //obstacle lane
-        gobs.set_obslane(xdata[3] & 0x3);
+            //obstacle lane
+            gobs.set_obslane(xdata[3] & 0x3);
 
 
-        //is cipv flag
-        gobs.set_cipvflag((xdata[3] >> 2) & 0x1);
+            //is cipv flag
+            gobs.set_cipvflag((xdata[3] >> 2) & 0x1);
 
 
-        //radar pos x
-        tmp = (xdata[4] << 4) | (xdata[3] >> 4);
-        gobs.set_radarposx(tmp * 0.0625);
+            //radar pos x
+            tmp = (xdata[4] << 4) | (xdata[3] >> 4);
+            gobs.set_radarposx(tmp * 0.0625);
 
 
-        tmp = 0;
+            tmp = 0;
 
 
-        //radar vel x
-        tmp = ((xdata[6] & 0xf) << 8) | xdata[5];
-        tmp <<= 20;
-        tmp >>= 20;
-        gobs.set_radarvelx(tmp * 0.0625);
+            //radar vel x
+            tmp = ((xdata[6] & 0xf) << 8) | xdata[5];
+            tmp <<= 20;
+            tmp >>= 20;
+            gobs.set_radarvelx(tmp * 0.0625);
 
 
-        tmp = 0;
+            tmp = 0;
 
 
-        //radar match confidence
-        gobs.set_radarmatchconfi((xdata[6] >> 4) & 0x7);
+            //radar match confidence
+            gobs.set_radarmatchconfi((xdata[6] >> 4) & 0x7);
 
 
-        //matched radar ID
-        gobs.set_matchedradarid(xdata[7] & 0x7f);
+            //matched radar ID
+            gobs.set_matchedradarid(xdata[7] & 0x7f);
 
 
-    }
-    /****************************************************  mobileye obstacle data c  ****************************************************************************
+        }
+        /****************************************************  mobileye obstacle data c  ****************************************************************************
      *  message ID:0x73b
      *  message ID:0x73b
      *  member:                  type           physical unit       range               note
      *  member:                  type           physical unit       range               note
      *  obstacle_angle_rate      double           degree/s     [-327.68, 327.68]    Angle rate of Center of Obstacle, negative->moved to left
      *  obstacle_angle_rate      double           degree/s     [-327.68, 327.68]    Angle rate of Center of Obstacle, negative->moved to left
@@ -309,48 +313,48 @@ void ProcCANMsg(iv::can::canraw xmsg)
      *  obstacle_angle           double           degree        [-327.68,327.68]    Angle to Center of Obstacle in degrees, 0 indicates that the obstacle is in
      *  obstacle_angle           double           degree        [-327.68,327.68]    Angle to Center of Obstacle in degrees, 0 indicates that the obstacle is in
      *                                                                              exactly in front of us, a positive angle indicates that theobstacle is to the right
      *                                                                              exactly in front of us, a positive angle indicates that theobstacle is to the right
      *************************************************************************************************************************************************************/
      *************************************************************************************************************************************************************/
-    else if((xmsg.id()-0x73b)/3 == 0)
-    {
-        //obstacle angle rate
-        tmp = (xdata[1] << 8) | xdata[0];
-        tmp <<= 16;
-        tmp >>= 16;
-        gobs.set_obsangrate(tmp * 0.01);
-
-        tmp = 0;
-
-        //obstacle scale change
-        tmp = (xdata[3] << 8) | xdata[2];
-        tmp <<= 16;
-        tmp >>= 16;
-        gobs.set_obsscalechange(tmp * 0.0002);
-
-        tmp = 0;
-
-        //object accel x
-        tmp = ((xdata[5] & 0x3) << 8) | xdata[4];
-        tmp <<= 22;
-        tmp >>= 22;
-        gobs.set_accelx(tmp * 0.03);
-
-        tmp = 0;
-
-        //obstacle replaced
-        gobs.set_obsreplaced((xdata[5] >> 4) & 0x1);
-
-        //obstacle angle
-        tmp = (xdata[7] << 8) | xdata[6];
-        tmp <<= 16;
-        tmp >>= 16;
-        gobs.set_obsang(tmp * 0.01);
-
-        iv::mobileye::obs * pxobs = gmobileye.add_xobj();
-        pxobs->CopyFrom(gobs);
-        gobs_count++;
-        gMobEyeIvlog->verbose("mobileyeobs", "nums:%d cur_count:%d, obs_id:%d, pos_x:%f, pos_y:%f \n",\
-                              gnum_obstacles, gobs_count, gobs.id(), gobs.pos_x(), gobs.pos_y());
+        else if((xmsg.id()-0x73b)%3 == 0)
+        {
+            //obstacle angle rate
+            tmp = (xdata[1] << 8) | xdata[0];
+            tmp <<= 16;
+            tmp >>= 16;
+            gobs.set_obsangrate(tmp * 0.01);
+
+            tmp = 0;
+
+            //obstacle scale change
+            tmp = (xdata[3] << 8) | xdata[2];
+            tmp <<= 16;
+            tmp >>= 16;
+            gobs.set_obsscalechange(tmp * 0.0002);
+
+            tmp = 0;
+
+            //object accel x
+            tmp = ((xdata[5] & 0x3) << 8) | xdata[4];
+            tmp <<= 22;
+            tmp >>= 22;
+            gobs.set_accelx(tmp * 0.03);
+
+            tmp = 0;
+
+            //obstacle replaced
+            gobs.set_obsreplaced((xdata[5] >> 4) & 0x1);
+
+            //obstacle angle
+            tmp = (xdata[7] << 8) | xdata[6];
+            tmp <<= 16;
+            tmp >>= 16;
+            gobs.set_obsang(tmp * 0.01);
+
+            iv::mobileye::obs * pxobs = gmobileye.add_xobj();
+            pxobs->CopyFrom(gobs);
+            gobs_count++;
+            gMobEyeIvlog->verbose("mobileyeobs", "nums:%d cur_count:%d, obs_id:%d, pos_x:%f, pos_y:%f \n",\
+                                  gnum_obstacles, gobs_count, gobs.id(), gobs.pos_x(), gobs.pos_y());
+        }
     }
     }
-
     /****************************************************  mobileye aftermarket lane  ****************************************************************************
     /****************************************************  mobileye aftermarket lane  ****************************************************************************
      *  message ID:0x669
      *  message ID:0x669
      *  member:                  type           physical unit       range               note
      *  member:                  type           physical unit       range               note
@@ -495,8 +499,8 @@ int main(int argc, char *argv[])
 
 
     iv::xmlparam::Xmlparam xp(strpath.toStdString());
     iv::xmlparam::Xmlparam xp(strpath.toStdString());
 
 
-    std::string strmemcan = xp.GetParam("canrecv","canrecv0");
-    std::string strmemsend = xp.GetParam("cansend","cansend0");
+    std::string strmemcan = xp.GetParam("canrecv","canrecv1");
+    std::string strmemsend = xp.GetParam("cansend","cansend1");
     std::string strmemmobileye = xp.GetParam("mobileye","mobileye");
     std::string strmemmobileye = xp.GetParam("mobileye","mobileye");
 
 
     gTime.start();
     gTime.start();

+ 54 - 38
src/detection/detection_radar_delphi_esr_send/main.cpp

@@ -5,6 +5,7 @@
 #include <math.h>
 #include <math.h>
 #include <thread>
 #include <thread>
 #include <QDebug>
 #include <QDebug>
+#include <QReadWriteLock>
 
 
 #include <signal.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <stdlib.h>
@@ -40,12 +41,12 @@ static uint16_t Radar_to_Rear_Axle = 370;//< 0-710 cm
 static uint16_t Car_Wheel_Base = 270;//< 0-710 cm
 static uint16_t Car_Wheel_Base = 270;//< 0-710 cm
 static uint8_t Car_Steering_Gear_Ratio = 18;//< 0-31.875
 static uint8_t Car_Steering_Gear_Ratio = 18;//< 0-31.875
 /******************************************/
 /******************************************/
-
+QReadWriteLock *wrLock = new QReadWriteLock();
 canSend4F0 canData4f0;
 canSend4F0 canData4f0;
 canSend4F1 canData4f1;
 canSend4F1 canData4f1;
 canSend5F2 canData5f2;
 canSend5F2 canData5f2;
 canSend5F4 canData5f4;
 canSend5F4 canData5f4;
-
+int canChannel = 0;
 /******************************************/
 /******************************************/
 
 
 iv::Ivlog * givlog;
 iv::Ivlog * givlog;
@@ -69,7 +70,6 @@ void ExecSend()
 {
 {
     iv::can::canmsg xmsg;
     iv::can::canmsg xmsg;
     iv::can::canraw xraw;
     iv::can::canraw xraw;
-qDebug()<<QTime::currentTime();
     xraw.set_id(0x4F0);
     xraw.set_id(0x4F0);
     xraw.set_data(canData4f0.byte,8);
     xraw.set_data(canData4f0.byte,8);
     xraw.set_bext(false);
     xraw.set_bext(false);
@@ -136,8 +136,10 @@ void Listengpsimu(const char * strdata,const unsigned int nSize,const unsigned i
         givlog->warn("detection_radar_delphi_esr_send--Listengpsimu parse errror. nSize is %d",nSize);
         givlog->warn("detection_radar_delphi_esr_send--Listengpsimu parse errror. nSize is %d",nSize);
         return;
         return;
     }
     }
+    wrLock->lockForWrite();
     Vehicle_Yaw_Rate = xgpsimu.gyro_z() * -1;
     Vehicle_Yaw_Rate = xgpsimu.gyro_z() * -1;
     Vehicle_Speed = sqrt(xgpsimu.vn()*xgpsimu.vn() + xgpsimu.ve()*xgpsimu.ve() + xgpsimu.vd()*xgpsimu.vd());
     Vehicle_Speed = sqrt(xgpsimu.vn()*xgpsimu.vn() + xgpsimu.ve()*xgpsimu.ve() + xgpsimu.vd()*xgpsimu.vd());
+    wrLock->unlock();
 }
 }
 
 
 void Listencancar(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
 void Listencancar(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
@@ -158,10 +160,12 @@ void Listencancar(const char * strdata,const unsigned int nSize,const unsigned i
 
 
 /****************timer*********************/
 /****************timer*********************/
 
 
-void signalHandler(int num)
+void signalHandler()
 {
 {
+    wrLock->lockForRead();
     unsigned int speed = (unsigned int)(Vehicle_Speed / 0.0625);
     unsigned int speed = (unsigned int)(Vehicle_Speed / 0.0625);
     int yawRate = (int)(Vehicle_Yaw_Rate / 0.0625);
     int yawRate = (int)(Vehicle_Yaw_Rate / 0.0625);
+    wrLock->unlock();
 
 
     canData4f0.bit.canVehicleSpeedH = speed >> 8;
     canData4f0.bit.canVehicleSpeedH = speed >> 8;
     canData4f0.bit.canVehicleSpeedL = speed & 0xFF;
     canData4f0.bit.canVehicleSpeedL = speed & 0xFF;
@@ -489,7 +493,7 @@ void threadstate()
 {
 {
     while(1)
     while(1)
     {
     {
-        std::this_thread::sleep_for(std::chrono::milliseconds(10));
+        std::this_thread::sleep_for(std::chrono::milliseconds(20));
         if(gnRadarState > -100)gnRadarState--;
         if(gnRadarState > -100)gnRadarState--;
         if(gnRadarState > 0)
         if(gnRadarState > 0)
         {
         {
@@ -506,7 +510,8 @@ void threadstate()
                 givfault->SetFaultState(2,2,"无CAN数据");
                 givfault->SetFaultState(2,2,"无CAN数据");
             }
             }
         }
         }
-
+        signalHandler();
+        qDebug()<<QTime::currentTime();
     }
     }
 }
 }
 
 
@@ -514,6 +519,42 @@ int main(int argc, char *argv[])
 {
 {
     QCoreApplication a(argc, argv);
     QCoreApplication a(argc, argv);
 
 
+    QString strpath = QCoreApplication::applicationDirPath();
+    if(argc < 2)
+        strpath = strpath + "/detection_radar_esr.xml";
+    else
+        strpath = argv[1];
+    std::cout<<strpath.toStdString()<<std::endl;
+
+    iv::xmlparam::Xmlparam xp(strpath.toStdString());
+
+    std::string strmemcan = xp.GetParam("canrecv","canrecv1");
+    std::string strmemsend = xp.GetParam("cansend","cansend1");
+    std::string strmemradar = xp.GetParam("radar","radar");
+    std::string strmodulename = xp.GetParam("modulename","detection_radar_delphi_esr");
+#ifdef fujiankuan
+    gstrmemgpsimu = xp.GetParam("gpsimu_name","hcp2_gpsimu");
+    gstrmemcancar = xp.GetParam("cancar","can_car");
+#endif
+    givlog = new iv::Ivlog(strmodulename.data());
+    givfault = new iv::Ivfault(strmodulename.data());
+
+    givfault->SetFaultState(1,1,"初始化");
+    givlog->info("Initialized");
+
+    if(strmemsend.compare("cansend0") == 0){
+        canChannel = 0;
+        givlog->info("ESR","set ESR can send channel to 0");
+    }
+    if(strmemsend.compare("cansend1") == 0){
+        canChannel = 1;
+        givlog->info("ESR","set ESR can send channel to 1");
+}
+    else {
+        givlog->info("ESR","Not agx can,set default ESR can send channel to 0");
+        canChannel = 0;
+    }
+
     iv::radar::radarobjectarray x;
     iv::radar::radarobjectarray x;
     x.set_mstime(0);
     x.set_mstime(0);
     int i;
     int i;
@@ -542,31 +583,6 @@ int main(int argc, char *argv[])
     memset(canData5f2.byte,0,8);
     memset(canData5f2.byte,0,8);
     memset(canData5f4.byte,0,8);
     memset(canData5f4.byte,0,8);
 
 
-    QString strpath = QCoreApplication::applicationDirPath();
-    if(argc < 2)
-        strpath = strpath + "/detection_radar_esr.xml";
-    else
-        strpath = argv[1];
-    std::cout<<strpath.toStdString()<<std::endl;
-
-    iv::xmlparam::Xmlparam xp(strpath.toStdString());
-
-    std::string strmemcan = xp.GetParam("canrecv","canrecv1");
-    std::string strmemsend = xp.GetParam("cansend","cansend1");
-    std::string strmemradar = xp.GetParam("radar","radar");
-    std::string strmodulename = xp.GetParam("modulename","detection_radar_delphi_esr");
-#ifdef fujiankuan
-    gstrmemgpsimu = xp.GetParam("gpsimu_name","hcp2_gpsimu");
-    gstrmemcancar = xp.GetParam("cancar","can_car");
-#endif
-
-
-    givlog = new iv::Ivlog(strmodulename.data());
-    givfault = new iv::Ivfault(strmodulename.data());
-
-    givfault->SetFaultState(1,1,"初始化");
-    givlog->info("Initialized");
-
     gpa = iv::modulecomm::RegisterSend(strmemradar.data(),100000,3);
     gpa = iv::modulecomm::RegisterSend(strmemradar.data(),100000,3);
     gpb = iv::modulecomm::RegisterSend(strmemsend.data(),100000,1);
     gpb = iv::modulecomm::RegisterSend(strmemsend.data(),100000,1);
     void * pa = iv::modulecomm::RegisterRecv(strmemcan.data(),Listencan0);
     void * pa = iv::modulecomm::RegisterRecv(strmemcan.data(),Listencan0);
@@ -580,13 +596,13 @@ int main(int argc, char *argv[])
 //    signal(SIGALRM, signalHandler);
 //    signal(SIGALRM, signalHandler);
 //    ualarm(2000,2000);
 //    ualarm(2000,2000);
 
 
-    signal(SIGALRM, signalHandler);
+//    signal(SIGALRM, signalHandler);
 
 
-    struct itimerval new_value, old_value;
-    new_value.it_value.tv_sec = 0;
-    new_value.it_value.tv_usec = 1;
-    new_value.it_interval.tv_sec = 0;
-    new_value.it_interval.tv_usec = 20000;
-    setitimer(ITIMER_REAL, &new_value, NULL);
+//    struct itimerval new_value, old_value;
+//    new_value.it_value.tv_sec = 0;
+//    new_value.it_value.tv_usec = 1;
+//    new_value.it_interval.tv_sec = 0;
+//    new_value.it_interval.tv_usec = 20000;
+//    setitimer(ITIMER_REAL, &new_value, NULL);
     return a.exec();
     return a.exec();
 }
 }

+ 1 - 1
src/driver/driver_cloud_grpc_client_BS/VehicleControl_service.proto

@@ -13,7 +13,7 @@ service VehicleControl {
   // 车辆远程控制
   // 车辆远程控制
   rpc vehicleControl (Empty) returns (ControlReply) {}
   rpc vehicleControl (Empty) returns (ControlReply) {}
   // 路径生成
   // 路径生成
-  rpc UploadMap(Empty) returns(UploadMapReply) {}
+  rpc UploadMap(Empty) returns(UploadMapReply) {}  //this service may change into uploadMap in future
   // 控制模式改变
   // 控制模式改变
   rpc changeCtrlMode(Empty) returns(CtrlModeReply) {}
   rpc changeCtrlMode(Empty) returns(CtrlModeReply) {}
 }
 }

+ 2 - 2
src/driver/driver_cloud_grpc_client_BS/VehiclePatrol.proto

@@ -37,5 +37,5 @@ message PatrolRequest{
     string plateNumber = 18;
     string plateNumber = 18;
 }
 }
 
 
-message Empty{
-}
+message Empty{ //this message need a id in future
+}

+ 1 - 1
src/driver/driver_cloud_grpc_client_BS/VehicleUpload_service.proto

@@ -10,7 +10,7 @@ option java_outer_classname = "VehicleService";
 import "VehicleUpload.proto";
 import "VehicleUpload.proto";
 
 
 service DataExchange {
 service DataExchange {
-  rpc uploadVehicleOInfo (UplinkRequest) returns (ResponseMessage) {}
+  rpc uploadVehicleInfo (UplinkRequest) returns (ResponseMessage) {}
   
   
   rpc uploadPath (UploadPathRequest) returns (Empty) {}
   rpc uploadPath (UploadPathRequest) returns (Empty) {}
 }
 }

+ 6 - 2
src/driver/driver_cloud_grpc_client_BS/driver_cloud_grpc_client_BS.pro

@@ -30,7 +30,9 @@ SOURCES += \
         VehicleUpload_service.grpc.pb.cc \
         VehicleUpload_service.grpc.pb.cc \
         VehicleUpload_service.pb.cc \
         VehicleUpload_service.pb.cc \
         main.cpp \
         main.cpp \
-        grpcclient.cpp
+        vehicle_control.cpp \
+        vehicle_patrol.cpp \
+        vehicle_upload.cpp
 
 
 # Default rules for deployment.
 # Default rules for deployment.
 qnx: target.path = /tmp/$${TARGET}/bin
 qnx: target.path = /tmp/$${TARGET}/bin
@@ -72,6 +74,8 @@ HEADERS += \
         VehicleUpload.pb.h \
         VehicleUpload.pb.h \
         VehicleUpload_service.grpc.pb.h \
         VehicleUpload_service.grpc.pb.h \
         VehicleUpload_service.pb.h \
         VehicleUpload_service.pb.h \
-        grpcclient.h
+        vehicle_control.h \
+        vehicle_patrol.h \
+        vehicle_upload.h
 
 
 #before compile in ubuntu20.04 : sudo apt install libyaml-cpp-dev libgrpc++-dev
 #before compile in ubuntu20.04 : sudo apt install libyaml-cpp-dev libgrpc++-dev

+ 5 - 4
src/driver/driver_cloud_grpc_client_BS/driver_cloud_grpc_client_BS.yaml

@@ -3,9 +3,10 @@ upload_port : 10591
 patrol_port : 10592
 patrol_port : 10592
 control_port : 20591
 control_port : 20591
 
 
-uploadinterval : 100 //ms
-patrolinterval : 100
+uploadinterval : 500 //ms
+patrolinterval : 500
 controlinterval : 100
 controlinterval : 100
+uploadmapinterval : 1000
 
 
-ID : 1
-
+id : 1234567890123456789H
+plateNumber : 津A123456

+ 94 - 396
src/driver/driver_cloud_grpc_client_BS/main.cpp

@@ -1,309 +1,78 @@
 #include <QCoreApplication>
 #include <QCoreApplication>
 
 
-#include "grpcclient.h"
-
 #include "ivversion.h"
 #include "ivversion.h"
 
 
-/*
 #include <yaml-cpp/yaml.h>
 #include <yaml-cpp/yaml.h>
-
-#include <QDateTime>
-
-#include <iostream>
-
-#include <vector>
-
-#include <memory>
-
-#include <QMutex>
-
-#include <thread>
-
-#include "modulecomm.h"
-
-#include "cloud.pb.h"
-
-#include <iostream>
-#include <memory>
-#include <string>
-
-#include <grpcpp/grpcpp.h>
-
-#include "uploadmsg.grpc.pb.h"
-
-
-using grpc::Channel;
-using grpc::ClientContext;
-using grpc::Status;
-
-
-void test()
+#include "vehicle_upload.h"
+#include "vehicle_control.h"
+#include "vehicle_patrol.h"
+
+#include <QFile>
+#include <QString>
+#include <QStringList>
+#include <QThread>
+
+std::string gstrserverip =  "139.9.235.66";//"123.57.212.138";
+std::string gstruploadPort = "10591";//"9000";
+std::string gstrpatrolPort = "10592";//"9000";
+std::string gstrcontrolPort = "20591";//"9000";
+std::string gstruploadInterval = "500";
+std::string gstrpatrolInterval = "500";
+std::string gstrcontrolInterval = "100";
+std::string gstruploadMapInterval = "500";
+std::string gstrid = "1234567890123456789H";
+std::string gstrplateNumber = "津A123456";
+
+class mainloop : public QThread
 {
 {
-    std::string target_str = "0.0.0.0:50051";
-
-    auto cargs = grpc::ChannelArguments();
-    cargs.SetMaxReceiveMessageSize(1024 * 1024 * 1024); // 1 GB
-    cargs.SetMaxSendMessageSize(1024 * 1024 * 1024);
-
-    std::shared_ptr<Channel> channel = grpc::CreateCustomChannel(
-             target_str, grpc::InsecureChannelCredentials(),cargs);
-
-    std::unique_ptr<iv::Upload::Stub> stub_ = iv::Upload::NewStub(channel);
-
-
-    iv::UploadRequest request;
-
-
-
-    // Container for the data we expect from the server.
-    iv::UploadReply reply;
-
-    int nid = 0;
-
-    nid = 1;
-
-    while(1)
-    {
-
-
-
-
-        // Context for the client. It could be used to convey extra information to
-        // the server and/or tweak certain RPC behaviors.
-
-
-        ClientContext context ;
-        std::this_thread::sleep_for(std::chrono::milliseconds(100));
-        qint64 time1 = QDateTime::currentMSecsSinceEpoch();
-
-        request.set_id(nid);
-        request.set_ntime(time1);
-        nid++;
-        // The actual RPC.
-        Status status = stub_->upload(&context, request, &reply);
-        if (status.ok()) {
-            std::cout<<nid<<" upload successfully"<<std::endl;
-//            qint64 time2;
-
-//            memcpy(&time2,reply.data().data(),8);
-//            qint64 time3 = QDateTime::currentMSecsSinceEpoch();
-//            std::cout<<"reply data size is "<<reply.data().size()<<std::endl;
-//            std::cout<<" latency is "<<(time2 - time1)<<" 2 is "<<(time3 - time2)<<std::endl;
-//          return reply.message();
-        } else {
-          std::cout << status.error_code() << ": " << status.error_message()
-                    << std::endl;
-          std::cout<<"RPC failed"<<std::endl;
-          std::this_thread::sleep_for(std::chrono::milliseconds(900));
-
-//          delete pcontext;
-//          pcontext = new ClientContext;
-
-//          channel = grpc::CreateCustomChannel(
-//                   target_str, grpc::InsecureChannelCredentials(),cargs);
-
-//          stub_ = iv::Upload::NewStub(channel);
-        }
-    }
-}
-
-std::string gstrserverip =  "0.0.0.0";//"123.57.212.138";
-std::string gstrserverport = "50051";//"9000";
-std::string gstruploadinterval = "1000";
-void * gpa;
-QMutex gMutexMsg;
-std::thread * guploadthread;
-
-
-
-
-std::vector<iv::msgunit> mvectormsgunit;
-
-std::vector<iv::msgunit> mvectorctrlmsgunit;
-
-
-std::string gstrVIN = "AAAAAAAAAAAAAAAAA";
-std::string gstrqueryMD5 = "5d41402abc4b2a76b9719d911017c591";//"5d41402abc4b2a76b9719d911017c592";
-std::string gstrctrlMD5 = "5d41402abc4b2a76b9719d911017c591";
-
-
-
-int gindex = 0;
-
-void ListenData(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
+//    Q_OBJECT
+public:
+    mainloop(VehicleControlClient *pCC,DataExchangeClient *pUC);
+    void run();
+private:
+    VehicleControlClient *pControlClient;
+    DataExchangeClient *pUploadClient;
+};
+
+mainloop::mainloop(VehicleControlClient *pCC,DataExchangeClient *pUC)
 {
 {
-
-    int nsize = mvectormsgunit.size();
-    int i;
-    for(i=0;i<nsize;i++)
-    {
-        if(strncmp(strmemname,mvectormsgunit[i].mstrmsgname,255) == 0)
-        {
-            gMutexMsg.lock();
-            char * strtem = new char[nSize];
-            memcpy(strtem,strdata,nSize);
-            mvectormsgunit[i].mpstrmsgdata.reset(strtem);
-            mvectormsgunit[i].mndatasize = nSize;
-            mvectormsgunit[i].mbRefresh = true;
-            gMutexMsg.unlock();
-            break;
-        }
-    }
+    pControlClient = pCC;
+    pUploadClient = pUC;
 }
 }
 
 
-
-void sharectrlmsg(iv::cloud::cloudmsg * pxmsg)
+void mainloop::run()
 {
 {
-    int i;
-    int nsize = pxmsg->xclouddata_size();
-    for(i=0;i<nsize;i++)
-    {
-        int j;
-        int nquerysize = mvectorctrlmsgunit.size();
-        for(j=0;j<nquerysize;j++)
+    while (1) {
+        msleep(100);
+//        if(pControlClient->get_isNeedMap() == true)
         {
         {
-            if(strncmp(pxmsg->xclouddata(i).msgname().data(), mvectorctrlmsgunit[j].mstrmsgname,255) == 0)
+            std::cout<<"patrol path calculating"<<std::endl;
+            QFile mapfile("/home/samuel/Documents/path1.txt");
+            QVector<org::jeecg::defsDetails::grpc::MapPoint> somePoints;
+            if(mapfile.open(QIODevice::ReadOnly | QIODevice::Text))
             {
             {
- //               qDebug("size is %d ",pxmsg->xclouddata(i).data().size());
-                iv::modulecomm::ModuleSendMsg(mvectorctrlmsgunit[j].mpa,pxmsg->xclouddata(i).data().data(),pxmsg->xclouddata(i).data().size());
-                break;
-            }
-        }
-    }
-}
-
-
-void threadupload()
-{
-    int nsize = mvectormsgunit.size();
-    int i;
-
-    int ninterval = atoi(gstruploadinterval.data());
-    if(ninterval<=0)ninterval = 100;
-
-    QTime xTime;
-    xTime.start();
-    int nlastsend = xTime.elapsed();
-
-    std::string target_str = gstrserverip+":";
-    target_str = target_str + gstrserverport ;//std::to_string()
-    auto cargs = grpc::ChannelArguments();
-    cargs.SetMaxReceiveMessageSize(1024 * 1024 * 1024); // 1 GB
-    cargs.SetMaxSendMessageSize(1024 * 1024 * 1024);
-
-    std::shared_ptr<Channel> channel = grpc::CreateCustomChannel(
-             target_str, grpc::InsecureChannelCredentials(),cargs);
-
-    std::unique_ptr<iv::Upload::Stub> stub_ = iv::Upload::NewStub(channel);
-
-
-    iv::UploadRequest request;
-
-    int nid = 0;
-
-    // Container for the data we expect from the server.
-    iv::UploadReply reply;
-
-    gpr_timespec timespec;
-      timespec.tv_sec = 30;//设置阻塞时间为2秒
-      timespec.tv_nsec = 0;
-      timespec.clock_type = GPR_TIMESPAN;
-
- //   ClientContext context;
-
-
-
-    while(true)
-    {
-        std::this_thread::sleep_for(std::chrono::milliseconds(1));
-        if((xTime.elapsed()-nlastsend)<ninterval)
-        {
-            continue;
-        }
-
-            bool bImportant = false;
-            int nkeeptime = 0;
-            iv::cloud::cloudmsg xmsg;
-            xmsg.set_xtime(QDateTime::currentMSecsSinceEpoch());
-            gMutexMsg.lock();
-            for(i=0;i<nsize;i++)
-            {
-                if(mvectormsgunit[i].mbRefresh)
+                while(!mapfile.atEnd())
                 {
                 {
-                    mvectormsgunit[i].mbRefresh = false;
-                    if(mvectormsgunit[i].mbImportant)
-                    {
-                        bImportant = true;
-                    }
-                    if(mvectormsgunit[i].mnkeeptime > nkeeptime)
-                    {
-                        nkeeptime = mvectormsgunit[i].mnkeeptime;
-                    }
-                    iv::cloud::cloudunit xcloudunit;
-                    xcloudunit.set_msgname(mvectormsgunit[i].mstrmsgname);
-                    xcloudunit.set_data(mvectormsgunit[i].mpstrmsgdata.get(),mvectormsgunit[i].mndatasize);
-                    iv::cloud::cloudunit * pcu = xmsg.add_xclouddata();
-                    pcu->CopyFrom(xcloudunit);
-                }
-
-            }
-            gMutexMsg.unlock();
-
-            int nbytesize = xmsg.ByteSize();
-            char * strbuf = new char[nbytesize];
-            std::shared_ptr<char> pstrbuf;
-            pstrbuf.reset(strbuf);
-            if(xmsg.SerializeToArray(strbuf,nbytesize))
-            {
-
-                ClientContext context ;
-                context.set_deadline(timespec);
-                qint64 time1 = QDateTime::currentMSecsSinceEpoch();
-
-                request.set_id(nid);
-                request.set_ntime(time1);
-                request.set_strquerymd5(gstrqueryMD5);
-                request.set_strctrlmd5(gstrctrlMD5);
-                request.set_strvin(gstrVIN);
-                request.set_xdata(strbuf,nbytesize);
-                request.set_kepptime(nkeeptime);
-                request.set_bimportant(bImportant);
-                nid++;
-                // The actual RPC.
-                Status status = stub_->upload(&context, request, &reply);
-                if (status.ok()) {
-                    std::cout<<nid<<" upload successfully"<<std::endl;
-                    if(reply.nres() == 1)
-                    {
-                        iv::cloud::cloudmsg xmsg;
-                        if(xmsg.ParseFromArray(reply.xdata().data(),reply.xdata().size()))
-                        {
-                            sharectrlmsg(&xmsg);
-                        }
-                    }
-                } else {
-                  std::cout << status.error_code() << ": " << status.error_message()
-                            << std::endl;
-                  std::cout<<"RPC failed"<<std::endl;
-                  if(status.error_code() == 4)
-                  {
-                      std::cout<<" RPC Exceed Time, Create New stub_"<<std::endl;
-                      channel = grpc::CreateCustomChannel(
-                               target_str, grpc::InsecureChannelCredentials(),cargs);
-
-                      stub_ = iv::Upload::NewStub(channel);
-                  }
-                  std::this_thread::sleep_for(std::chrono::milliseconds(900));
-
+                    QByteArray line = mapfile.readLine();
+                    QString map_str(line);
+                    QStringList oneline = map_str.split(",");
+                    org::jeecg::defsDetails::grpc::MapPoint onePoint;
+                    onePoint.set_index(oneline.at(0).toInt());
+                    onePoint.mutable_mappoint()->set_longitude(oneline.at(1).toDouble());
+                    onePoint.mutable_mappoint()->set_latitude(oneline.at(2).toDouble());
+                    onePoint.mutable_mappoint()->set_height(oneline.at(3).toDouble());
+                    somePoints.append(onePoint);
                 }
                 }
-
             }
             }
-            nlastsend = xTime.elapsed();
-
+//            pUploadClient->updatePath(pControlClient->get_patrolPathID(),somePoints);
+            pUploadClient->updatePath("testpath1",somePoints);
+            pUploadClient->uploadPath();
+            pControlClient->set_isNeedMap(false);
+        }
+//        std::cout<<"thread running"<<std::endl;
     }
     }
 }
 }
 
 
-
 void dec_yaml(const char * stryamlpath)
 void dec_yaml(const char * stryamlpath)
 {
 {
 
 
@@ -312,161 +81,90 @@ void dec_yaml(const char * stryamlpath)
     {
     {
         config = YAML::LoadFile(stryamlpath);
         config = YAML::LoadFile(stryamlpath);
     }
     }
-    catch(YAML::BadFile e)
+    catch(...)
     {
     {
-        qDebug("load error.");
+        qDebug("yaml file has some unknown code or load fail.");
         return;
         return;
     }
     }
 
 
-    std::vector<std::string> vecmodulename;
-
-
     if(config["server"])
     if(config["server"])
     {
     {
         gstrserverip = config["server"].as<std::string>();
         gstrserverip = config["server"].as<std::string>();
     }
     }
-    if(config["port"])
+    if(config["uploadPort"])
     {
     {
-        gstrserverport = config["port"].as<std::string>();
+        gstruploadPort = config["uploadPort"].as<std::string>();
     }
     }
-    if(config["uploadinterval"])
+    if(config["patrolPort"])
     {
     {
-        gstruploadinterval = config["uploadinterval"].as<std::string>();
+        gstrpatrolPort = config["patrolPort"].as<std::string>();
     }
     }
-
-    if(config["VIN"])
+    if(config["controlPort"])
     {
     {
-        gstrVIN = config["VIN"].as<std::string>();
+        gstrcontrolPort = config["controlPort"].as<std::string>();
     }
     }
-
-    if(config["queryMD5"])
+    if(config["uploadInterval"])
     {
     {
-        gstrqueryMD5 = config["queryMD5"].as<std::string>();
+        gstruploadInterval = config["uploadInterval"].as<std::string>();
     }
     }
-    else
+    if(config["patrolInterval"])
     {
     {
-        return;
+        gstrpatrolInterval = config["patrolInterval"].as<std::string>();
     }
     }
-
-    if(config["ctrlMD5"])
+    if(config["controlinterval"])
     {
     {
-        gstrctrlMD5 = config["ctrlMD5"].as<std::string>();
+        gstrcontrolInterval = config["controlinterval"].as<std::string>();
     }
     }
-
-
-    std::string strmsgname;
-
-    if(config["uploadmessage"])
-    {
-
-        for(YAML::const_iterator it= config["uploadmessage"].begin(); it != config["uploadmessage"].end();++it)
-        {
-            std::string strtitle = it->first.as<std::string>();
-            std::cout<<strtitle<<std::endl;
-
-            if(config["uploadmessage"][strtitle]["msgname"]&&config["uploadmessage"][strtitle]["buffersize"]&&config["uploadmessage"][strtitle]["buffercount"])
-            {
-                iv::msgunit xmu;
-                strmsgname = config["uploadmessage"][strtitle]["msgname"].as<std::string>();
-                strncpy(xmu.mstrmsgname,strmsgname.data(),255);
-                xmu.mnBufferSize = config["uploadmessage"][strtitle]["buffersize"].as<int>();
-                xmu.mnBufferCount = config["uploadmessage"][strtitle]["buffercount"].as<int>();
-                if(config["uploadmessage"][strtitle]["bimportant"])
-                {
-                   std::string strimportant =    config["uploadmessage"][strtitle]["bimportant"].as<std::string>();
-                   if(strimportant == "true")
-                   {
-                       xmu.mbImportant = true;
-                   }
-                }
-                if(config["uploadmessage"][strtitle]["keeptime"])
-                {
-                   std::string strkeep =    config["uploadmessage"][strtitle]["keeptime"].as<std::string>();
-                   xmu.mnkeeptime = atoi(strkeep.data());
-                }
-                mvectormsgunit.push_back(xmu);
-            }
-        }
-    }
-    else
+    if(config["uploadmapinterval"])
     {
     {
-
-
+        gstruploadMapInterval = config["uploadmapinterval"].as<std::string>();
     }
     }
 
 
-    if(!config["ctrlMD5"])
+    if(config["id"])
     {
     {
-       return;
+        gstrid = config["id"].as<std::string>();
     }
     }
-
-    if(config["ctrlmessage"])
+    if(config["plateNumber"])
     {
     {
-        std::string strnodename = "ctrlmessage";
-        for(YAML::const_iterator it= config[strnodename].begin(); it != config[strnodename].end();++it)
-        {
-            std::string strtitle = it->first.as<std::string>();
-            std::cout<<strtitle<<std::endl;
-
-            if(config[strnodename][strtitle]["msgname"]&&config[strnodename][strtitle]["buffersize"]&&config[strnodename][strtitle]["buffercount"])
-            {
-                iv::msgunit xmu;
-                strmsgname = config[strnodename][strtitle]["msgname"].as<std::string>();
-                strncpy(xmu.mstrmsgname,strmsgname.data(),255);
-                xmu.mnBufferSize = config[strnodename][strtitle]["buffersize"].as<int>();
-                xmu.mnBufferCount = config[strnodename][strtitle]["buffercount"].as<int>();
-                mvectorctrlmsgunit.push_back(xmu);
-            }
-        }
-    }
-    else
-    {
-
+        gstrplateNumber = config["plateNumber"].as<std::string>();
     }
     }
 
 
     return;
     return;
-
 }
 }
 
 
-
-*/
-
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
-    showversion("driver_cloud_grpc_client");
+    showversion("driver_cloud_grpc_client_BS");
     QCoreApplication a(argc, argv);
     QCoreApplication a(argc, argv);
 
 
- //   std::thread * ptest = new std::thread(test);
-
- //   return a.exec();
-
     char stryamlpath[256];
     char stryamlpath[256];
     if(argc<2)
     if(argc<2)
     {
     {
-        snprintf(stryamlpath,255,"driver_cloud_grpc_client.yaml");
-//        strncpy(stryamlpath,abs_ymlpath,255);
+        snprintf(stryamlpath,255,"driver_cloud_grpc_client_BS.yaml");
     }
     }
     else
     else
     {
     {
         strncpy(stryamlpath,argv[1],255);
         strncpy(stryamlpath,argv[1],255);
     }
     }
-//    dec_yaml(stryamlpath);
+    dec_yaml(stryamlpath);
+
+    std::string control_str = gstrserverip+":";
+    control_str = control_str + gstrcontrolPort ;
+
+    std::string patrol_str = gstrserverip+":";
+    patrol_str = patrol_str + gstrpatrolPort;
+
+    std::string upload_str = gstrserverip+":";
+    upload_str = upload_str + gstruploadPort ;
 
 
-    grpcclient * pgrpcclient = new grpcclient(stryamlpath);
-    pgrpcclient->start();
+    VehicleControlClient *vehiclecontrol = new VehicleControlClient(grpc::CreateChannel(control_str, grpc::InsecureChannelCredentials()));
 
 
-//    int i;
-//    for(i=0;i<mvectormsgunit.size();i++)
-//    {
-//        mvectormsgunit[i].mpa = iv::modulecomm::RegisterRecv(mvectormsgunit[i].mstrmsgname,ListenData);
-//    }
+    DataExchangeClient *vehicleupload = new DataExchangeClient(grpc::CreateChannel(upload_str, grpc::InsecureChannelCredentials()));
 
 
-//    for(i=0;i<mvectorctrlmsgunit.size();i++)
-//    {
-//        mvectorctrlmsgunit[i].mpa = iv::modulecomm::RegisterSend(mvectorctrlmsgunit[i].mstrmsgname,mvectorctrlmsgunit[i].mnBufferSize,
-//                                                                 mvectorctrlmsgunit[i].mnBufferCount);
-//    }
+    VehiclePatrolExceptionClient vehiclepatrol(grpc::CreateChannel(patrol_str, grpc::InsecureChannelCredentials()));
 
 
-//    guploadthread = new std::thread(threadupload);
+    mainloop loop(vehiclecontrol,vehicleupload);
+    loop.start();
 
 
     return a.exec();
     return a.exec();
 }
 }

+ 2 - 2
src/driver/driver_cloud_grpc_client_BS/prototocpp.txt

@@ -1,3 +1,3 @@
-protoc -I . --plugin=protoc-gen-grpc=/home/samuel/grpc/cmake/build/grpc_cpp_plugin --grpc_out=. driver_cloud_grpc_client_BS.proto
+protoc -I . --plugin=protoc-gen-grpc=/home/samuel/grpc/cmake/build/grpc_cpp_plugin --grpc_out=. VehicleUpload.proto VehiclePatrol.proto VehicleControl.proto VehicleUpload_service.proto VehiclePatrol_service.proto VehicleControl_service.proto
 
 
-protoc -I . --cpp_out=. driver_cloud_grpc_client_BS.proto 
+protoc -I . --cpp_out=. VehicleUpload.proto VehiclePatrol.proto VehicleControl.proto VehicleUpload_service.proto VehiclePatrol_service.proto VehicleControl_service.proto 

+ 201 - 0
src/driver/driver_cloud_grpc_client_BS/vehicle_control.cpp

@@ -0,0 +1,201 @@
+#include "vehicle_control.h"
+
+extern std::string gstrserverip;
+extern std::string gstrcontrolPort;
+extern std::string gstrcontrolInterval;
+extern std::string gstruploadMapInterval;
+extern std::string gstrid;
+extern std::string gstrplateNumber;
+
+using org::jeecg::defsControl::grpc::Empty; ///< other message
+using org::jeecg::defsControl::grpc::GPSPoint;
+using org::jeecg::defsControl::grpc::MapPoint;
+
+using org::jeecg::defsControl::grpc::CtrlMode; ///< other enum
+using org::jeecg::defsControl::grpc::ShiftStatus;
+
+VehicleControlClient::VehicleControlClient(std::shared_ptr<Channel> channel)
+{
+    stub_ = VehicleControl::NewStub(channel);
+
+    controlTimer = new QTimer();
+    connect(controlTimer,SIGNAL(timeout()),this,SLOT(controlTimeout()));
+//    controlTimer->start(std::atoi(gstrcontrolInterval.c_str()));
+
+    uploadMapTimer = new QTimer();
+    connect(uploadMapTimer,SIGNAL(timeout()),this,SLOT(uploadMapTimeout()));
+    uploadMapTimer->start(std::atoi(gstruploadMapInterval.c_str()));
+}
+
+VehicleControlClient::~VehicleControlClient(void)
+{
+    delete controlTimer;
+    delete uploadMapTimer;
+}
+
+std::string VehicleControlClient::vehicleControl(void)
+{
+    // Data we are sending to the server.
+    Empty request;
+    request.set_id(gstrid);
+
+    // Container for the data we expect from the server.
+    ControlReply reply;
+
+    // Context for the client. It could be used to convey extra information to
+    // the server and/or tweak certain RPC behaviors.
+    ClientContext context;
+
+    // The actual RPC.
+    Status status = stub_ -> vehicleControl(&context,request,&reply);
+
+    // Act upon its status.
+    if (status.ok()) {
+        if(reply.id() == gstrid)
+        {
+            shiftCMD = reply.shiftcmd();
+            steeringWheelAngleCMD = reply.steeringwheelanglecmd();
+            throttleCMD = reply.throttlecmd();
+            brakeCMD = reply.brakecmd();
+        }
+        return "vehicleControl RPC successed";
+    } else {
+        std::cout << status.error_code() << ": " << status.error_message()
+                  << std::endl;
+        return "vehicleControl RPC failed";
+    }
+}
+
+std::string VehicleControlClient::uploadMap(void)
+{
+    // Data we are sending to the server.
+    Empty request;
+    request.set_id(gstrid);
+
+    // Container for the data we expect from the server.
+    UploadMapReply reply;
+
+    // Context for the client. It could be used to convey extra information to
+    // the server and/or tweak certain RPC behaviors.
+    ClientContext context;
+
+    // The actual RPC.
+    Status status = stub_ -> UploadMap(&context,request,&reply);
+
+    // Act upon its status.
+    if (status.ok()) {
+        if(reply.id() == gstrid)
+        {
+            std::cout<<reply.id()<<std::endl;
+            isNeedMap = false;
+            patrolPathID = "noPath";
+            POIPoints.clear();
+
+            isNeedMap = reply.isneedmap();
+            std::cout<<reply.isneedmap()<<std::endl;
+            patrolPathID = reply.patrolpathid();
+            std::cout<<reply.patrolpathid()<<std::endl;
+            for(int i = 0;i < reply.mappoints_size();i++)
+            {
+                POIPoints.append(reply.mappoints(i));
+                std::cout<<reply.mappoints(i).index()<<std::endl;
+            }
+        }
+        return "UploadMap RPC successed";
+    } else {
+        std::cout << status.error_code() << ": " << status.error_message()
+                  << std::endl;
+        return "UploadMap RPC failed";
+    }
+}
+
+std::string VehicleControlClient::changeCtrlMode(void)
+{
+    // Data we are sending to the server.
+    Empty request;
+    request.set_id(gstrid);
+
+    // Container for the data we expect from the server.
+    CtrlModeReply reply;
+
+    // Context for the client. It could be used to convey extra information to
+    // the server and/or tweastd::cout<<"shift:"<<shiftCMD<<std::endl;k certain RPC behaviors.
+    ClientContext context;
+
+    // The actual RPC.
+    Status status = stub_ -> changeCtrlMode(&context,request,&reply);
+
+    // Act upon its status.
+    if (status.ok()) {
+        if(reply.id() == gstrid)
+        {
+            modeCMD = reply.modecmd();
+        }
+        return "changeCtrlMode RPC successed";
+    } else {
+        std::cout << status.error_code() << ": " << status.error_message()
+                  << std::endl;
+        return "changeCtrlMode RPC failed";
+    }
+}
+
+void VehicleControlClient::updateControlData(void)
+{
+    std::cout<<"shift:"<<shiftCMD<<std::endl;
+    std::cout<<"steeringWheelAngle:"<<steeringWheelAngleCMD<<std::endl;
+    std::cout<<"throttle:"<<throttleCMD<<std::endl;
+    std::cout<<"brake:"<<brakeCMD<<std::endl;
+}
+
+void VehicleControlClient::updateMapPOIData(void)
+{
+    std::cout<<"isNeedMap:"<<isNeedMap<<std::endl;
+    std::cout<<"patrolPathID:"<<patrolPathID<<std::endl;
+}
+
+void VehicleControlClient::updateCtrolMode(void)
+{
+    std::cout<<"modeCMD:"<<modeCMD<<std::endl;
+}
+
+void VehicleControlClient::controlTimeout(void)
+{
+    std::string reply = changeCtrlMode();
+    std::cout<< reply <<std::endl;
+    updateCtrolMode();
+
+    reply = vehicleControl();
+    std::cout<< reply <<std::endl;
+    if(modeCMD == CtrlMode::CMD_REMOTE)
+    {
+        updateControlData();
+    }
+}
+
+void VehicleControlClient::uploadMapTimeout(void)
+{
+    if(isNeedMap == false)
+    {
+        std::string reply = uploadMap();
+        std::cout<< reply <<std::endl;
+        if(isNeedMap == true)
+        {
+            updateMapPOIData();
+        }
+    }
+}
+
+std::string VehicleControlClient::get_patrolPathID(void)
+{
+    return patrolPathID;
+}
+
+bool VehicleControlClient::get_isNeedMap(void)
+{
+    return isNeedMap;
+}
+
+void VehicleControlClient::set_isNeedMap(bool needMapStatus)
+{
+    isNeedMap = needMapStatus;
+}

+ 67 - 0
src/driver/driver_cloud_grpc_client_BS/vehicle_control.h

@@ -0,0 +1,67 @@
+#ifndef VEHICLE_CONTROL_H
+#define VEHICLE_CONTROL_H
+
+#include <QObject>
+#include <QTimer>
+#include <QVector>
+
+#include <iostream>
+#include <memory>
+#include <string>
+
+#include <grpcpp/grpcpp.h>
+
+#include "VehicleControl_service.grpc.pb.h"
+#include "VehicleControl.grpc.pb.h"
+
+using grpc::Channel;
+using grpc::ClientContext;
+using grpc::Status;
+
+using org::jeecg::defsControl::grpc::VehicleControl; ///< service name
+
+using org::jeecg::defsControl::grpc::ControlReply; ///< rpc fuction parameter and return
+using org::jeecg::defsControl::grpc::UploadMapReply;
+using org::jeecg::defsControl::grpc::CtrlModeReply;
+
+class VehicleControlClient : public QObject{
+    Q_OBJECT
+
+public:
+    VehicleControlClient(std::shared_ptr<Channel> channel);
+
+    ~VehicleControlClient(void);
+
+    std::string vehicleControl(void);
+    std::string uploadMap(void);
+    std::string changeCtrlMode(void);
+    void updateControlData(void);
+    void updateMapPOIData(void);
+    void updateCtrolMode(void);
+    std::string get_patrolPathID(void);
+    bool get_isNeedMap(void);
+    void set_isNeedMap(bool needMapStatus);
+
+private:
+    std::unique_ptr<VehicleControl::Stub> stub_;
+
+    org::jeecg::defsControl::grpc::ShiftStatus shiftCMD;
+    double steeringWheelAngleCMD;
+    double throttleCMD;
+    double brakeCMD;
+
+    bool isNeedMap = false;
+    std::string patrolPathID;
+    QVector<org::jeecg::defsControl::grpc::MapPoint> POIPoints;
+
+    org::jeecg::defsControl::grpc::CtrlMode modeCMD;
+
+    QTimer *controlTimer;
+    QTimer *uploadMapTimer;
+
+private slots:
+    void controlTimeout(void);
+    void uploadMapTimeout(void);
+};
+
+#endif // VEHICLE_CONTROL_H

+ 131 - 0
src/driver/driver_cloud_grpc_client_BS/vehicle_patrol.cpp

@@ -0,0 +1,131 @@
+#include "vehicle_patrol.h"
+#include <QDateTime>
+#include <QFile>
+
+extern std::string gstrserverip;
+extern std::string gstrpatrolPort;
+extern std::string gstrpatrolInterval;
+extern std::string gstrid;
+extern std::string gstrplateNumber;
+
+using org::jeecg::defsPatrol::grpc::Empty;
+using org::jeecg::defsPatrol::grpc::GPSPoint;
+
+VehiclePatrolExceptionClient::VehiclePatrolExceptionClient(std::shared_ptr<Channel> channel)
+{
+    stub_ = VehiclePatrolException::NewStub(channel);
+
+    patrolTimer = new QTimer();
+    connect(patrolTimer,SIGNAL(timeout()),this,SLOT(patrolTimeout()));
+//    patrolTimer->start(std::atoi(gstrpatrolInterval.c_str()));
+}
+
+VehiclePatrolExceptionClient::~VehiclePatrolExceptionClient(void)
+{
+    delete patrolTimer;
+}
+
+std::string VehiclePatrolExceptionClient::uploadVehiclePatrolInfo(void)
+{
+    // Data we are sending to the server.
+    PatrolRequest request;
+    request.set_id(id);
+    request.set_istvr(isTVR);
+    request.set_violationstatus(violationStatus);
+    request.set_vehiclelicensenumber(vehicleLicenseNumber);
+    request.set_violationimage(violationImage.data(),violationImage.size());
+    request.mutable_violationposition()->CopyFrom(violationPosition);
+
+    request.set_isfsm(isFSM);
+    request.set_firestatus(fireStatus);
+    request.set_fireimage(fireImage.data(),fireImage.size());
+    request.set_firetime(fireTime);
+    request.mutable_fireposition()->CopyFrom(firePosition);
+
+    request.set_istsgm(isTSGM);
+    request.set_gatestatus(gateStatus);
+    request.set_gateimage(gateImage.data(),gateImage.size());
+    request.set_gatetime(gateTime);
+    request.mutable_gateposition()->CopyFrom(gatePosition);
+
+    request.set_platenumber(plateNumber);
+
+    // Container for the data we expect from the server.
+    Empty reply;
+
+    // Context for the client. It could be used to convey extra information to
+    // the server and/or tweak certain RPC behaviors.
+    ClientContext context;
+
+    // The actual RPC.
+    Status status = stub_ -> uploadVehiclePatrolInfo(&context,request,&reply);
+
+    // Act upon its status.
+    if (status.ok()) {
+
+        return "uploadVehiclePatrolInfo RPC successed";
+    } else {
+        std::cout << status.error_code() << ": " << status.error_message()
+                  << std::endl;
+        return "uploadVehiclePatrolInfo RPC failed";
+    }
+}
+
+void VehiclePatrolExceptionClient::updatePatrolData(void)
+{
+    id = gstrid;
+    isTVR = true;
+    violationStatus = 2;
+    vehicleLicenseNumber = "津B654321";
+
+//    QFile xFile;
+//    xFile.setFileName("/home/samuel/Pictures/123.jpg");
+//    if(xFile.open(QIODevice::ReadOnly))
+//    {
+//        violationImage = xFile.readAll();
+//    }
+//    xFile.close();
+
+    violationTime = QDateTime::currentMSecsSinceEpoch();
+    violationPosition.set_height(0.1);
+    violationPosition.set_latitude(39.0666552);
+    violationPosition.set_longitude(117.3542963);
+
+    isFSM = true;
+    fireStatus = 1;
+
+//    xFile.setFileName("/home/samuel/Pictures/123.jpg");
+//    if(xFile.open(QIODevice::ReadOnly))
+//    {
+//        fireImage = xFile.readAll();
+//    }
+//    xFile.close();
+
+    fireTime = QDateTime::currentMSecsSinceEpoch();
+    firePosition.set_height(0.1);
+    firePosition.set_latitude(39.0667552);
+    firePosition.set_longitude(117.3542963);
+
+    isTSGM = true;
+    gateStatus = 2;
+
+//    xFile.setFileName("/home/samuel/Pictures/123.jpg");
+//    if(xFile.open(QIODevice::ReadOnly))
+//    {
+//        gateImage = xFile.readAll();
+//    }
+//    xFile.close();
+
+    gateTime = QDateTime::currentMSecsSinceEpoch();
+    gatePosition.set_height(0.1);
+    gatePosition.set_latitude(39.0665552);
+    gatePosition.set_longitude(117.3542963);
+
+    plateNumber = gstrplateNumber;
+}
+
+void VehiclePatrolExceptionClient::patrolTimeout(void)
+{
+    updatePatrolData();
+    uploadVehiclePatrolInfo();
+}

+ 68 - 0
src/driver/driver_cloud_grpc_client_BS/vehicle_patrol.h

@@ -0,0 +1,68 @@
+#ifndef VEHICLE_PATROL_H
+#define VEHICLE_PATROL_H
+
+#include <QObject>
+#include <QTimer>
+#include <QVector>
+
+#include <iostream>
+#include <memory>
+#include <string>
+
+#include <grpcpp/grpcpp.h>
+
+#include "VehiclePatrol_service.grpc.pb.h"
+#include "VehiclePatrol.grpc.pb.h"
+
+using grpc::Channel;
+using grpc::ClientContext;
+using grpc::Status;
+
+using org::jeecg::defsPatrol::grpc::VehiclePatrolException; ///< service name
+
+using org::jeecg::defsPatrol::grpc::PatrolRequest;
+
+class VehiclePatrolExceptionClient : public QObject{
+    Q_OBJECT
+
+public:
+    VehiclePatrolExceptionClient(std::shared_ptr<Channel> channel);
+
+    ~VehiclePatrolExceptionClient(void);
+
+    std::string uploadVehiclePatrolInfo(void);
+    void updatePatrolData(void);
+
+private:
+    std::unique_ptr<VehiclePatrolException::Stub> stub_;
+
+    std::string id;
+
+    bool isTVR; //Traffic Violation Recognition
+    int32_t violationStatus; //0 no violation 1 overspeed 2 illegal parking 3 direction wrong 4 run the red light
+    std::string vehicleLicenseNumber;
+    QByteArray violationImage;
+    uint64_t violationTime; //time when get violationImage
+    org::jeecg::defsPatrol::grpc::GPSPoint violationPosition; //positon when get violationImage
+
+    bool isFSM; //Fire and Smoke Monitor
+    int32_t fireStatus; //0 no fire 1 has fire
+    QByteArray fireImage;
+    uint64_t fireTime; //time when get fireImage
+    org::jeecg::defsPatrol::grpc::GPSPoint firePosition; //positon when get fireImage
+
+    bool isTSGM; //Turn Stile Gate Monitor
+    int32_t gateStatus; //0 no gate 1 gate close 2 gate open
+    QByteArray gateImage;
+    uint64_t gateTime; //time when get gateImage
+    org::jeecg::defsPatrol::grpc::GPSPoint gatePosition; //positon when get gateImage
+
+    std::string plateNumber;
+
+    QTimer *patrolTimer;
+
+private slots:
+    void patrolTimeout(void);
+};
+
+#endif // VEHICLE_PATROL_H

+ 207 - 0
src/driver/driver_cloud_grpc_client_BS/vehicle_upload.cpp

@@ -0,0 +1,207 @@
+#include "vehicle_upload.h"
+#include <QDateTime>
+#include <QFile>
+
+extern std::string gstrserverip;
+extern std::string gstruploadPort;
+extern std::string gstruploadInterval;
+extern std::string gstrid;
+extern std::string gstrplateNumber;
+
+
+using org::jeecg::defsDetails::grpc::Empty; ///< other message
+using org::jeecg::defsDetails::grpc::GPSPoint;
+using org::jeecg::defsDetails::grpc::MapPoint;
+
+using org::jeecg::defsDetails::grpc::ShiftStatus; ///< other enum
+using org::jeecg::defsDetails::grpc::CtrlMode;
+
+DataExchangeClient::DataExchangeClient(std::shared_ptr<Channel> channel)
+{
+    stub_ = DataExchange::NewStub(channel);
+
+    uploadTimer = new QTimer();
+    connect(uploadTimer,SIGNAL(timeout()),this,SLOT(uploadTimeout()));
+    uploadTimer->start(std::atoi(gstruploadInterval.c_str()));
+}
+
+DataExchangeClient::~DataExchangeClient(void)
+{
+    delete uploadTimer;
+}
+
+std::string DataExchangeClient::uploadVehicleInfo(void)
+{
+
+    // Data we are sending to the server.
+    UplinkRequest request;
+    request.set_id(id);
+    request.set_timestamp(timeStamp);
+    request.set_soc(SOC);
+    request.set_statusfeedback(statusFeedback);
+    request.set_mileage(mileage);
+    request.set_speed(speed);
+    request.set_shiftfeedback(shiftFeedback);
+    request.set_steeringwheelanglefeedback(steeringWheelAngleFeedback);
+    request.set_throttlefeedback(throttleFeedback);
+    request.set_brakefeedback(brakeFeedback);
+    request.set_gpsrtkstatus(GPSRTKStatus);
+    request.mutable_positionfeedback()->CopyFrom(positionFeedback);
+    request.set_pitch(pitch);
+    request.set_roll(roll);
+    request.set_heading(heading);
+    request.set_cameraimagefront(cameraImageFront.data(),cameraImageFront.size());
+    request.set_cameraimagerear(cameraImageRear.data(),cameraImageRear.size());
+    request.set_cameraimageleft(cameraImageLeft.data(),cameraImageLeft.size());
+    request.set_cameraimageright(cameraImageRight.data(),cameraImageRight.size());
+    request.set_sensorstatusgpsimu(sensorStatusGPSIMU);
+    request.set_sensorstatuslidar(sensorStatusLidar);
+    request.set_sensorstatusradar(sensorStatusRadar);
+    request.set_sensorstatuscamfront(sensorStatusCamFront);
+    request.set_sensorstatuscamrear(sensorStatusCamRear);
+    request.set_sensorstatuscamleft(sensorStatusCamLeft);
+    request.set_sensorstatuscamright(sensorStatusCamRight);
+    request.set_isarrived(isArrived);
+    request.set_platenumber(plateNumber);
+    request.set_modefeedback(modeFeedback);
+
+    // Container for the data we expect from the server.
+    ResponseMessage reply;
+
+    // Context for the client. It could be used to convey extra information to
+    // the server and/or tweak certain RPC behaviors.
+    ClientContext context;
+
+    // The actual RPC.
+    Status status = stub_ -> uploadVehicleInfo(&context, request, &reply);
+
+    // Act upon its status.
+    if (status.ok()) {
+        destinationPosition.CopyFrom(reply.destinationposition());
+//        std::cout<<"lat:"<<destinationPosition.latitude()<<"lon:"<<destinationPosition.longitude()<<"height:"<<destinationPosition.height()<<std::endl;
+        return "uploadVehicleInfo RPC successed";
+    } else {
+        std::cout << status.error_code() << ": " << status.error_message()
+                  << std::endl;
+        return "uploadVehicleInfo RPC failed";
+    }
+}
+
+std::string DataExchangeClient::uploadPath(void)
+{
+    // Data we are sending to the server.
+    UploadPathRequest request;
+    request.set_id(id);
+    request.set_patrolpathid(patrolPathID);
+    for(int i = 0;i < pathPoints.size();i++)
+    {
+        request.add_pathpoints();
+        request.mutable_pathpoints(i)->operator =(pathPoints.at(i));
+    }
+
+    // Container for the data we expect from the server.
+    Empty reply;
+
+    // Context for the client. It could be used to convey extra information to
+    // the server and/or tweak certain RPC behaviors.
+    ClientContext context;
+
+    // The actual RPC.
+    Status status = stub_ -> uploadPath(&context,request,&reply);
+
+    // Act upon its status.
+    if (status.ok()) {
+        if(reply.id() == gstrid)
+        {
+            std::cout<<"Path uploaded by car id:"<<reply.id()<<std::endl;
+        }
+        return "uploadPath RPC successed";
+    } else {
+        std::cout << status.error_code() << ": " << status.error_message()
+                  << std::endl;
+        return "uploadPath RPC failed";
+    }
+}
+
+void DataExchangeClient::updateData(void)
+{
+    id = gstrid;
+    timeStamp = QDateTime::currentMSecsSinceEpoch();
+    SOC = 86.5;
+    statusFeedback = VehicleStatus::STATUS_REMOTE;
+    mileage = 123.45; // kilometer
+    speed = 0.1; // m/s
+    shiftFeedback = ShiftStatus::SHIFT_DRIVE;
+    steeringWheelAngleFeedback = 1.23; //+/-540 degree
+    throttleFeedback = 0.12;
+    brakeFeedback = 0.34;
+    GPSRTKStatus = 6; //GPS-RTK status 0-6 6 is best
+    positionFeedback.set_latitude(39.0666552);
+    positionFeedback.set_longitude(117.3540963);
+    positionFeedback.set_height(0.84);
+    pitch = 0.03;
+    roll = 0.02;
+    heading = 198.4;
+
+//    QFile xFile;
+//    xFile.setFileName("/home/samuel/Pictures/123.jpg");
+//    if(xFile.open(QIODevice::ReadOnly))
+//    {
+//        cameraImageFront = xFile.readAll();
+//    }
+//    xFile.close();
+
+//    xFile.setFileName("/home/samuel/Pictures/123.jpg");
+//    if(xFile.open(QIODevice::ReadOnly))
+//    {
+//        cameraImageRear = xFile.readAll();
+//    }
+//    xFile.close();
+
+//    xFile.setFileName("/home/samuel/Pictures/123.jpg");
+//    if(xFile.open(QIODevice::ReadOnly))
+//    {
+//        cameraImageLeft = xFile.readAll();
+//    }
+//    xFile.close();
+
+//    xFile.setFileName("/home/samuel/Pictures/123.jpg");
+//    if(xFile.open(QIODevice::ReadOnly))
+//    {
+//        cameraImageRight = xFile.readAll();
+//    }
+//    xFile.close();
+
+    sensorStatusGPSIMU = false; //0 GPS-IMU ok 1 GPS-IMU error
+    sensorStatusLidar = false;
+    sensorStatusRadar = false;
+    sensorStatusCamFront = false;
+    sensorStatusCamRear = false;
+    sensorStatusCamLeft = false;
+    sensorStatusCamRight = false;
+
+    isArrived = 0; //0 no destination 1 not arrived 2 arrived
+
+    plateNumber = gstrplateNumber;
+
+    modeFeedback = CtrlMode::CMD_REMOTE; //mode Feedback
+}
+
+void DataExchangeClient::updatePath(std::string pathID, QVector<MapPoint> points)
+{
+    id = gstrid;
+    patrolPathID = pathID;
+    pathPoints.clear();
+    for(int i = 0;i < points.size();i++)
+    {
+        pathPoints.append(points.value(i));
+//        std::cout<<pathPoints.at(i).index()<<std::endl;
+    }
+}
+
+void DataExchangeClient::uploadTimeout(void)
+{
+    updateData();
+    std::string reply = uploadVehicleInfo();
+    std::cout<< reply <<std::endl;
+}

+ 91 - 0
src/driver/driver_cloud_grpc_client_BS/vehicle_upload.h

@@ -0,0 +1,91 @@
+#ifndef VEHICLE_UPLOAD_H
+#define VEHICLE_UPLOAD_H
+
+#include <QObject>
+#include <QTimer>
+#include <QVector>
+
+#include <iostream>
+#include <memory>
+#include <string>
+
+#include <grpcpp/grpcpp.h>
+
+#include "VehicleUpload_service.grpc.pb.h"
+#include "VehicleUpload.grpc.pb.h"
+
+using grpc::Channel;
+using grpc::ClientContext;
+using grpc::Status;
+
+using org::jeecg::defsDetails::grpc::DataExchange; ///< service name
+
+using org::jeecg::defsDetails::grpc::UplinkRequest; ///< rpc fuction parameter and return
+using org::jeecg::defsDetails::grpc::ResponseMessage;
+using org::jeecg::defsDetails::grpc::UploadPathRequest;
+
+using org::jeecg::defsDetails::grpc::VehicleStatus; ///< other enum
+
+class DataExchangeClient : public QObject{
+    Q_OBJECT
+
+public:
+    DataExchangeClient(std::shared_ptr<Channel> channel);
+
+    ~DataExchangeClient(void);
+
+    std::string uploadVehicleInfo(void);
+    std::string uploadPath(void);
+    void updateData(void);
+    void updatePath(std::string pathID,QVector<org::jeecg::defsDetails::grpc::MapPoint> points);
+
+private:
+    std::unique_ptr<DataExchange::Stub> stub_;
+
+    std::string id;
+    uint64_t timeStamp;
+    double SOC; //0.0-100.0%
+    VehicleStatus statusFeedback = VehicleStatus::STATUS_EMERGENCY_STOP;
+    double mileage; // kilometer
+    double speed; // m/s
+    org::jeecg::defsDetails::grpc::ShiftStatus shiftFeedback;
+    double steeringWheelAngleFeedback; //+/-540 degree
+    double throttleFeedback;
+    double brakeFeedback;
+    int32_t GPSRTKStatus; //GPS-RTK status 0-6 6 is best
+    org::jeecg::defsDetails::grpc::GPSPoint positionFeedback;
+    double pitch;
+    double roll;
+    double heading;
+
+    QByteArray cameraImageFront;
+    QByteArray cameraImageRear;
+    QByteArray cameraImageLeft;
+    QByteArray cameraImageRight;
+
+    bool sensorStatusGPSIMU; //0 GPS-IMU ok 1 GPS-IMU error
+    bool sensorStatusLidar;
+    bool sensorStatusRadar;
+    bool sensorStatusCamFront;
+    bool sensorStatusCamRear;
+    bool sensorStatusCamLeft;
+    bool sensorStatusCamRight;
+
+    int32_t isArrived; //0 no destination 1 not arrived 2 arrived
+
+    std::string plateNumber;
+
+    org::jeecg::defsDetails::grpc::CtrlMode modeFeedback = org::jeecg::defsDetails::grpc::CtrlMode::CMD_EMERGENCY_STOP; //mode Feedback
+
+    org::jeecg::defsDetails::grpc::GPSPoint destinationPosition;
+
+    std::string patrolPathID;
+    QVector<org::jeecg::defsDetails::grpc::MapPoint> pathPoints;
+
+    QTimer *uploadTimer;
+
+private slots:
+    void uploadTimeout(void);
+};
+
+#endif // VEHICLE_UPLOAD_H

+ 2 - 1
src/driver/driver_map_xodrload/globalplan.cpp

@@ -1442,7 +1442,8 @@ int GetLaneOriTotal(Road * pRoad, int nlane,double s,int & nori, int & ntotal,do
                         break;
                         break;
                     }
                     }
                 }
                 }
-                fSpeed = pLSpeed->GetMax();
+                if(pLSpeed->GetS()<=(s-pLS->GetS()))fSpeed = pLSpeed->GetMax();
+
             }
             }
         }
         }
         if(nlane<0)
         if(nlane<0)

+ 104 - 0
src/tool/map_lanetoxodr/adcxodrviewer.pro

@@ -0,0 +1,104 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2019-08-23T15:28:22
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = adcxodrviewer
+TEMPLATE = app
+
+CONFIG+= c++11
+
+DEFINES += XODRViewer
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which has been marked as deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+QMAKE_LFLAGS += -no-pie
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+
+SOURCES += \
+    ivxodrtool.cpp \
+        main.cpp \
+    roaddigit.cpp \
+    myview.cpp \
+    OpenDrive/Junction.cpp \
+    OpenDrive/Lane.cpp \
+    OpenDrive/ObjectSignal.cpp \
+    OpenDrive/OpenDrive.cpp \
+    OpenDrive/OpenDriveXmlParser.cpp \
+    OpenDrive/OpenDriveXmlWriter.cpp \
+    OpenDrive/OtherStructures.cpp \
+    OpenDrive/Road.cpp \
+    OpenDrive/RoadGeometry.cpp \
+    TinyXML/tinystr.cpp \
+    TinyXML/tinyxml.cpp \
+    TinyXML/tinyxmlerror.cpp \
+    TinyXML/tinyxmlparser.cpp \
+    fresnl.cpp \
+    polevl.c \
+    const.cpp \
+    gnss_coordinate_convert.cpp \
+    xodrfunc.cpp \
+    xodrscenfunc.cpp \
+    xvmainwindow.cpp
+
+HEADERS += \
+    ivxodrtool.h \
+    roaddigit.h \
+    myview.h \
+    gps_type.h \
+    linedata.h \
+    OpenDrive/Junction.h \
+    OpenDrive/Lane.h \
+    OpenDrive/ObjectSignal.h \
+    OpenDrive/OpenDrive.h \
+    OpenDrive/OpenDriveXmlParser.h \
+    OpenDrive/OpenDriveXmlWriter.h \
+    OpenDrive/OtherStructures.h \
+    OpenDrive/Road.h \
+    OpenDrive/RoadGeometry.h \
+    TinyXML/tinystr.h \
+    TinyXML/tinyxml.h \
+    gnss_coordinate_convert.h \
+    xodrfunc.h \
+    xodrscenfunc.h \
+    xvmainwindow.h
+
+FORMS += \
+    xvmainwindow.ui
+
+
+
+
+
+
+
+QMAKE_CXXFLAGS +=  -g
+
+
+
+
+
+
+DISTFILES += \
+
+
+unix:INCLUDEPATH += /usr/include/eigen3
+win32:INCLUDEPATH += D:\File\soft\eigen
+
+
+RESOURCES += \
+    opendrive.qrc

+ 120 - 0
src/tool/map_lanetoxodr/adcxodrviewer_android.pro

@@ -0,0 +1,120 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2019-08-23T15:28:22
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+QT += androidextras
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = adcxodrviewer
+TEMPLATE = app
+
+CONFIG+= c++11
+
+DEFINES += Android
+
+DEFINES += XODRViewer
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which has been marked as deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+QMAKE_LFLAGS += -no-pie
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+
+SOURCES += \
+    ivxodrtool.cpp \
+        main.cpp \
+    roaddigit.cpp \
+    myview.cpp \
+    OpenDrive/Junction.cpp \
+    OpenDrive/Lane.cpp \
+    OpenDrive/ObjectSignal.cpp \
+    OpenDrive/OpenDrive.cpp \
+    OpenDrive/OpenDriveXmlParser.cpp \
+    OpenDrive/OpenDriveXmlWriter.cpp \
+    OpenDrive/OtherStructures.cpp \
+    OpenDrive/Road.cpp \
+    OpenDrive/RoadGeometry.cpp \
+    TinyXML/tinystr.cpp \
+    TinyXML/tinyxml.cpp \
+    TinyXML/tinyxmlerror.cpp \
+    TinyXML/tinyxmlparser.cpp \
+    fresnl.cpp \
+    polevl.c \
+    const.cpp \
+    gnss_coordinate_convert.cpp \
+    xodrfunc.cpp \
+    xodrscenfunc.cpp \
+    xvmainwindow.cpp
+
+HEADERS += \
+    ivxodrtool.h \
+    roaddigit.h \
+    myview.h \
+    gps_type.h \
+    linedata.h \
+    OpenDrive/Junction.h \
+    OpenDrive/Lane.h \
+    OpenDrive/ObjectSignal.h \
+    OpenDrive/OpenDrive.h \
+    OpenDrive/OpenDriveXmlParser.h \
+    OpenDrive/OpenDriveXmlWriter.h \
+    OpenDrive/OtherStructures.h \
+    OpenDrive/Road.h \
+    OpenDrive/RoadGeometry.h \
+    TinyXML/tinystr.h \
+    TinyXML/tinyxml.h \
+    gnss_coordinate_convert.h \
+    xodrfunc.h \
+    xodrscenfunc.h \
+    xvmainwindow.h
+
+FORMS += \
+    xvmainwindow.ui
+
+
+
+
+
+
+
+QMAKE_CXXFLAGS +=  -g
+
+
+
+
+
+
+DISTFILES += \ \
+    android/AndroidManifest.xml \
+    android/build.gradle \
+    android/gradle/wrapper/gradle-wrapper.jar \
+    android/gradle/wrapper/gradle-wrapper.properties \
+    android/gradlew \
+    android/gradlew.bat \
+    android/res/values/libs.xml
+
+
+unix:INCLUDEPATH += /usr/include/eigen3
+win32:INCLUDEPATH += D:\File\soft\eigen
+
+
+RESOURCES += \
+    opendrive.qrc
+
+contains(ANDROID_TARGET_ARCH,arm64-v8a) {
+    ANDROID_PACKAGE_SOURCE_DIR = \
+        $$PWD/android
+}

+ 270 - 0
src/tool/map_lanetoxodr/dialogroadmerge.cpp

@@ -0,0 +1,270 @@
+#include "dialogroadmerge.h"
+#include "ui_dialogroadmerge.h"
+
+#include "xodrfunc.h"
+
+#include <math.h>
+
+DialogRoadMerge::DialogRoadMerge(OpenDrive * pxodr,QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogRoadMerge)
+{
+    ui->setupUi(this);
+
+    mpxodr = pxodr;
+}
+
+DialogRoadMerge::~DialogRoadMerge()
+{
+    delete ui;
+}
+
+
+int DialogRoadMerge::MergeGeometry(Road *pRoad1, Road *pRoad2)
+{
+    double froad1len = pRoad1->GetRoadLength();
+    int nroad2geocount = pRoad2->GetGeometryBlockCount();
+    int i;
+    GeometryBlock * pnewgb;
+    for(i=0;i<nroad2geocount;i++)
+    {
+
+
+        GeometryBlock * pgb = pRoad2->GetGeometryBlock(i);
+
+        RoadGeometry * pgeb = pgb->GetGeometryAt(0);
+        if(pgeb == 0)
+        {
+            continue;
+        }
+        pRoad1->AddGeometryBlock();
+        pnewgb = pRoad1->GetLastAddedGeometryBlock();
+        switch (pgeb->GetGeomType()) {
+        case 0:
+            pnewgb->AddGeometryLine(pgeb->GetS() + froad1len,pgeb->GetX(),pgeb->GetY(),pgeb->GetHdg(),pgeb->GetLength());
+            break;
+        case 1:
+        {
+            GeometrySpiral * pspiral = (GeometrySpiral *)pgeb;
+            pnewgb->AddGeometrySpiral(pgeb->GetS() + froad1len,pgeb->GetX(),pgeb->GetY(),pgeb->GetHdg(),pgeb->GetLength(),
+                                      pspiral->GetCurvatureStart(),pspiral->GetCurvatureEnd());
+        }
+            break;
+        case 2:
+        {
+            GeometryArc * parc = (GeometryArc *)pgeb;
+            pnewgb->AddGeometryArc(pgeb->GetS() + froad1len,parc->GetX(),parc->GetY(),
+                                   parc->GetHdg(),parc->GetLength(),parc->GetCurvature());
+        }
+            break;
+        case 4:
+        {
+            GeometryParamPoly3 * pparmp3d = (GeometryParamPoly3 *)pgeb;
+            pnewgb->AddGeometryParamPoly3(pgeb->GetS() + froad1len,pgeb->GetX(),pgeb->GetY(),
+                                          pgeb->GetHdg(),pgeb->GetLength(),pparmp3d->GetuA(),pparmp3d->GetuB(),
+                                          pparmp3d->GetuC(),pparmp3d->GetuD(),pparmp3d->GetvA(),
+                                          pparmp3d->GetvB(),pparmp3d->GetvC(),pparmp3d->GetvD());
+        }
+        default:
+            break;
+        }
+
+
+    }
+    return 0;
+}
+
+int DialogRoadMerge::MergeElevation(Road *pRoad1, Road *pRoad2)
+{
+    double froad1len = pRoad1->GetRoadLength();
+    int i;
+    int nroad2elecount = pRoad2->GetElevationCount();
+    for(i=0;i<nroad2elecount;i++)
+    {
+        Elevation * pele = pRoad2->GetElevation(i);
+        pRoad1->AddElevation(pele->GetS() + froad1len,pele->GetA(),pele->GetB(),
+                             pele->GetC(),pele->GetD());
+    }
+    return 0;
+}
+
+int DialogRoadMerge::MergeLaneSection(Road *pRoad1, Road *pRoad2)
+{
+    double froad1len = pRoad1->GetRoadLength();
+    int i;
+    bool bAddRoad2LaneSection = true;
+    if((pRoad1->GetLaneSectionCount() == pRoad2->GetLaneSectionCount())&&(pRoad1->GetLaneSectionCount() == 1))
+    {
+        if(pRoad1->GetLaneSection(0)->GetLaneCount() == pRoad2->GetLaneSection(0)->GetLaneCount())
+        {
+            LaneSection * pLS1 = pRoad1->GetLaneSection(0);
+            LaneSection * pLS2 = pRoad2->GetLaneSection(0);
+            Lane * pLane1,*pLane2;
+            pLane1 = 0;
+            pLane2 = 0;
+            unsigned int j;
+            for(j=0;j<pLS1->GetLaneCount();j++)
+            {
+                if(pLS1->GetLane(j)->GetId() != 0)
+                {
+                    pLane1 = pLS1->GetLane(j);
+                    break;
+                }
+            }
+            for(j=0;j<pLS2->GetLaneCount();j++)
+            {
+                if(pLS2->GetLane(j)->GetId() != 0)
+                {
+                    pLane2 = pLS2->GetLane(j);
+                    break;
+                }
+            }
+            if(pLane1 == pLane2)
+            {
+                bAddRoad2LaneSection = false;
+            }
+            if((pLane1 != 0) && (pLane2 != 0))
+            {
+                if((pLane1->GetLaneWidthCount() == pLane2->GetLaneWidthCount())&&(pLane1->GetLaneWidthCount()>0))
+                {
+                    LaneWidth * pLW1 = pLane1->GetLaneWidth(0);
+                    LaneWidth * pLW2 = pLane2->GetLaneWidth(0);
+                    if((pLW1->GetA() == pLW2->GetA())&&(pLW1->GetB() == pLW2->GetB())&&(pLW1->GetC() == pLW2->GetC())&&(pLW1->GetD() == pLW2->GetD()))
+                    {
+                        bAddRoad2LaneSection = false;
+                    }
+                }
+            }
+        }
+    }
+
+    if(bAddRoad2LaneSection == true)
+    {
+        int nroad2lanesectioncount = pRoad2->GetLaneSectionCount();
+        for(i=0;i<nroad2lanesectioncount;i++)
+        {
+            LaneSection ls = *(pRoad2->GetLaneSection(i));
+            ls.SetS(ls.GetS() + froad1len);
+            pRoad1->GetLaneSectionVector()->push_back(ls);
+        }
+    }
+
+    return 0;
+}
+
+int DialogRoadMerge::MergeSignal(Road *pRoad1, Road *pRoad2)
+{
+    double froad1len = pRoad1->GetRoadLength();
+    int i;
+    int nroad2sigcount = pRoad2->GetSignalCount();
+    for(i=0;i<nroad2sigcount;i++)
+    {
+        Signal xs = *(pRoad2->GetSignal(i));
+        xs.Sets(xs.Gets() + froad1len);
+        pRoad1->GetSignalVector()->push_back(xs);
+    }
+}
+
+void DialogRoadMerge::on_pushButton_Merge_clicked()
+{
+    std::string strroad1 = ui->lineEdit_Road1->text().toStdString();
+    std::string strroad2 = ui->lineEdit_Road2->text().toStdString();
+    Road * pRoad1 = xodrfunc::GetRoadByID(mpxodr,strroad1);
+    if(pRoad1 == 0)
+    {
+        QMessageBox::warning(this,"Warning","Not found road1",QMessageBox::YesAll);
+        return;
+    }
+    Road * pRoad2 = xodrfunc::GetRoadByID(mpxodr,strroad2);
+    if(pRoad2 == 0)
+    {
+        QMessageBox::warning(this,"Warning","Not found road2",QMessageBox::YesAll);
+        return;
+    }
+
+    double x1,y1,hdg1;
+    double x2,y2,hdg2;
+    xodrfunc::GetRoadXYByS(pRoad1,pRoad1->GetRoadLength(),x1,y1,hdg1);
+    xodrfunc::GetRoadXYByS(pRoad2,0,x2,y2,hdg2);
+
+    double fdis = sqrt(pow(x1-x2,2)+pow(y1-y2,2));
+
+    if(fdis > 1.0)
+    {
+        char strout[256];
+        snprintf(strout,256,"Road dis very fast. Dis is %6.3f",fdis);
+        QMessageBox::warning(this,"Warning",QString(strout),QMessageBox::YesAll);
+        return;
+    }
+
+
+    //Merge Geometry
+    Road xroad;
+    xroad = *pRoad1;
+    double froad1len = pRoad1->GetRoadLength();
+
+    MergeGeometry(pRoad1,pRoad2);
+//    int nroad2geocount = pRoad2->GetGeometryBlockCount();
+//    int i;
+//    GeometryBlock * pnewgb;
+//    for(i=0;i<nroad2geocount;i++)
+//    {
+
+
+//        GeometryBlock * pgb = pRoad2->GetGeometryBlock(i);
+
+//        RoadGeometry * pgeb = pgb->GetGeometryAt(0);
+//        if(pgeb == 0)
+//        {
+//            continue;
+//        }
+//        pRoad1->AddGeometryBlock();
+//        pnewgb = pRoad1->GetLastAddedGeometryBlock();
+//        switch (pgeb->GetGeomType()) {
+//        case 0:
+//            pnewgb->AddGeometryLine(pgeb->GetS() + froad1len,pgeb->GetX(),pgeb->GetY(),pgeb->GetHdg(),pgeb->GetLength());
+//            break;
+//        case 1:
+//        {
+//            GeometrySpiral * pspiral = (GeometrySpiral *)pgeb;
+//            pnewgb->AddGeometrySpiral(pgeb->GetS() + froad1len,pgeb->GetX(),pgeb->GetY(),pgeb->GetHdg(),pgeb->GetLength(),
+//                                      pspiral->GetCurvatureStart(),pspiral->GetCurvatureEnd());
+//        }
+//            break;
+//        case 2:
+//        {
+//            GeometryArc * parc = (GeometryArc *)pgeb;
+//            pnewgb->AddGeometryArc(pgeb->GetS() + froad1len,parc->GetX(),parc->GetY(),
+//                                   parc->GetHdg(),parc->GetLength(),parc->GetCurvature());
+//        }
+//            break;
+//        case 4:
+//        {
+//            GeometryParamPoly3 * pparmp3d = (GeometryParamPoly3 *)pgeb;
+//            pnewgb->AddGeometryParamPoly3(pgeb->GetS() + froad1len,pgeb->GetX(),pgeb->GetY(),
+//                                          pgeb->GetHdg(),pgeb->GetLength(),pparmp3d->GetuA(),pparmp3d->GetuB(),
+//                                          pparmp3d->GetuC(),pparmp3d->GetuD(),pparmp3d->GetvA(),
+//                                          pparmp3d->GetvB(),pparmp3d->GetvC(),pparmp3d->GetvD());
+//        }
+//        default:
+//            break;
+//        }
+
+
+//    }
+
+
+    //Merge ELevation
+    MergeElevation(pRoad1,pRoad2);
+
+    //Merge LaneSection
+
+    MergeLaneSection(pRoad1,pRoad2);
+
+    //Merge Signal
+    MergeSignal(pRoad1,pRoad2);
+
+
+    pRoad1->SetRoadLength(pRoad1->GetRoadLength() + pRoad2->GetRoadLength());
+     mpxodr->DeleteRoad(xodrfunc::GetRoadIndex(mpxodr,pRoad2));
+}

+ 35 - 0
src/tool/map_lanetoxodr/dialogroadmerge.h

@@ -0,0 +1,35 @@
+#ifndef DIALOGROADMERGE_H
+#define DIALOGROADMERGE_H
+
+#include <QDialog>
+
+#include "OpenDrive/OpenDrive.h"
+#include <QMessageBox>
+
+namespace Ui {
+class DialogRoadMerge;
+}
+
+class DialogRoadMerge : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogRoadMerge(OpenDrive * pxodr,QWidget *parent = nullptr);
+    ~DialogRoadMerge();
+
+private slots:
+    void on_pushButton_Merge_clicked();
+
+private:
+    Ui::DialogRoadMerge *ui;
+    OpenDrive * mpxodr;
+
+private:
+    int MergeGeometry(Road * pRoad1,Road * pRoad2);
+    int MergeElevation(Road * pRoad1,Road * pRoad2);
+    int MergeLaneSection(Road * pRoad1,Road * pRoad2);
+    int MergeSignal(Road * pRoad1,Road * pRoad2);
+};
+
+#endif // DIALOGROADMERGE_H

+ 78 - 0
src/tool/map_lanetoxodr/dialogroadmerge.ui

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogRoadMerge</class>
+ <widget class="QDialog" name="DialogRoadMerge">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>432</width>
+    <height>262</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QPushButton" name="pushButton_Merge">
+   <property name="geometry">
+    <rect>
+     <x>160</x>
+     <y>150</y>
+     <width>89</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Merge</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_Road1">
+   <property name="geometry">
+    <rect>
+     <x>200</x>
+     <y>30</y>
+     <width>131</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_Road2">
+   <property name="geometry">
+    <rect>
+     <x>200</x>
+     <y>90</y>
+     <width>131</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>90</x>
+     <y>40</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Road1</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>90</x>
+     <y>100</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Road2</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 146 - 0
src/tool/map_lanetoxodr/dialogroadmirror.cpp

@@ -0,0 +1,146 @@
+#include "dialogroadmirror.h"
+#include "ui_dialogroadmirror.h"
+
+#include "gnss_coordinate_convert.h"
+
+#include <math.h>
+
+#include <mainwindow.h>
+
+extern MainWindow * gw;
+
+extern double glon0 ;
+extern double glat0 ;
+
+DialogRoadMirror::DialogRoadMirror(OpenDrive * pxodr,Road * pRoad,QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogRoadMirror)
+{
+    ui->setupUi(this);
+    mpxodr = pxodr;
+    mpRoad = pRoad;
+
+    if(pRoad != 0)
+    {
+        setWindowTitle(QString(pRoad->GetRoadId().data()));
+    }
+}
+
+DialogRoadMirror::~DialogRoadMirror()
+{
+    delete ui;
+}
+
+void DialogRoadMirror::on_pushButton_Mirror_clicked()
+{
+
+    double x0,y0;
+    double rel_x,rel_y;
+    double x,y;
+    double flon,flat;
+    flon = ui->lineEdit_Lon->text().toDouble();
+    flat = ui->lineEdit_Lat->text().toDouble();
+    GaussProjCal(glon0,glat0,&x0,&y0);
+    GaussProjCal(flon,flat,&x,&y);
+    rel_x = x - x0;
+    rel_y = y - y0;
+
+    double hdg = (90 - ui->lineEdit_Heading->text().toDouble())*M_PI/180.0;
+    while(hdg < 0)hdg = hdg + 2.0*M_PI;
+    while(hdg >= 2.0*M_PI)hdg = hdg - 2.0*M_PI;
+
+    x0 = rel_x;
+    y0 = rel_y;
+    double hdg0 = hdg;
+
+    Road newroad = *mpRoad;
+
+    int i;
+    int ngeobcount = mpRoad->GetGeometryBlockCount();
+    for(i=0;i<ngeobcount;i++)
+    {
+        double x,y,hdg;
+        RoadGeometry * pgeo = newroad.GetGeometryBlock(i)->GetGeometryAt(0);
+        if(pgeo == 0)continue;
+        x = newroad.GetGeometryBlock(i)->GetGeometryAt(0)->GetX();
+        y = newroad.GetGeometryBlock(i)->GetGeometryAt(0)->GetY();
+        hdg = newroad.GetGeometryBlock(i)->GetGeometryAt(0)->GetHdg();
+
+        x = x-x0;
+        y = y- y0;
+
+        double s,t;
+        double frotate = hdg0*(-1);
+        s = x*cos(frotate) -y*sin(frotate) ;
+        t = x*sin(frotate) +y*cos(frotate);
+        hdg = hdg + frotate;
+        while(hdg<0)hdg = hdg + 2.0*M_PI;
+        while(hdg>=2.0*M_PI)hdg = hdg - 2.0*M_PI;
+
+        x = s;
+        y = t*(-1);
+        hdg = hdg*(-1);
+
+        while(hdg<0)hdg = hdg + 2.0*M_PI;
+        while(hdg>=2.0*M_PI)hdg = hdg - 2.0*M_PI;
+
+        frotate = hdg0;
+
+        s = x*cos(frotate) -y*sin(frotate) ;
+        t = x*sin(frotate) +y*cos(frotate);
+        hdg = hdg + frotate;
+        while(hdg<0)hdg = hdg + 2.0*M_PI;
+        while(hdg>=2.0*M_PI)hdg = hdg - 2.0*M_PI;
+
+
+        newroad.GetGeometryBlock(i)->GetGeometryAt(0)->SetX(s + x0);
+        newroad.GetGeometryBlock(i)->GetGeometryAt(0)->SetY(t + y0);
+        newroad.GetGeometryBlock(i)->GetGeometryAt(0)->SetHdg(hdg);
+
+        if(pgeo->GetGeomType() == 1)
+        {
+            GeometrySpiral * pSpiral = (GeometrySpiral *)pgeo;
+            double startcurv = pSpiral->GetCurvatureStart() *(-1);
+            double endcurv = pSpiral->GetCurvatureEnd() *(-1);
+            pSpiral->SetCurvatureStart(startcurv);
+            pSpiral->SetCurvatureEnd(endcurv);
+        }
+
+        if(pgeo->GetGeomType() == 2)
+        {
+            GeometryArc * pArc = (GeometryArc *)pgeo;
+            double curv = pArc->GetCurvature();
+            pArc->SetCurvature(curv*(-1));
+        }
+    }
+
+    int nnewroadid = gw->CreateRoadID();
+    newroad.SetRoadId(QString::number(nnewroadid).toStdString());
+
+    mpxodr->GetRoadVector()->push_back(newroad);
+
+    bool bSaveOldRoad = true;
+    QMessageBox::StandardButton button;
+    char strout[256];
+    snprintf(strout,256,"New Road id is %d. Keep the old road.",nnewroadid);
+    button=QMessageBox::question(this,tr("Quest"),QString(strout),QMessageBox::Yes|QMessageBox::No);
+    if(button==QMessageBox::No)
+    {
+        bSaveOldRoad = false;
+    }
+    else if(button==QMessageBox::Yes)
+    {
+        bSaveOldRoad = true;
+    }
+
+    if(bSaveOldRoad == false)
+    {
+        int nroadindex = xodrfunc::GetRoadIndex(mpxodr,mpRoad);
+        if(nroadindex >= 0)
+        {
+            mpxodr->DeleteRoad(nroadindex);
+        }
+    }
+
+    this->accept();
+}

+ 32 - 0
src/tool/map_lanetoxodr/dialogroadmirror.h

@@ -0,0 +1,32 @@
+#ifndef DIALOGROADMIRROR_H
+#define DIALOGROADMIRROR_H
+
+#include <QDialog>
+
+#include "OpenDrive/OpenDrive.h"
+
+#include <QMessageBox>
+
+namespace Ui {
+class DialogRoadMirror;
+}
+
+class DialogRoadMirror : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogRoadMirror(OpenDrive * pxodr,Road * pRoad, QWidget *parent = nullptr);
+    ~DialogRoadMirror();
+
+private slots:
+    void on_pushButton_Mirror_clicked();
+
+private:
+    Ui::DialogRoadMirror *ui;
+
+    OpenDrive * mpxodr;
+    Road * mpRoad;
+};
+
+#endif // DIALOGROADMIRROR_H

+ 101 - 0
src/tool/map_lanetoxodr/dialogroadmirror.ui

@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogRoadMirror</class>
+ <widget class="QDialog" name="DialogRoadMirror">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>532</width>
+    <height>377</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QLineEdit" name="lineEdit_Lon">
+   <property name="geometry">
+    <rect>
+     <x>250</x>
+     <y>40</y>
+     <width>181</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_Lat">
+   <property name="geometry">
+    <rect>
+     <x>250</x>
+     <y>120</y>
+     <width>181</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_Heading">
+   <property name="geometry">
+    <rect>
+     <x>250</x>
+     <y>200</y>
+     <width>181</width>
+     <height>41</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_Mirror">
+   <property name="geometry">
+    <rect>
+     <x>210</x>
+     <y>280</y>
+     <width>111</width>
+     <height>41</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Mirror</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>110</x>
+     <y>55</y>
+     <width>91</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Longitude</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>112</x>
+     <y>138</y>
+     <width>67</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Latitude</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_3">
+   <property name="geometry">
+    <rect>
+     <x>110</x>
+     <y>220</y>
+     <width>101</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Heading(°)</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 102 - 0
src/tool/map_lanetoxodr/dialogroadmove.cpp

@@ -0,0 +1,102 @@
+#include "dialogroadmove.h"
+#include "ui_dialogroadmove.h"
+
+#include <math.h>
+
+#include <mainwindow.h>
+
+extern MainWindow * gw;
+
+DialogRoadMove::DialogRoadMove(OpenDrive * pxodr,Road * pRoad, QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogRoadMove)
+{
+    ui->setupUi(this);
+
+    mpxodr = pxodr;
+    mpRoad = pRoad;
+
+    if(pRoad != 0)
+    {
+        setWindowTitle(QString(pRoad->GetRoadId().data()));
+    }
+}
+
+DialogRoadMove::~DialogRoadMove()
+{
+    delete ui;
+}
+
+void DialogRoadMove::on_pushButton_Move_clicked()
+{
+    if(mpRoad == 0)
+    {
+        QMessageBox::warning(this,"Warning","Not have road.",QMessageBox::YesAll);
+        return;
+    }
+
+    double fMoveX = ui->lineEdit_normal->text().toDouble();
+    double fMoveY = ui->lineEdit_dir->text().toDouble();
+
+    if((fMoveX == 0)&&(fMoveY == 0))
+    {
+        QMessageBox::StandardButton button;
+        button=QMessageBox::question(this,tr("生成道路"),QString(tr("是否在原来位置生成道路")),QMessageBox::Yes|QMessageBox::No);
+        if(button==QMessageBox::No)
+        {
+            return;
+        }
+        else if(button==QMessageBox::Yes)
+        {
+
+        }
+    }
+
+    Road newroad = *mpRoad;
+
+    double hdg = 0;
+    if(mpRoad->GetGeometryBlockCount()>0)
+    {
+        hdg = mpRoad->GetGeometryBlock(0)->GetGeometryAt(0)->GetHdg();
+    }
+
+    double yoff = fMoveX*sin(hdg+M_PI/2.0) + fMoveY *sin(hdg);
+    double xoff = fMoveX*cos(hdg+M_PI/2.0) + fMoveY *cos(hdg);
+    int i;
+    int ngeobcount = mpRoad->GetGeometryBlockCount();
+    for(i=0;i<ngeobcount;i++)
+    {
+        newroad.GetGeometryBlock(i)->GetGeometryAt(0)->SetX(newroad.GetGeometryBlock(i)->GetGeometryAt(0)->GetX() + xoff);
+        newroad.GetGeometryBlock(i)->GetGeometryAt(0)->SetY(newroad.GetGeometryBlock(i)->GetGeometryAt(0)->GetY() + yoff);
+    }
+
+    int nnewroadid = gw->CreateRoadID();
+    newroad.SetRoadId(QString::number(nnewroadid).toStdString());
+
+    mpxodr->GetRoadVector()->push_back(newroad);
+
+    bool bSaveOldRoad = true;
+    QMessageBox::StandardButton button;
+    char strout[256];
+    snprintf(strout,256,"New Road id is %d. Keep the old road.",nnewroadid);
+    button=QMessageBox::question(this,tr("Quest"),QString(strout),QMessageBox::Yes|QMessageBox::No);
+    if(button==QMessageBox::No)
+    {
+        bSaveOldRoad = false;
+    }
+    else if(button==QMessageBox::Yes)
+    {
+        bSaveOldRoad = true;
+    }
+
+    if(bSaveOldRoad == false)
+    {
+        int nroadindex = xodrfunc::GetRoadIndex(mpxodr,mpRoad);
+        if(nroadindex >= 0)
+        {
+            mpxodr->DeleteRoad(nroadindex);
+        }
+    }
+
+    this->accept();
+}

+ 32 - 0
src/tool/map_lanetoxodr/dialogroadmove.h

@@ -0,0 +1,32 @@
+#ifndef DIALOGROADMOVE_H
+#define DIALOGROADMOVE_H
+
+#include <QDialog>
+
+#include "OpenDrive/OpenDrive.h"
+
+#include <QMessageBox>
+
+namespace Ui {
+class DialogRoadMove;
+}
+
+class DialogRoadMove : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogRoadMove(OpenDrive * pxodr,Road * pRoad, QWidget *parent = nullptr);
+    ~DialogRoadMove();
+
+private slots:
+    void on_pushButton_Move_clicked();
+
+private:
+    Ui::DialogRoadMove *ui;
+
+    OpenDrive * mpxodr;
+    Road * mpRoad;
+};
+
+#endif // DIALOGROADMOVE_H

+ 78 - 0
src/tool/map_lanetoxodr/dialogroadmove.ui

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogRoadMove</class>
+ <widget class="QDialog" name="DialogRoadMove">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>552</width>
+    <height>283</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QPushButton" name="pushButton_Move">
+   <property name="geometry">
+    <rect>
+     <x>200</x>
+     <y>170</y>
+     <width>89</width>
+     <height>25</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Move</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>60</x>
+     <y>100</y>
+     <width>181</width>
+     <height>21</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Road Direction</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label_2">
+   <property name="geometry">
+    <rect>
+     <x>60</x>
+     <y>40</y>
+     <width>171</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Road Normal Direction</string>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_normal">
+   <property name="geometry">
+    <rect>
+     <x>300</x>
+     <y>32</y>
+     <width>161</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLineEdit" name="lineEdit_dir">
+   <property name="geometry">
+    <rect>
+     <x>300</x>
+     <y>95</y>
+     <width>161</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 117 - 0
src/tool/map_lanetoxodr/dialogroadrotate.cpp

@@ -0,0 +1,117 @@
+#include "dialogroadrotate.h"
+#include "ui_dialogroadrotate.h"
+
+#include <math.h>
+
+#include <mainwindow.h>
+
+extern MainWindow * gw;
+
+DialogRoadRotate::DialogRoadRotate(OpenDrive * pxodr,Road * pRoad, QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::DialogRoadRotate)
+{
+    ui->setupUi(this);
+
+    mpxodr = pxodr;
+    mpRoad = pRoad;
+
+    if(pRoad != 0)
+    {
+        setWindowTitle(QString(pRoad->GetRoadId().data()));
+    }
+}
+
+DialogRoadRotate::~DialogRoadRotate()
+{
+    delete ui;
+}
+
+void DialogRoadRotate::on_pushButton_Rotate_clicked()
+{
+    if(mpRoad == 0)
+    {
+        QMessageBox::warning(this,"Warning","Not have road.",QMessageBox::YesAll);
+        return;
+    }
+
+    double frotate = ui->lineEdit_rotatedegree->text().toDouble() *M_PI/180.0;
+
+    if(frotate == 0)
+    {
+        QMessageBox::StandardButton button;
+        button=QMessageBox::question(this,tr("生成道路"),QString(tr("是否在原来位置生成道路")),QMessageBox::Yes|QMessageBox::No);
+        if(button==QMessageBox::No)
+        {
+            return;
+        }
+        else if(button==QMessageBox::Yes)
+        {
+
+        }
+    }
+
+    Road newroad = *mpRoad;
+    double hdg0 = 0;
+    double x0 = 0;
+    double y0 = 0;
+    if(mpRoad->GetGeometryBlockCount()>0)
+    {
+        hdg0 = mpRoad->GetGeometryBlock(0)->GetGeometryAt(0)->GetHdg();
+        x0 = mpRoad->GetGeometryBlock(0)->GetGeometryAt(0)->GetX();
+        y0 = mpRoad->GetGeometryBlock(0)->GetGeometryAt(0)->GetY();
+    }
+
+    int i;
+    int ngeobcount = mpRoad->GetGeometryBlockCount();
+    for(i=0;i<ngeobcount;i++)
+    {
+        double x,y,hdg;
+        x = newroad.GetGeometryBlock(i)->GetGeometryAt(0)->GetX();
+        y = newroad.GetGeometryBlock(i)->GetGeometryAt(0)->GetY();
+        hdg = newroad.GetGeometryBlock(i)->GetGeometryAt(0)->GetHdg();
+
+        double s,t;
+        s = (x-x0)*cos(frotate) -(y-y0)*sin(frotate) + x0;
+        t = (x-x0)*sin(frotate) +(y-y0)*cos(frotate) + y0;
+        hdg = hdg + frotate;
+        while(hdg<0)hdg = hdg + 2.0*M_PI;
+        while(hdg>=2.0*M_PI)hdg = hdg - 2.0*M_PI;
+
+
+        newroad.GetGeometryBlock(i)->GetGeometryAt(0)->SetX(s);
+        newroad.GetGeometryBlock(i)->GetGeometryAt(0)->SetY(t);
+        newroad.GetGeometryBlock(i)->GetGeometryAt(0)->SetHdg(hdg);
+    }
+
+    int nnewroadid = gw->CreateRoadID();
+    newroad.SetRoadId(QString::number(nnewroadid).toStdString());
+
+    mpxodr->GetRoadVector()->push_back(newroad);
+
+    bool bSaveOldRoad = true;
+    QMessageBox::StandardButton button;
+    char strout[256];
+    snprintf(strout,256,"New Road id is %d. Keep the old road.",nnewroadid);
+    button=QMessageBox::question(this,tr("Quest"),QString(strout),QMessageBox::Yes|QMessageBox::No);
+    if(button==QMessageBox::No)
+    {
+        bSaveOldRoad = false;
+    }
+    else if(button==QMessageBox::Yes)
+    {
+        bSaveOldRoad = true;
+    }
+
+    if(bSaveOldRoad == false)
+    {
+        int nroadindex = xodrfunc::GetRoadIndex(mpxodr,mpRoad);
+        if(nroadindex >= 0)
+        {
+            mpxodr->DeleteRoad(nroadindex);
+        }
+    }
+
+    this->accept();
+
+}

+ 32 - 0
src/tool/map_lanetoxodr/dialogroadrotate.h

@@ -0,0 +1,32 @@
+#ifndef DIALOGROADROTATE_H
+#define DIALOGROADROTATE_H
+
+#include <QDialog>
+
+#include "OpenDrive/OpenDrive.h"
+
+#include <QMessageBox>
+
+namespace Ui {
+class DialogRoadRotate;
+}
+
+class DialogRoadRotate : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit DialogRoadRotate(OpenDrive * pxodr,Road * pRoad, QWidget *parent = nullptr);
+    ~DialogRoadRotate();
+
+private slots:
+    void on_pushButton_Rotate_clicked();
+
+private:
+    Ui::DialogRoadRotate *ui;
+
+    OpenDrive * mpxodr;
+    Road * mpRoad;
+};
+
+#endif // DIALOGROADROTATE_H

+ 55 - 0
src/tool/map_lanetoxodr/dialogroadrotate.ui

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogRoadRotate</class>
+ <widget class="QDialog" name="DialogRoadRotate">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>487</width>
+    <height>242</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <widget class="QLineEdit" name="lineEdit_rotatedegree">
+   <property name="geometry">
+    <rect>
+     <x>250</x>
+     <y>66</y>
+     <width>181</width>
+     <height>31</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>90</x>
+     <y>70</y>
+     <width>131</width>
+     <height>21</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Degree(°)</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_Rotate">
+   <property name="geometry">
+    <rect>
+     <x>170</x>
+     <y>140</y>
+     <width>121</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Rotate</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 257 - 9
src/tool/map_lanetoxodr/dialogroadsplit.cpp

@@ -1,10 +1,14 @@
 #include "dialogroadsplit.h"
 #include "dialogroadsplit.h"
 #include "ui_dialogroadsplit.h"
 #include "ui_dialogroadsplit.h"
 
 
+#include "xodrfunc.h"
 
 
 #include "mainwindow.h"
 #include "mainwindow.h"
 extern MainWindow * gw;
 extern MainWindow * gw;
 
 
+extern double glon0 ;
+extern double glat0;
+
 DialogRoadSplit::DialogRoadSplit(Road * pRoad,OpenDrive * pxodr,QWidget *parent) :
 DialogRoadSplit::DialogRoadSplit(Road * pRoad,OpenDrive * pxodr,QWidget *parent) :
     QDialog(parent),
     QDialog(parent),
     ui(new Ui::DialogRoadSplit)
     ui(new Ui::DialogRoadSplit)
@@ -39,7 +43,20 @@ void DialogRoadSplit::on_pushButton_spalitats_clicked()
     }
     }
 
 
 
 
-    SplitRoad(mpxodr,mpRoad,s);
+    int nrtn = SplitRoad(mpxodr,mpRoad,s);
+
+    if(nrtn == 0)
+    {
+        QMessageBox::information(this,"Split","split road successfully.",QMessageBox::YesAll);
+        this->accept();
+    }
+    else
+    {
+        char strout[256];
+        snprintf(strout,256,"split error code is %d",nrtn);
+        QMessageBox::warning(this,"Split Road Fail",QString(strout),QMessageBox::YesAll);
+
+    }
 
 
 
 
 
 
@@ -164,14 +181,21 @@ int DialogRoadSplit::SplitRoad(OpenDrive *pxodr, Road *pRoad,const double s)
     if(pxodr == 0)return -3;
     if(pxodr == 0)return -3;
     if(s>=pRoad->GetRoadLength())return -4;
     if(s>=pRoad->GetRoadLength())return -4;
 
 
+
+    vector<Elevation> xvectorelevation = *(pRoad->GetElevationVector());
+    vector<LaneSection> xvectorlanesection = *(pRoad->GetLaneSectionVector());
+    vector<Signal> xvectorsignal = *(pRoad->GetSignalVector());
+
+//    double fRoadLen = pRoad->GetRoadLength();
+
     std::string strroadid = pRoad->GetRoadId();
     std::string strroadid = pRoad->GetRoadId();
-    int ngeocount = pRoad->GetGeometryBlockCount();
+    unsigned int ngeocount = pRoad->GetGeometryBlockCount();
 
 
     if(ngeocount < 1)return -5;
     if(ngeocount < 1)return -5;
 
 
-    int i;
+    unsigned int i;
     GeometryBlock * pgeobsel = 0;
     GeometryBlock * pgeobsel = 0;
-    int indexsplit = 0;
+    unsigned int indexsplit = 0;
     for(i=0;i<(ngeocount-1);i++)
     for(i=0;i<(ngeocount-1);i++)
     {
     {
         GeometryBlock * pgeob = pRoad->GetGeometryBlock(i+1);
         GeometryBlock * pgeob = pRoad->GetGeometryBlock(i+1);
@@ -182,11 +206,15 @@ int DialogRoadSplit::SplitRoad(OpenDrive *pxodr, Road *pRoad,const double s)
             break;
             break;
         }
         }
     }
     }
-    if(pgeobsel == 0)pgeobsel = pRoad->GetGeometryBlock(0);
+    if(pgeobsel == 0)
+    {
+        pgeobsel = pRoad->GetGeometryBlock(pRoad->GetGeometryBlockCount()-1);
+        indexsplit = pRoad->GetGeometryBlockCount()-1;
+    }
 
 
     short ngeotype = pgeobsel->GetGeometryAt(0)->GetGeomType();
     short ngeotype = pgeobsel->GetGeometryAt(0)->GetGeomType();
 
 
-    Road * pnewroad;
+//    Road * pnewroad;
      //not line or geo. split as this geo start.
      //not line or geo. split as this geo start.
     //or line arc. but s at geo start.
     //or line arc. but s at geo start.
     if(((ngeotype !=0)&&(ngeotype !=2))||((indexsplit != 0)&&(pgeobsel->GetGeometryAt(0)->GetS() == s)))
     if(((ngeotype !=0)&&(ngeotype !=2))||((indexsplit != 0)&&(pgeobsel->GetGeometryAt(0)->GetS() == s)))
@@ -195,7 +223,7 @@ int DialogRoadSplit::SplitRoad(OpenDrive *pxodr, Road *pRoad,const double s)
         else
         else
         {
         {
             double flength = 0;
             double flength = 0;
-            int j;
+            unsigned int j;
             for(j=indexsplit;j<ngeocount;j++)
             for(j=indexsplit;j<ngeocount;j++)
             {
             {
                 flength = flength + pRoad->GetGeometryBlock(j)->GetGeometryAt(0)->GetLength();
                 flength = flength + pRoad->GetGeometryBlock(j)->GetGeometryAt(0)->GetLength();
@@ -230,6 +258,9 @@ int DialogRoadSplit::SplitRoad(OpenDrive *pxodr, Road *pRoad,const double s)
             pRoad->SetRoadLength(flength1);
             pRoad->SetRoadLength(flength1);
             for(j=0;j<indexsplit;j++)pnewroad->DeleteGeometryBlock(0);
             for(j=0;j<indexsplit;j++)pnewroad->DeleteGeometryBlock(0);
 
 
+            proad1 = pRoad;
+            proad2 = pnewroad;
+
         }
         }
     }
     }
     else
     else
@@ -245,8 +276,8 @@ int DialogRoadSplit::SplitRoad(OpenDrive *pxodr, Road *pRoad,const double s)
 
 
             if(nrtn != 0)return -8;
             if(nrtn != 0)return -8;
 
 
-            int newroadid = gw->CreateRoadID();
-            int j;
+            unsigned int newroadid = gw->CreateRoadID();
+            unsigned int j;
             double flength,flength1;
             double flength,flength1;
 
 
             flength = c.GetGeometryAt(0)->GetLength();
             flength = c.GetGeometryAt(0)->GetLength();
@@ -300,9 +331,226 @@ int DialogRoadSplit::SplitRoad(OpenDrive *pxodr, Road *pRoad,const double s)
                 pnewroad->GetGeometryBlock(j)->GetGeometryAt(0)->SetS(pnewroad->GetGeometryBlock(j)->GetGeometryAt(0)->GetS() - s);
                 pnewroad->GetGeometryBlock(j)->GetGeometryAt(0)->SetS(pnewroad->GetGeometryBlock(j)->GetGeometryAt(0)->GetS() - s);
             }
             }
 
 
+            proad1 = pRoad;
+            proad2 = pnewroad;
+
+        }
+    }
+
+
+    SplitElevation(proad1,proad2,xvectorelevation);
+    SplitLaneSection(proad1,proad2,xvectorlanesection);
+    SplitSignal(proad1,proad2,xvectorsignal);
+
+    return 0;
+
+}
+
+int DialogRoadSplit::SplitElevation(Road *proad1, Road *proad2, vector<Elevation> xvectorele)
+{
+    double flen1 = proad1->GetRoadLength();
+ //   double flen2 = proad2->GetRoadLength();
+
+    bool bsplitele  = false;
+    unsigned int indexsplitele = 0;
+    if(xvectorele.size() > 0)
+    {
+        unsigned int i;
+        for(i=0;i<(xvectorele.size()-1);i++)
+        {
+            if(flen1 <= xvectorele[i+1].GetS())
+            {
+                indexsplitele = i;
+                bsplitele = true;
+                break;
+            }
+
+        }
+
+        if(bsplitele == false)
+        {
+            indexsplitele = xvectorele.size() -1;
+            bsplitele = true;
+        }
+
+        for(i=(indexsplitele+1);i<xvectorele.size();i++)
+        {
+            proad1->GetElevationVector()->erase(proad1->GetElevationVector()->begin()+indexsplitele+1);
+        }
+
+        for(i=0;i<(indexsplitele+1);i++)
+        {
+            proad2->GetElevationVector()->erase(proad2->GetElevationVector()->begin());
+        }
+
+        double a0,b0,c0,d0;
+        double a1,b1,c1,d1;
+        Elevation * pa = &(proad1->GetElevationVector()->at(indexsplitele));
+        a0 = pa->GetA();
+        b0 = pa->GetB();
+        c0 = pa->GetC();
+        d0 = pa->GetD();
+        double s0 = flen1 - pa->GetS();
+        a1 = a0 + b0*s0 + c0* s0*s0 + d0*s0*s0*s0;
+        b1 = b0 + 2*c0*s0 + 3*d0*s0*s0;
+        c1 = c0 + 3*d0*s0;
+        d1 = d0;
+
+        if(s0 == 0)proad1->GetElevationVector()->erase(proad1->GetElevationVector()->begin()+indexsplitele);
+
+        Elevation newele(flen1,a1,b1,c1,d1);
+        proad2->GetElevationVector()->insert(proad2->GetElevationVector()->begin(),newele);
+
+        for(i=0;i<proad2->GetElevationCount();i++)
+        {
+            proad2->GetElevationVector()->at(i).SetS(proad2->GetElevationVector()->at(i).GetS() - flen1);
+        }
+
+
+    }
+
+    return 0;
+}
+
+
+int DialogRoadSplit::Splitabcd(double a0, double b0, double c0, double d0, double &a, double &b, double &c, double &d, double s_off)
+{
+    a = a0 + b0*s_off + c0* s_off*s_off + d0*s_off*s_off*s_off;
+    b = b0 + 2*c0*s_off + 3*d0*s_off*s_off;
+    c = c0 + 3*d0*s_off;
+    d = d0;
+    return 0;
+}
+
+int DialogRoadSplit::SplitLaneSection(Road *proad1, Road *proad2,  vector<LaneSection> xvectorls)
+{
+    double flen1 = proad1->GetRoadLength();
+ //   double flen2 = proad2->GetRoadLength();
+
+    bool bsplitls  = false;
+    int indexsplitls = 0;
+    if(xvectorls.size() > 0)
+    {
+        unsigned int i;
+        for(i=0;i<(xvectorls.size()-1);i++)
+        {
+            if(flen1 <= xvectorls[i+1].GetS())
+            {
+                indexsplitls = i;
+                bsplitls = true;
+                break;
+            }
+
+        }
+
+        if(bsplitls == false)
+        {
+            indexsplitls = xvectorls.size() -1;
+            bsplitls = true;
+        }
+
+        LaneSection * pLS = &(proad1->GetLaneSectionVector()->at(indexsplitls));
+         double s0 = flen1 - pLS->GetS();
+
+
+
+        for(i=(indexsplitls+1);i<xvectorls.size();i++)
+        {
+            proad1->GetLaneSectionVector()->erase(proad1->GetLaneSectionVector()->begin()+indexsplitls+1);
+        }
+
+        for(i=0;i<(indexsplitls+1);i++)
+        {
+            proad2->GetLaneSectionVector()->erase(proad2->GetLaneSectionVector()->begin());
+        }
+
+        if(s0 == 0)
+        {
+            proad1->GetLaneSectionVector()->erase(proad1->GetLaneSectionVector()->begin()+indexsplitls);
+            proad2->GetLaneSectionVector()->insert(proad2->GetLaneSectionVector()->begin(),xvectorls[indexsplitls]);
+        }
+        else
+        {
+            LaneSection LS = xvectorls[indexsplitls];
+            unsigned int j;
+            for(j=0;j<LS.GetLaneCount();j++)
+            {
+                Lane * pLane =  LS.GetLane(j);
+                if(pLane->GetLaneWidthCount()>0)
+                {
+                    double a,b,c,d;
+                    Splitabcd(pLane->GetLaneWidth(0)->GetA(),pLane->GetLaneWidth(0)->GetB(),
+                              pLane->GetLaneWidth(0)->GetC(),pLane->GetLaneWidth(0)->GetD(),
+                              a,b,c,d,s0);
+                    pLane->GetLaneWidth(0)->SetA(a);
+                    pLane->GetLaneWidth(0)->SetB(b);
+                    pLane->GetLaneWidth(0)->SetC(c);
+                    pLane->GetLaneWidth(0)->SetD(d);
+                }
+            }
+            proad2->GetLaneSectionVector()->insert(proad2->GetLaneSectionVector()->begin(),LS);
+        }
+
+        proad2->GetLaneSectionVector()->at(0).SetS(0);
+
+        for(i=1;i<proad2->GetLaneSectionCount();i++)
+        {
+            proad2->GetLaneSectionVector()->at(i).SetS(proad2->GetLaneSectionVector()->at(i).GetS() - flen1);
         }
         }
+
     }
     }
+    return 0;
+}
+
+int DialogRoadSplit::SplitSignal(Road *proad1, Road *proad2, vector<Signal> xvectorsignal)
+{
+    double flen1 = proad1->GetRoadLength();
+    unsigned int i;
+    for(i=0;i<xvectorsignal.size();i++)
+    {
+        proad1->GetSignalVector()->erase(proad1->GetSignalVector()->begin());
+        proad2->GetSignalVector()->erase(proad2->GetSignalVector()->begin());
+    }
+
+    for(i=0;i<xvectorsignal.size();i++)
+    {
 
 
+        if(xvectorsignal.at(i).Gets()<flen1)
+        {
+            proad1->GetSignalVector()->push_back(xvectorsignal.at(i));
+        }
+        else
+        {
+            xvectorsignal.at(i).Sets(xvectorsignal.at(i).Gets() - flen1);
+            proad2->GetSignalVector()->push_back(xvectorsignal.at(i));
+        }
+    }
     return 0;
     return 0;
+}
 
 
+void DialogRoadSplit::on_pushButton_spliatatpos_clicked()
+{
+    Road * pRoad = 0;
+    GeometryBlock * pgeob;
+    double fdis,nearx,neary,hdg;
+    double fs;
+    int nlane;
+    double x0,y0;
+    double rel_x,rel_y;
+    double x,y;
+    double flon,flat;
+    flon = ui->lineEdit_lon->text().toDouble();
+    flat = ui->lineEdit_lat->text().toDouble();
+    GaussProjCal(glon0,glat0,&x0,&y0);
+    GaussProjCal(flon,flat,&x,&y);
+    rel_x = x - x0;
+    rel_y = y - y0;
+    if(xodrfunc::GetNearPoint(rel_x,rel_y,mpxodr,&pRoad,&pgeob,fdis,nearx,neary,hdg,50,&fs,&nlane,true) == 0)
+    {
+        SplitRoad(mpxodr,pRoad,fs);
+    }
+    else
+    {
+        QMessageBox::warning(this,"Warning","Position is Fast",QMessageBox::YesAll);
+    }
 }
 }

+ 8 - 0
src/tool/map_lanetoxodr/dialogroadsplit.h

@@ -21,11 +21,19 @@ public:
 private slots:
 private slots:
     void on_pushButton_spalitats_clicked();
     void on_pushButton_spalitats_clicked();
 
 
+    void on_pushButton_spliatatpos_clicked();
+
 public:
 public:
     static int SplitRoad(OpenDrive * pxodr,Road * pRoad,const double s);
     static int SplitRoad(OpenDrive * pxodr,Road * pRoad,const double s);
     static int SplitGeometryBlock(GeometryBlock * pa,GeometryBlock * pb, GeometryBlock * pc,const double s);
     static int SplitGeometryBlock(GeometryBlock * pa,GeometryBlock * pb, GeometryBlock * pc,const double s);
     static int SplitElevation(Elevation * pa,Elevation ** pb,Elevation ** pc,const double s);
     static int SplitElevation(Elevation * pa,Elevation ** pb,Elevation ** pc,const double s);
 
 
+    static int SplitElevation(Road * proad1,Road * proad2,vector<Elevation> xvectorele);
+    static int SplitLaneSection(Road * proad1,Road * proad2,vector<LaneSection> xvectorls);
+    static int SplitSignal(Road * proad1,Road * proad2,vector<Signal> xvectorsignal);
+
+    static int Splitabcd(double a0,double b0,double c0,double d0,double & a,double & b,double & c ,double & d,double s_off);
+
 private:
 private:
     Ui::DialogRoadSplit *ui;
     Ui::DialogRoadSplit *ui;
     Road * mpRoad;
     Road * mpRoad;

+ 47 - 2
src/tool/map_lanetoxodr/main.cpp

@@ -1,14 +1,59 @@
+
+#ifdef XODRViewer
+#include "xvmainwindow.h"
+#else
 #include "mainwindow.h"
 #include "mainwindow.h"
+#endif
+
 #include <QApplication>
 #include <QApplication>
 
 
-#include "ivbacktrace.h"
+
+#ifdef Android
+#include <QAndroidJniEnvironment>
+#include <QtAndroid>
+//#include <QAndr
+#include <QAndroidJniObject>
+
+#endif
+
+
+
+
+
+#ifdef Android
+
+bool requestPermission() {
+   QtAndroid::PermissionResult  r = QtAndroid::checkPermission("android.permission.WRITE_EXTERNAL_STORAGE");
+    if(r == QtAndroid::PermissionResult::Denied) {
+        QtAndroid::requestPermissionsSync( QStringList() << "android.permission.WRITE_EXTERNAL_STORAGE" );
+        r = QtAndroid::checkPermission("android.permission.WRITE_EXTERNAL_STORAGE");
+        if(r == QtAndroid::PermissionResult::Denied) {
+             return false;
+        }
+   }
+   return true;
+}
+
+#endif
+
+
 
 
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
-    RegisterIVBackTrace();
 
 
     QApplication a(argc, argv);
     QApplication a(argc, argv);
+
+#ifdef Android
+
+    requestPermission();
+
+#endif
+
+#ifdef XODRViewer
+    XVMainWindow w;
+#else
     MainWindow w;
     MainWindow w;
+#endif
     w.show();
     w.show();
     w.resize(1280,800);
     w.resize(1280,800);
 
 

+ 104 - 4
src/tool/map_lanetoxodr/mainwindow.cpp

@@ -54,6 +54,10 @@ MainWindow::MainWindow(QWidget *parent) :
 
 
     scene = new QGraphicsScene;
     scene = new QGraphicsScene;
 
 
+//    mpscene = new  QGraphicsScene;//(-300, -300, 600, 600);
+    mpscene = new  QGraphicsScene(0,0,VIEW_WIDTH,VIEW_HEIGHT);
+    mpscene->setBackgroundBrush(Qt::darkGreen);
+
 
 
  //    painter->begin(image);
  //    painter->begin(image);
 
 
@@ -370,6 +374,16 @@ void MainWindow::ExecPainter()
 void MainWindow::paintEvent(QPaintEvent *)
 void MainWindow::paintEvent(QPaintEvent *)
 {
 {
 
 
+    if(mnViewMode == 1)
+    {
+        if(mbRefresh)
+        {
+ //           UpdateScene();
+        }
+        myview->setScene(mpscene);
+        myview->show();
+        return;
+    }
     if(mbRefresh)
     if(mbRefresh)
     {
     {
         ExecPainter();
         ExecPainter();
@@ -422,6 +436,21 @@ void MainWindow::CreateTab1View(QTabWidget * p)
     int nLEWidth = mnFontHeight * 6;
     int nLEWidth = mnFontHeight * 6;
     int nLEHeight = mnFontHeight * 3/2;
     int nLEHeight = mnFontHeight * 3/2;
 
 
+    pLabel = new QLabel(pGroup);
+    pLabel->setText("View Mode");
+    pLabel->setGeometry(nXPos,nYPos,nLEWidth,nLEHeight);
+    nXPos = nXPos + nSpace;
+
+    pCB = new QComboBox(pGroup);
+    pCB->addItem("Line");
+    pCB->addItem("Scene");
+    pCB->setCurrentIndex(0);
+    pCB->setGeometry(nXPos,nYPos,nLEWidth,nLEHeight);
+    connect(pCB,SIGNAL(currentIndexChanged(int)),this,SLOT(onViewModeChange(int)));
+
+    nXPos = 10;
+    nYPos = nYPos + mnFontHeight * 3;
+
     pLabel = new QLabel(pGroup);
     pLabel = new QLabel(pGroup);
     pLabel->setText("Lat0");
     pLabel->setText("Lat0");
     pLabel->setGeometry(nXPos,nYPos,nLEWidth,nLEHeight);
     pLabel->setGeometry(nXPos,nYPos,nLEWidth,nLEHeight);
@@ -1168,8 +1197,11 @@ void MainWindow::onClickXY(double x, double y)
     double lon,lat;
     double lon,lat;
     selx = mClickX;
     selx = mClickX;
     sely = mClickY * (-1);
     sely = mClickY * (-1);
-    selx = selx/((double )mnfac);
-    sely = sely/((double)mnfac);
+    if(mnViewMode == 0)
+    {
+        selx = selx/((double )mnfac);
+        sely = sely/((double)mnfac);
+    }
     mpLE_SelX->setText(QString::number(selx,'f',3));
     mpLE_SelX->setText(QString::number(selx,'f',3));
     mpLE_SelY->setText(QString::number(sely,'f',3));
     mpLE_SelY->setText(QString::number(sely,'f',3));
 
 
@@ -4170,8 +4202,8 @@ int MainWindow::FindNewRoadID(OpenDrive *pxodr1, OpenDrive *pxodr2)
 int MainWindow::FindNewJunctionID(OpenDrive *pxodr1, OpenDrive *pxodr2)
 int MainWindow::FindNewJunctionID(OpenDrive *pxodr1, OpenDrive *pxodr2)
 {
 {
     int njunctionsize1,njunctionsize2;
     int njunctionsize1,njunctionsize2;
-    njunctionsize1 = pxodr1->GetRoadCount();
-    njunctionsize2 = pxodr2->GetRoadCount();
+    njunctionsize1 = pxodr1->GetJunctionCount();
+    njunctionsize2 = pxodr2->GetJunctionCount();
     int i;
     int i;
     int * pnid = new int[njunctionsize1 + njunctionsize2];
     int * pnid = new int[njunctionsize1 + njunctionsize2];
     std::shared_ptr<int> ppnid;ppnid.reset(pnid);
     std::shared_ptr<int> ppnid;ppnid.reset(pnid);
@@ -4965,6 +4997,10 @@ void MainWindow::on_actionEdit_Road_triggered()
     std::string strroadid = mpCBRoad->currentText().toStdString();
     std::string strroadid = mpCBRoad->currentText().toStdString();
     RoadEditDialog rd(&mxodr,strroadid,this);
     RoadEditDialog rd(&mxodr,strroadid,this);
     int res = rd.exec();
     int res = rd.exec();
+
+    updateCBRoad();
+    mbRefresh = true;
+    update();
 }
 }
 
 
 void MainWindow::on_actionAdd_Road_From_RTK_triggered()
 void MainWindow::on_actionAdd_Road_From_RTK_triggered()
@@ -5026,3 +5062,67 @@ void MainWindow::on_actionSplit_Road_triggered()
 {
 {
 
 
 }
 }
+
+void MainWindow::UpdateScene()
+{
+
+    int i;
+    int nsize = mvectorviewitem.size();
+    for(i=0;i<nsize;i++)
+    {
+        mpscene->removeItem(mvectorviewitem.at(i));
+        delete mvectorviewitem.at(i);
+    }
+    mvectorviewitem.clear();
+
+    nsize = mxodr.GetRoadCount();
+
+    std::vector<RoadDigit> xvectorrd;
+    for(i=0;i<nsize;i++)
+    {
+        RoadDigit xrd(mxodr.GetRoad(i),10.0);
+        xvectorrd.push_back(xrd);
+ //       UpdateSceneRoad(mxodr.GetRoad(i));
+//        qDebug("update road %d",i);
+    }
+    for(i=0;i<nsize;i++)
+    {
+        std::vector<QGraphicsPathItem *> xvectorlanepath = xodrscenfunc::GetRoadLaneItem(&(xvectorrd[i]));
+        int j;
+        int ncount = xvectorlanepath.size();
+        for(j=0;j<ncount;j++)
+        {
+            QGraphicsPathItem * pitem = xvectorlanepath[j];
+            pitem->setPos(mfViewMoveX +VIEW_WIDTH/2,-mfViewMoveY+VIEW_HEIGHT/2);
+            mpscene->addItem(pitem);
+            mvectorviewitem.push_back(pitem);
+        }
+    }
+
+    for(i=0;i<nsize;i++)
+    {
+        std::vector<QGraphicsPathItem *> xvectormarkpath = xodrscenfunc::GetRoadMarkItem(&(xvectorrd[i]));
+        int j;
+        int ncount = xvectormarkpath.size();
+        for(j=0;j<ncount;j++)
+        {
+            QGraphicsPathItem * pitem = xvectormarkpath[j];
+            pitem->setPos(mfViewMoveX +VIEW_WIDTH/2,-mfViewMoveY+VIEW_HEIGHT/2);
+            mpscene->addItem(pitem);
+            mvectorviewitem.push_back(pitem);
+        }
+    }
+    mbRefresh = false;
+}
+
+
+void MainWindow::onViewModeChange(int index)
+{
+    if(index == 1)
+    {
+       UpdateScene();
+    }
+    mnViewMode = index;
+    mbRefresh = true;
+    update();
+}

+ 15 - 0
src/tool/map_lanetoxodr/mainwindow.h

@@ -67,6 +67,10 @@ using namespace Eigen;
 
 
 #include "xodrmake.h"
 #include "xodrmake.h"
 
 
+#include "roaddigit.h"
+
+#include "xodrscenfunc.h"
+
 namespace Ui {
 namespace Ui {
 class MainWindow;
 class MainWindow;
 }
 }
@@ -88,6 +92,9 @@ private:
     QTimer *timer;
     QTimer *timer;
     QGraphicsScene *scene;
     QGraphicsScene *scene;
 
 
+    QGraphicsScene * mpscene;
+
+
 public:
 public:
     static void ComboToString(std::string strroadid,QComboBox * pCB);
     static void ComboToString(std::string strroadid,QComboBox * pCB);
 
 
@@ -185,6 +192,8 @@ private slots:
 
 
     void on_actionSplit_Road_triggered();
     void on_actionSplit_Road_triggered();
 
 
+    void onViewModeChange(int index);
+
 private:
 private:
 
 
 
 
@@ -385,6 +394,12 @@ private:
     void updateCBRoad();
     void updateCBRoad();
     void updateJunction();
     void updateJunction();
 
 
+    int mnViewMode = 0; //Use Scene
+
+    void UpdateScene();
+
+    std::vector<QGraphicsPathItem *> mvectorviewitem;
+
 
 
 };
 };
 
 

+ 18 - 3
src/tool/map_lanetoxodr/map_lanetoxodr.pro

@@ -33,10 +33,15 @@ SOURCES += \
     dialogeditlane.cpp \
     dialogeditlane.cpp \
     dialogeditroadmark.cpp \
     dialogeditroadmark.cpp \
     dialoglanefromrtk.cpp \
     dialoglanefromrtk.cpp \
+    dialogroadmerge.cpp \
+    dialogroadmirror.cpp \
+    dialogroadmove.cpp \
+    dialogroadrotate.cpp \
     dialogroadsplit.cpp \
     dialogroadsplit.cpp \
     ivxodrtool.cpp \
     ivxodrtool.cpp \
         main.cpp \
         main.cpp \
         mainwindow.cpp \
         mainwindow.cpp \
+    roaddigit.cpp \
     roadeditdialog.cpp \
     roadeditdialog.cpp \
     roadviewitem.cpp \
     roadviewitem.cpp \
     speeddialog.cpp \
     speeddialog.cpp \
@@ -69,7 +74,8 @@ SOURCES += \
     geofit.cpp \
     geofit.cpp \
     circlefitting.cpp \
     circlefitting.cpp \
     xodrfunc.cpp \
     xodrfunc.cpp \
-    xodrmake.cpp
+    xodrmake.cpp \
+    xodrscenfunc.cpp
 
 
 HEADERS += \
 HEADERS += \
     autoconnect.h \
     autoconnect.h \
@@ -77,10 +83,15 @@ HEADERS += \
     dialogeditlane.h \
     dialogeditlane.h \
     dialogeditroadmark.h \
     dialogeditroadmark.h \
     dialoglanefromrtk.h \
     dialoglanefromrtk.h \
+    dialogroadmerge.h \
+    dialogroadmirror.h \
+    dialogroadmove.h \
+    dialogroadrotate.h \
     dialogroadsplit.h \
     dialogroadsplit.h \
     ivxodrtool.h \
     ivxodrtool.h \
         mainwindow.h \
         mainwindow.h \
     rawtype.h \
     rawtype.h \
+    roaddigit.h \
     roadeditdialog.h \
     roadeditdialog.h \
     roadviewitem.h \
     roadviewitem.h \
     speeddialog.h \
     speeddialog.h \
@@ -91,7 +102,6 @@ HEADERS += \
     myview.h \
     myview.h \
     boost.h \
     boost.h \
     gps_type.h \
     gps_type.h \
-    linedata.h \
     OpenDrive/Junction.h \
     OpenDrive/Junction.h \
     OpenDrive/Lane.h \
     OpenDrive/Lane.h \
     OpenDrive/ObjectSignal.h \
     OpenDrive/ObjectSignal.h \
@@ -110,13 +120,18 @@ HEADERS += \
     geofit.h \
     geofit.h \
     circlefitting.h \
     circlefitting.h \
     xodrfunc.h \
     xodrfunc.h \
-    xodrmake.h
+    xodrmake.h \
+    xodrscenfunc.h
 
 
 FORMS += \
 FORMS += \
         dialogaddroadfromrtk.ui \
         dialogaddroadfromrtk.ui \
         dialogeditlane.ui \
         dialogeditlane.ui \
         dialogeditroadmark.ui \
         dialogeditroadmark.ui \
         dialoglanefromrtk.ui \
         dialoglanefromrtk.ui \
+        dialogroadmerge.ui \
+        dialogroadmirror.ui \
+        dialogroadmove.ui \
+        dialogroadrotate.ui \
         dialogroadsplit.ui \
         dialogroadsplit.ui \
         mainwindow.ui \
         mainwindow.ui \
         roadeditdialog.ui \
         roadeditdialog.ui \

+ 10 - 0
src/tool/map_lanetoxodr/myview.cpp

@@ -59,8 +59,13 @@ void MyView::zoomIn()
     int centery = (psV->value() + psV->size().height()/2)/beishu;
     int centery = (psV->value() + psV->size().height()/2)/beishu;
     int centerx = (psH->value() + psH->size().width()/2)/beishu;
     int centerx = (psH->value() + psH->size().width()/2)/beishu;
 
 
+#ifndef Android
     scale(1.1, 1.1);
     scale(1.1, 1.1);
     beishu *= 1.1;
     beishu *= 1.1;
+#else
+    scale(1.3, 1.3);
+    beishu *= 1.3;
+#endif
  //   centerOn(450, 700 - (200 / beishu));
  //   centerOn(450, 700 - (200 / beishu));
 
 
 
 
@@ -93,8 +98,13 @@ void MyView::zoomOut()
     int centery = (psV->value() + psV->size().height()/2)/beishu;
     int centery = (psV->value() + psV->size().height()/2)/beishu;
     int centerx = (psH->value() + psH->size().width()/2)/beishu;
     int centerx = (psH->value() + psH->size().width()/2)/beishu;
 
 
+#ifndef Android
     scale(1 / 1.1, 1 / 1.1);
     scale(1 / 1.1, 1 / 1.1);
     beishu /= 1.1;
     beishu /= 1.1;
+#else
+    scale(1 / 1.3, 1 / 1.3);
+    beishu /= 1.3;
+#endif
 //    centerOn(450, 700 - (200 / beishu));
 //    centerOn(450, 700 - (200 / beishu));
 
 
 
 

+ 265 - 0
src/tool/map_lanetoxodr/roaddigit.cpp

@@ -0,0 +1,265 @@
+#include "roaddigit.h"
+
+#include <math.h>
+#include "xodrfunc.h"
+
+
+RoadDigit::RoadDigit(Road * pRoad,double fspace)
+{
+    mpRoad = pRoad;
+    UpdateSpace(fspace);
+}
+
+std::vector<iv::RoadDigitUnit> * RoadDigit::GetRDU()
+{
+    return &mvectorRDU;
+}
+
+void RoadDigit::UpdateSpace(double fspace)
+{
+    if(mpRoad == 0)return;
+    CalcLine(fspace);
+    CalcLane();
+}
+
+void RoadDigit::CalcLine(double fspace)
+{
+    unsigned int j;
+    iv::RoadDigitUnit rdu;
+
+
+    bool bLastGeo = false;
+    for(j=0;j<mpRoad->GetGeometryBlockCount();j++)
+    {
+
+        GeometryBlock * pgeob = mpRoad->GetGeometryBlock(j);
+        double x,y;
+        double x_center,y_center;
+        double R;
+        RoadGeometry * pg;
+        GeometryArc * parc;
+        GeometryParamPoly3 * ppp3;
+        GeometrySpiral *pSpiral;
+        double rel_x,rel_y,rel_hdg;
+        pg = pgeob->GetGeometryAt(0);
+        x = pg->GetX();
+        y = pg->GetY();
+
+        if(j == (mpRoad->GetGeometryBlockCount() -1))
+        {
+            bLastGeo = true;
+        }
+
+        switch (pg->GetGeomType()) {
+        case 0:
+        {
+
+            rdu.mS = pg->GetS();
+            rdu.mX = pg->GetX();
+            rdu.mY = pg->GetY();
+            rdu.mfHdg = pg->GetHdg();
+            mvectorRDU.push_back(rdu);
+            int ncount = pg->GetLength() /fspace;
+            if(ncount<2)ncount = 2;
+            double fstep;
+            if(ncount > 0)fstep = pg->GetLength()/ncount;
+            int i;
+            if(bLastGeo )ncount = ncount+1;
+            for(i=1;i<ncount;i++)
+            {
+                double xtem,ytem;
+                xtem = x + (i*fstep)*cos(pg->GetHdg());
+                ytem = y + (i*fstep)*sin(pg->GetHdg());
+
+                rdu.mS = pg->GetS() + i*fstep;
+                rdu.mX = xtem;
+                rdu.mY = ytem;
+                rdu.mfHdg = pg->GetHdg();
+                mvectorRDU.push_back(rdu);
+
+            }
+        }
+            break;
+
+        case 1:
+            pSpiral = (GeometrySpiral * )pg;
+            {
+               int ncount = pSpiral->GetLength()/fspace;
+               if(ncount < 5)ncount = 5;
+               double sstep = pSpiral->GetLength()/((double)ncount);
+               int k;
+               double x0,y0,hdg0,s0;
+               x0 = pSpiral->GetX();
+               y0 = pSpiral->GetY();
+               s0 = pSpiral->GetS();
+               hdg0 = pSpiral->GetHdg() ;
+
+               rdu.mS = s0;
+               rdu.mX = x0;
+               rdu.mY = y0;
+               rdu.mfHdg = hdg0;
+               mvectorRDU.push_back(rdu);
+
+
+               pSpiral->GetCoords(s0,rel_x,rel_y,rel_hdg);
+
+               if(bLastGeo )ncount = ncount+1;
+               for(k=1;k<ncount;k++)
+               {
+                   pSpiral->GetCoords(s0+sstep*k,rel_x,rel_y,rel_hdg);
+
+                   rdu.mS = s0 + sstep * k;
+                   rdu.mX = rel_x;
+                   rdu.mY = rel_y;
+                   rdu.mfHdg = rel_hdg;
+                   mvectorRDU.push_back(rdu);
+
+            }
+        }
+
+            break;
+        case 2:
+            {
+            parc = (GeometryArc *)pg;
+            R = abs(1.0/parc->GetCurvature());
+            if(parc->GetCurvature() > 0)
+            {
+                x_center = pg->GetX() + R *cos(pg->GetHdg() + M_PI/2.0);
+                y_center = pg->GetY() + R * sin(pg->GetHdg() + M_PI/2.0);
+            }
+            else
+            {
+                x_center = pg->GetX() + R *cos(pg->GetHdg() -M_PI/2.0);
+                y_center = pg->GetY() + R * sin(pg->GetHdg() - M_PI/2.0);
+            }
+
+            rdu.mS = pg->GetS();
+            rdu.mX = pg->GetX();
+            rdu.mY = pg->GetY();
+            rdu.mfHdg = pg->GetHdg();
+            mvectorRDU.push_back(rdu);
+
+            int k;
+            int ncount = parc->GetLength() /fspace;
+            if(ncount< 5)ncount = 5;
+            double curv = parc->GetCurvature();
+            double arcrange = parc->GetLength()/R;
+            if((arcrange/0.1)>ncount)ncount = arcrange/0.1;
+            double hdgstep;
+            double hdg0 = parc->GetHdg();
+            double hdgnow = parc->GetHdg();
+            if(ncount > 0) hdgstep= (parc->GetLength()/R)/ncount;
+
+            double x_draw,y_draw;
+
+            if(curv > 0)
+            {
+                hdgnow =  hdg0 ;
+                x_draw = x_center + R *cos(hdgnow - M_PI/2.0);
+                y_draw = y_center + R * sin(hdgnow - M_PI/2.0);
+            }
+            else
+            {
+                hdgnow = hdg0;
+                x_draw = x_center + R *cos(hdgnow  + M_PI/2.0);
+                y_draw = y_center + R * sin(hdgnow + M_PI/2.0);
+            }
+
+
+            if(bLastGeo )ncount = ncount+1;
+            for(k=1;k<ncount;k++)
+            {
+
+
+                if(curv > 0)
+                {
+                    hdgnow =  hdg0 + k*hdgstep;
+                    x_draw = x_center + R *cos(hdgnow - M_PI/2.0);
+                    y_draw = y_center + R * sin(hdgnow - M_PI/2.0);
+                }
+                else
+                {
+                    hdgnow = hdg0 - k * hdgstep;
+                    x_draw = x_center + R *cos(hdgnow  + M_PI/2.0);
+                    y_draw = y_center + R * sin(hdgnow + M_PI/2.0);
+                }
+
+                rdu.mS = pg->GetS() + hdgstep * k* R;
+                rdu.mX = x_draw;
+                rdu.mY = y_draw;
+                rdu.mfHdg = hdgnow;
+                mvectorRDU.push_back(rdu);
+
+
+
+            }
+            }
+            break;
+        case 4:
+            {
+            ppp3 = (GeometryParamPoly3 * )pg;
+            int ncount = ppp3->GetLength() /fspace;
+            if(ncount < 5)ncount = 5;
+            double sstep;
+            if(ncount > 0)sstep = ppp3->GetLength()/ncount;
+            else sstep = 10000.0;
+            double s = 0;
+            double xtem,ytem;
+            xtem = ppp3->GetuA() +  ppp3->GetuB() * s +  ppp3->GetuC() * s*s +  ppp3->GetuD() * s*s*s;
+            ytem = ppp3->GetvA() + ppp3->GetvB() * s + ppp3->GetvC() * s*s + ppp3->GetvD() * s*s*s;
+            x = xtem*cos(ppp3->GetHdg()) - ytem * sin(ppp3->GetHdg()) + ppp3->GetX();
+            y = xtem*sin(ppp3->GetHdg()) + ytem * cos(ppp3->GetHdg()) + ppp3->GetY();
+            s = s+ sstep;
+
+            rdu.mS = pg->GetS();
+            rdu.mX = pg->GetX();
+            rdu.mY = pg->GetY();
+            rdu.mfHdg = pg->GetHdg();
+            mvectorRDU.push_back(rdu);
+
+            double flastx = pg->GetX();
+            double flasty = pg->GetY();
+            while(s <= ppp3->GetLength())
+            {
+
+                xtem = ppp3->GetuA() +  ppp3->GetuB() * s +  ppp3->GetuC() * s*s +  ppp3->GetuD() * s*s*s;
+                ytem = ppp3->GetvA() + ppp3->GetvB() * s + ppp3->GetvC() * s*s + ppp3->GetvD() * s*s*s;
+                x = xtem*cos(ppp3->GetHdg()) - ytem * sin(ppp3->GetHdg()) + ppp3->GetX();
+                y = xtem*sin(ppp3->GetHdg()) + ytem * cos(ppp3->GetHdg()) + ppp3->GetY();
+
+                rdu.mS = pg->GetS() + s;
+                rdu.mX = x;
+                rdu.mY = y;
+                rdu.mfHdg = xodrfunc::CalcHdg(QPointF(flastx,flasty),QPointF(x,y));
+                mvectorRDU.push_back(rdu);
+
+                s = s+ sstep;
+
+
+            }
+            }
+            break;
+        default:
+            break;
+        }
+
+//         painter->drawPoint((int)(x*mnfac),(int)(y*(-1.0*mnfac)));
+
+    }
+
+}
+
+void RoadDigit::CalcLane()
+{
+    int i;
+    int ncount = mvectorRDU.size();
+    for(i=0;i<ncount;i++)
+    {
+
+        std::vector<iv::LanePoint> xvectorlp2 = xodrfunc::GetAllLanePoint(mpRoad,mvectorRDU[i].mS,
+                                                                          mvectorRDU[i].mX,mvectorRDU[i].mY,mvectorRDU[i].mfHdg);
+        mvectorRDU[i].mvectorLanePoint = xvectorlp2;
+    }
+}
+
+

+ 56 - 0
src/tool/map_lanetoxodr/roaddigit.h

@@ -0,0 +1,56 @@
+#ifndef ROADDIGIT_H
+#define ROADDIGIT_H
+
+#include "OpenDrive/OpenDrive.h"
+
+#include <vector>
+
+#include "xodrfunc.h"
+
+namespace iv {
+
+
+struct lanexy
+{
+    int nLane;
+    double mX;
+    double mY;
+    double mCenterX;
+    double mCenterY;
+    int mType = 0;
+    int mnMarkColor;
+    int mMarkType = -1;  //if -1 no mark
+    int mnChange = 0;
+    std::vector<int> mvectorsignal;
+};
+
+struct RoadDigitUnit
+{
+    double mS;
+    double mX;
+    double mY;
+    double mfHdg;
+    std::vector<iv::LanePoint> mvectorLanePoint;
+};
+
+}
+
+class RoadDigit
+{
+public:
+    RoadDigit(Road * pRoad,double fspace);
+
+private:
+    std::vector<iv::RoadDigitUnit> mvectorRDU;
+    Road * mpRoad = 0;
+
+private:
+    void CalcLine(double fspace);
+    void CalcLane();
+
+public:
+    std::vector<iv::RoadDigitUnit> * GetRDU();
+    void UpdateSpace(double fspace);
+};
+
+#endif // ROADDIGIT_H

+ 152 - 6
src/tool/map_lanetoxodr/roadeditdialog.cpp

@@ -312,6 +312,19 @@ void RoadEditDialog::on_comboBox_Road_activated(const QString &arg1)
 
 
 }
 }
 
 
+bool RoadEditDialog::IsDrawMark(double s)
+{
+    const double dotdis = 10.0;
+    const double dotlen = 5.0;
+
+    double  y = fmod(s,dotdis);
+    if(y>dotlen)return true;
+    else
+    {
+        return false;
+    }
+}
+
 void RoadEditDialog::on_comboBox_Road_currentIndexChanged(int index)
 void RoadEditDialog::on_comboBox_Road_currentIndexChanged(int index)
 {
 {
     Road * pRoad = mpxodr->GetRoad(index);
     Road * pRoad = mpxodr->GetRoad(index);
@@ -332,10 +345,18 @@ void RoadEditDialog::on_comboBox_Road_currentIndexChanged(int index)
     }
     }
     mvectorroadview.clear();
     mvectorroadview.clear();
 
 
+    nsize = mvectorviewitem.size();
+    for(i=0;i<nsize;i++)
+    {
+        scene->removeItem(mvectorviewitem.at(i));
+        delete mvectorviewitem.at(i);
+    }
+    mvectorviewitem.clear();
+
 
 
     double froad_xmin,froad_ymin,froad_xmax,froad_ymax;
     double froad_xmin,froad_ymin,froad_xmax,froad_ymax;
     ServiceXODRTool.GetRoadMaxMin(pRoad,froad_xmin,froad_ymin,froad_xmax,froad_ymax);
     ServiceXODRTool.GetRoadMaxMin(pRoad,froad_xmin,froad_ymin,froad_xmax,froad_ymax);
-    roadviewitem * prvw = new roadviewitem(pRoad);
+//    roadviewitem * prvw = new roadviewitem(pRoad);
 
 
     int nfac;
     int nfac;
     int nkeep = 30;
     int nkeep = 30;
@@ -362,11 +383,11 @@ void RoadEditDialog::on_comboBox_Road_currentIndexChanged(int index)
     mfViewMoveX = 0 - froad_xmin - (froad_xmax - froad_xmin)/2.0;
     mfViewMoveX = 0 - froad_xmin - (froad_xmax - froad_xmin)/2.0;
     mfViewMoveY = 0 + froad_ymin  + (froad_ymax-froad_ymin)/2.0;
     mfViewMoveY = 0 + froad_ymin  + (froad_ymax-froad_ymin)/2.0;
 
 
-    prvw->setPos(mfViewMoveX,mfViewMoveY);
+//    prvw->setPos(mfViewMoveX,mfViewMoveY);
  //       prvw->setPos((froad_xmax - froad_xmin)/2.0, (froad_ymax-froad_ymin)/2.0);
  //       prvw->setPos((froad_xmax - froad_xmin)/2.0, (froad_ymax-froad_ymin)/2.0);
-    mvectorroadview.push_back(prvw);
-    prvw->setratio(1.0);
-    scene->addItem(prvw);
+//    mvectorroadview.push_back(prvw);
+ //   prvw->setratio(1.0);
+//    scene->addItem(prvw);
 
 
     mnSelGeo = -1;
     mnSelGeo = -1;
 
 
@@ -380,6 +401,30 @@ void RoadEditDialog::on_comboBox_Road_currentIndexChanged(int index)
         ui->comboBox_Geo->addItem(QString("Geo ")+QString::number(i));
         ui->comboBox_Geo->addItem(QString("Geo ")+QString::number(i));
     }
     }
 
 
+
+    RoadDigit xrd(mpCurRoad,0.1);
+
+    std::vector<QGraphicsPathItem *> xvectorlanepath = xodrscenfunc::GetRoadLaneItem(&xrd);
+    int j;
+    int ncount = xvectorlanepath.size();
+    for(j=0;j<ncount;j++)
+    {
+        QGraphicsPathItem * pitem = xvectorlanepath[j];
+        pitem->setPos(mfViewMoveX,mfViewMoveY);
+        scene->addItem(pitem);
+        mvectorviewitem.push_back(pitem);
+    }
+
+    std::vector<QGraphicsPathItem *> xvectormarkpath = xodrscenfunc::GetRoadMarkItem(&xrd);
+    ncount = xvectormarkpath.size();
+    for(j=0;j<ncount;j++)
+    {
+        QGraphicsPathItem * pitem = xvectormarkpath[j];
+        pitem->setPos(mfViewMoveX,mfViewMoveY);
+        scene->addItem(pitem);
+        mvectorviewitem.push_back(pitem);
+    }
+
     update();
     update();
 }
 }
 
 
@@ -449,5 +494,106 @@ void RoadEditDialog::on_pushButton_RoadSplit_clicked()
 
 
     DialogRoadSplit roadsplit(mpCurRoad,mpxodr,this);
     DialogRoadSplit roadsplit(mpCurRoad,mpxodr,this);
     roadsplit.exec();
     roadsplit.exec();
-    on_comboBox_Road_currentIndexChanged(ui->comboBox_Road->currentIndex());
+
+    unsigned int ncurindex = ui->comboBox_Road->currentIndex();
+    ui->comboBox_Road->clear();
+    int i;
+    int nroadcount = mpxodr->GetRoadCount();
+    for(i=0;i<nroadcount;i++)
+    {
+        const char * strname = mpxodr->GetRoad(i)->GetRoadId().data();
+        ui->comboBox_Road->addItem(strname);
+
+    }
+    on_comboBox_Road_currentIndexChanged(ncurindex);
+}
+
+void RoadEditDialog::on_pushButton_RoadMerge_clicked()
+{
+    DialogRoadMerge roadmerge(mpxodr,this);
+    roadmerge.exec();
+
+    unsigned int ncurindex = ui->comboBox_Road->currentIndex();
+    ui->comboBox_Road->clear();
+    int i;
+    int nroadcount = mpxodr->GetRoadCount();
+    for(i=0;i<nroadcount;i++)
+    {
+        const char * strname = mpxodr->GetRoad(i)->GetRoadId().data();
+        ui->comboBox_Road->addItem(strname);
+
+    }
+    on_comboBox_Road_currentIndexChanged(ncurindex);
+}
+
+void RoadEditDialog::on_pushButton_MoveRoad_clicked()
+{
+    if(mpCurRoad == 0)
+    {
+        QMessageBox::warning(this,"Warning","Not Select Road");
+        return;
+    }
+
+    DialogRoadMove roadmove(mpxodr,mpCurRoad,this);
+    roadmove.exec();
+
+    unsigned int ncurindex = ui->comboBox_Road->currentIndex();
+    ui->comboBox_Road->clear();
+    int i;
+    int nroadcount = mpxodr->GetRoadCount();
+    for(i=0;i<nroadcount;i++)
+    {
+        const char * strname = mpxodr->GetRoad(i)->GetRoadId().data();
+        ui->comboBox_Road->addItem(strname);
+
+    }
+    on_comboBox_Road_currentIndexChanged(ncurindex);
+}
+
+void RoadEditDialog::on_pushButton_RotateRoad_clicked()
+{
+    if(mpCurRoad == 0)
+    {
+        QMessageBox::warning(this,"Warning","Not Select Road");
+        return;
+    }
+
+    DialogRoadRotate roadrotate(mpxodr,mpCurRoad,this);
+    roadrotate.exec();
+
+    unsigned int ncurindex = ui->comboBox_Road->currentIndex();
+    ui->comboBox_Road->clear();
+    int i;
+    int nroadcount = mpxodr->GetRoadCount();
+    for(i=0;i<nroadcount;i++)
+    {
+        const char * strname = mpxodr->GetRoad(i)->GetRoadId().data();
+        ui->comboBox_Road->addItem(strname);
+
+    }
+    on_comboBox_Road_currentIndexChanged(ncurindex);
+}
+
+void RoadEditDialog::on_pushButton_MirrorRoad_clicked()
+{
+    if(mpCurRoad == 0)
+    {
+        QMessageBox::warning(this,"Warning","Not Select Road");
+        return;
+    }
+
+    DialogRoadMirror roadmirror(mpxodr,mpCurRoad,this);
+    roadmirror.exec();
+
+    unsigned int ncurindex = ui->comboBox_Road->currentIndex();
+    ui->comboBox_Road->clear();
+    int i;
+    int nroadcount = mpxodr->GetRoadCount();
+    for(i=0;i<nroadcount;i++)
+    {
+        const char * strname = mpxodr->GetRoad(i)->GetRoadId().data();
+        ui->comboBox_Road->addItem(strname);
+
+    }
+    on_comboBox_Road_currentIndexChanged(ncurindex);
 }
 }

+ 20 - 0
src/tool/map_lanetoxodr/roadeditdialog.h

@@ -15,6 +15,13 @@
 #include "dialogeditroadmark.h"
 #include "dialogeditroadmark.h"
 #include "dialoglanefromrtk.h"
 #include "dialoglanefromrtk.h"
 #include "dialogroadsplit.h"
 #include "dialogroadsplit.h"
+#include "dialogroadmerge.h"
+#include "dialogroadmove.h"
+#include "dialogroadrotate.h"
+#include "dialogroadmirror.h"
+
+#include "roaddigit.h"
+#include "xodrscenfunc.h"
 
 
 namespace Ui {
 namespace Ui {
 class RoadEditDialog;
 class RoadEditDialog;
@@ -48,6 +55,17 @@ private slots:
 
 
     void on_pushButton_RoadSplit_clicked();
     void on_pushButton_RoadSplit_clicked();
 
 
+    void on_pushButton_RoadMerge_clicked();
+
+    void on_pushButton_MoveRoad_clicked();
+
+    void on_pushButton_RotateRoad_clicked();
+
+    void on_pushButton_MirrorRoad_clicked();
+
+private:
+    bool IsDrawMark(double s);
+
 private:
 private:
     Ui::RoadEditDialog *ui;
     Ui::RoadEditDialog *ui;
     OpenDrive * mpxodr;
     OpenDrive * mpxodr;
@@ -64,6 +82,8 @@ private:
 
 
     std::vector<roadviewitem *> mvectorroadview;
     std::vector<roadviewitem *> mvectorroadview;
 
 
+    std::vector<QGraphicsPathItem *> mvectorviewitem;
+
     double mfViewMoveX = 0;
     double mfViewMoveX = 0;
     double mfViewMoveY = 0;
     double mfViewMoveY = 0;
 };
 };

+ 53 - 1
src/tool/map_lanetoxodr/roadeditdialog.ui

@@ -262,7 +262,7 @@
   <widget class="QPushButton" name="pushButton_RoadSplit">
   <widget class="QPushButton" name="pushButton_RoadSplit">
    <property name="geometry">
    <property name="geometry">
     <rect>
     <rect>
-     <x>878</x>
+     <x>1013</x>
      <y>210</y>
      <y>210</y>
      <width>181</width>
      <width>181</width>
      <height>31</height>
      <height>31</height>
@@ -272,6 +272,58 @@
     <string>Road Split</string>
     <string>Road Split</string>
    </property>
    </property>
   </widget>
   </widget>
+  <widget class="QPushButton" name="pushButton_RoadMerge">
+   <property name="geometry">
+    <rect>
+     <x>1010</x>
+     <y>283</y>
+     <width>191</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Road Merge</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_MoveRoad">
+   <property name="geometry">
+    <rect>
+     <x>1010</x>
+     <y>356</y>
+     <width>191</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Move Road</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_RotateRoad">
+   <property name="geometry">
+    <rect>
+     <x>1010</x>
+     <y>431</y>
+     <width>191</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Rotate Road</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_MirrorRoad">
+   <property name="geometry">
+    <rect>
+     <x>1010</x>
+     <y>506</y>
+     <width>191</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Mirror Road</string>
+   </property>
+  </widget>
  </widget>
  </widget>
  <resources/>
  <resources/>
  <connections/>
  <connections/>

+ 2 - 0
src/tool/map_lanetoxodr/roadviewitem.cpp

@@ -12,6 +12,8 @@ roadviewitem::roadviewitem(Road * pRoad)
 {
 {
     mpRoad = pRoad;
     mpRoad = pRoad;
     mbNeedCalc = true;
     mbNeedCalc = true;
+    QGraphicsPathItem x;
+
 }
 }
 
 
 QRectF roadviewitem::boundingRect() const
 QRectF roadviewitem::boundingRect() const

+ 2 - 2
src/tool/map_lanetoxodr/roadviewitem.h

@@ -101,8 +101,8 @@ private:
     bool mbShowLane = true;
     bool mbShowLane = true;
     bool mbShowLine = false;
     bool mbShowLine = false;
     bool mbShowRoadID = true;
     bool mbShowRoadID = true;
-
-    bool IsDrawMark(double s);
+public:
+    static bool IsDrawMark(double s);
 };
 };
 
 
 #endif // ROADVIEWITEM_H
 #endif // ROADVIEWITEM_H

+ 154 - 1
src/tool/map_lanetoxodr/xodrfunc.cpp

@@ -601,6 +601,7 @@ std::vector<iv::LanePoint> xodrfunc::GetAllLanePoint(Road *pRoad,  const double
     int nLSCount = pRoad->GetLaneSectionCount();
     int nLSCount = pRoad->GetLaneSectionCount();
     double s_section = 0;
     double s_section = 0;
 
 
+
     std::vector<iv::LanePoint> xvectorlanepoint;
     std::vector<iv::LanePoint> xvectorlanepoint;
     for(i=0;i<nLSCount;i++)
     for(i=0;i<nLSCount;i++)
     {
     {
@@ -627,7 +628,7 @@ std::vector<iv::LanePoint> xodrfunc::GetAllLanePoint(Road *pRoad,  const double
             int nlanetype = 2; //driving
             int nlanetype = 2; //driving
             int nlanecolor = 0;
             int nlanecolor = 0;
             int k;
             int k;
-            double s_lane = 0;
+            double s_lane = s-s_section;
             for(k=0;k<pLane->GetLaneRoadMarkCount();k++)
             for(k=0;k<pLane->GetLaneRoadMarkCount();k++)
             {
             {
                  LaneRoadMark * plrm = pLane->GetLaneRoadMark(k);
                  LaneRoadMark * plrm = pLane->GetLaneRoadMark(k);
@@ -638,6 +639,13 @@ std::vector<iv::LanePoint> xodrfunc::GetAllLanePoint(Road *pRoad,  const double
                          continue;
                          continue;
                      }
                      }
                  }
                  }
+                 else
+                 {
+                     if(s_lane<plrm->GetS())
+                     {
+                         continue;
+                     }
+                 }
                  if(plrm->GetType() == "solid")
                  if(plrm->GetType() == "solid")
                  {
                  {
                      nlanemarktype = 0;
                      nlanemarktype = 0;
@@ -870,3 +878,148 @@ double xodrfunc::GetAcurateDis(const double x, const double y, Road *pRoad,  con
 
 
 
 
 }
 }
+
+
+
+int xodrfunc::GetLineXY(GeometryLine *pline, double soff, double &x, double &y, double &hdg)
+{
+    if(soff<0)return -1;
+
+    hdg = pline->GetHdg();
+    x = pline->GetX() + soff*cos(hdg);
+    y = pline->GetY() + soff*sin(hdg);
+    return 0;
+}
+
+Road * xodrfunc::GetRoadByID(OpenDrive * pxodr,std::string strroadid)
+{
+    Road * pRoad = 0;
+    int nroadcount = pxodr->GetRoadCount();
+    int i;
+    for(i=0;i<nroadcount;i++)
+    {
+        if(pxodr->GetRoad(i)->GetRoadId() == strroadid)
+        {
+            pRoad = pxodr->GetRoad(i);
+            break;
+        }
+    }
+    return pRoad;
+}
+
+int xodrfunc::GetSpiralXY(GeometrySpiral *pspira, double soff, double &x, double &y, double &hdg)
+{
+    pspira->GetCoords(pspira->GetS() + soff,x,y,hdg);
+    return 0;
+}
+
+int xodrfunc::GetArcXY(GeometryArc *parc, double soff, double &x, double &y, double &hdg)
+{
+    if(parc->GetCurvature() == 0)return -1;
+    double R = fabs(1.0/parc->GetCurvature());
+
+    //calculate arc center
+    double x_center = parc->GetX() + (1.0/parc->GetCurvature()) * cos(parc->GetHdg() + M_PI/2.0);
+    double y_center = parc->GetY() + (1.0/parc->GetCurvature()) * sin(parc->GetHdg()+ M_PI/2.0);
+
+    double arcdiff = soff/R;
+
+    if(parc->GetCurvature() > 0)
+    {
+        x = x_center + R * cos(parc->GetHdg() + arcdiff - M_PI/2.0);
+        y = y_center + R * sin(parc->GetHdg() + arcdiff - M_PI/2.0);
+        hdg = parc->GetHdg() + arcdiff;
+    }
+    else
+    {
+        x = x_center + R * cos(parc->GetHdg() -arcdiff + M_PI/2.0);
+        y = y_center + R * sin(parc->GetHdg() -arcdiff + M_PI/2.0);
+        hdg = parc->GetHdg() - arcdiff;
+    }
+
+
+
+    return 0;
+}
+
+int xodrfunc::GetParamPoly3XY(GeometryParamPoly3 *pparam3d, double soff, double &x, double &y, double &hdg)
+{
+    double xtem,ytem;
+    double ua,ub,uc,ud,va,vb,vc,vd;
+    ua = pparam3d->GetuA();ub= pparam3d->GetuB();uc= pparam3d->GetuC();ud = pparam3d->GetuD();
+    va = pparam3d->GetvA();vb= pparam3d->GetvB();vc= pparam3d->GetvC();vd = pparam3d->GetvD();
+//        xtem = parc->GetuA() + parc->GetuB() * s * len + parc->GetuC() * s*s *pow(len,2) + parc->GetuD() * s*s*s *pow(len,3);
+//        ytem = parc->GetvA() + parc->GetvB() * s* len + parc->GetvC() * s*s *pow(len,2) + parc->GetvD() * s*s*s *pow(len,3);
+    xtem = ua + ub * soff  + uc * soff * soff  + ud * soff *soff*soff ;
+    ytem = va + vb * soff + vc * soff*soff  + vd * soff*soff*soff ;
+    x = xtem*cos(pparam3d->GetHdg()) - ytem * sin(pparam3d->GetHdg()) + pparam3d->GetX();
+    y = xtem*sin(pparam3d->GetHdg()) + ytem * cos(pparam3d->GetHdg()) + pparam3d->GetY();
+    if(soff<0.3)hdg = pparam3d->GetHdg();
+    else
+    {
+        double soff1 = soff - 0.1;
+        double x1,y1;
+        xtem = ua + ub * soff1  + uc * soff1 * soff1  + ud * soff1 *soff1*soff1 ;
+        ytem = va + vb * soff1 + vc * soff1*soff1  + vd * soff1*soff1*soff1 ;
+        x1 = xtem*cos(pparam3d->GetHdg()) - ytem * sin(pparam3d->GetHdg()) + pparam3d->GetX();
+        y1 = xtem*sin(pparam3d->GetHdg()) + ytem * cos(pparam3d->GetHdg()) + pparam3d->GetY();
+        hdg = CalcHdg(QPointF(x1,y1),QPointF(x,y));
+    }
+    return 0;
+}
+
+int xodrfunc::GetRoadXYByS(Road *pRoad, const double s, double &x, double &y, double &hdg)
+{
+    if(s<0)return -1;
+    if(s>(pRoad->GetRoadLength()+0.1))return -2;
+    if(pRoad == 0)return -3;
+    if(pRoad->GetGeometryBlockCount()<1)return -4;
+    int i;
+    int nroadgeosize = pRoad->GetGeometryBlockCount();
+    RoadGeometry * pgeosel = pRoad->GetGeometryBlock(nroadgeosize -1)->GetGeometryAt(0);
+    for(i=0;i<(nroadgeosize-1);i++)
+    {
+        if(s<pRoad->GetGeometryBlock(i+1)->GetGeometryAt(0)->GetS())
+        {
+
+            pgeosel = pRoad->GetGeometryBlock(0)->GetGeometryAt(0);
+            break;
+        }
+    }
+
+
+    switch (pgeosel->GetGeomType()) {
+    case 0:
+        return GetLineXY((GeometryLine *)pgeosel,(s-pgeosel->GetS()),x,y,hdg);
+        break;
+    case 1:
+        return GetSpiralXY((GeometrySpiral *)pgeosel,(s-pgeosel->GetS()),x,y,hdg);
+        break;
+    case 2:
+        return GetArcXY((GeometryArc *)pgeosel,(s-pgeosel->GetS()),x,y,hdg);
+
+        break;
+    case 3:
+        break;
+    case 4:
+        return GetParamPoly3XY((GeometryParamPoly3 *)pgeosel,(s-pgeosel->GetS()),x,y,hdg);
+        break;
+    default:
+        break;
+    }
+    return -5;
+}
+
+int xodrfunc::GetRoadIndex(OpenDrive * pxodr, Road *pRoad)
+{
+    int nroadcount = pxodr->GetRoadCount();
+    int i;
+    for(i=0;i<nroadcount;i++)
+    {
+        if(pxodr->GetRoad(i) == pRoad)
+        {
+            return i;
+        }
+    }
+    return -1;
+}

+ 11 - 0
src/tool/map_lanetoxodr/xodrfunc.h

@@ -49,6 +49,17 @@ public:
                                 const double neary,const double nearhead,int * pnlane= 0);
                                 const double neary,const double nearhead,int * pnlane= 0);
 
 
     static std::vector<iv::LanePoint> GetAllLanePoint(Road * pRoad,const double s,const double x, const double y,const double fhdg);
     static std::vector<iv::LanePoint> GetAllLanePoint(Road * pRoad,const double s,const double x, const double y,const double fhdg);
+
+public:
+    static Road * GetRoadByID(OpenDrive * pxodr,std::string strroadid);
+    static int GetRoadXYByS(Road * pRoad,const double s,double &x, double & y, double & hdg);
+
+    static int GetLineXY(GeometryLine * pline,double soff,double &x, double & y, double & hdg);
+    static int GetSpiralXY(GeometrySpiral * pspira,double soff,double &x, double & y, double & hdg);
+    static int GetArcXY(GeometryArc * parc,double soff,double &x, double & y, double & hdg);
+    static int GetParamPoly3XY(GeometryParamPoly3 * pparam3d,double soff,double &x, double & y, double & hdg);
+
+    static int GetRoadIndex(OpenDrive * pxodr, Road * pRoad);
 };
 };
 
 
 #endif // XODRFUNC_H
 #endif // XODRFUNC_H

+ 226 - 0
src/tool/map_lanetoxodr/xodrscenfunc.cpp

@@ -0,0 +1,226 @@
+#include "xodrscenfunc.h"
+
+xodrscenfunc::xodrscenfunc()
+{
+
+}
+
+std::vector<QGraphicsPathItem *> xodrscenfunc::GetRoadLaneItem(RoadDigit *prd)
+{
+    std::vector<QGraphicsPathItem *> xvectorgrapath;
+    std::vector<iv::RoadDigitUnit> * pvectorrdu =  prd->GetRDU();
+    int nsize = pvectorrdu->size();
+    int i;
+    for(i=0;i<(nsize-1);i++)
+    {
+        std::vector<iv::LanePoint> xvepre = pvectorrdu->at(i).mvectorLanePoint;
+        std::vector<iv::LanePoint> xvenxt = pvectorrdu->at(i+1).mvectorLanePoint;
+        if((xvepre.size()<2)||(xvenxt.size()<2)||(xvenxt.size() != xvepre.size()))
+        {
+            continue;
+        }
+        unsigned int k;
+        for(k=0;k<(xvepre.size()-1);k++)
+        {
+            QPainterPath xpath;
+            xpath.moveTo(xvepre.at(k).mfX,xvepre.at(k).mfY*(-1));
+            xpath.lineTo(xvenxt.at(k).mfX,xvenxt.at(k).mfY*(-1));
+            xpath.lineTo(xvenxt.at(k+1).mfX,xvenxt.at(k+1).mfY*(-1));
+            xpath.lineTo(xvepre.at(k+1).mfX,xvepre.at(k+1).mfY*(-1));
+            xpath.closeSubpath();
+            QGraphicsPathItem * pitem = new QGraphicsPathItem;
+            pitem->setPath(xpath);
+//            pitem->setPos(mfViewMoveX +VIEW_WIDTH/2,-mfViewMoveY+VIEW_HEIGHT/2);
+            int nlanetype = xvepre.at(k).mnlanetype;
+            if(xvepre.at(k).mnlane<=0)nlanetype = xvepre.at(k+1).mnlanetype;
+            QColor brushcolor = Qt::darkGray;
+            switch (nlanetype) {
+            case 2:
+                brushcolor = Qt::darkGray;
+                break;
+            case 8:
+                brushcolor = Qt::red;
+                break;
+            case 9:
+                brushcolor = QColor(0xB2,0xB2,0xD6);
+                break;
+            default:
+                brushcolor = Qt::darkGreen;
+                break;
+            }
+            pitem->setBrush(brushcolor);
+            pitem->setPen(QPen(brushcolor,0.001));
+  //          mpscene->addItem(pitem);
+            xvectorgrapath.push_back(pitem);
+        }
+    }
+
+    return xvectorgrapath;
+
+
+}
+
+std::vector<QGraphicsPathItem *> xodrscenfunc::GetRoadMarkItem(RoadDigit *prd)
+{
+    std::vector<QGraphicsPathItem *> xvectorgrapath;
+    std::vector<iv::RoadDigitUnit> * pvectorrdu =  prd->GetRDU();
+    int nsize = pvectorrdu->size();
+    int i;
+    double flmw = 0.15;
+
+    for(i=0;i<(nsize-1);i++)
+    {
+        std::vector<iv::LanePoint> xvepre = pvectorrdu->at(i).mvectorLanePoint;
+        std::vector<iv::LanePoint> xvenxt = pvectorrdu->at(i+1).mvectorLanePoint;
+        if(xvenxt.size() != xvepre.size())
+        {
+            continue;
+        }
+        unsigned int k;
+        int noldmarktype = -1;
+        double foldx1,foldy1,foldx2,foldy2;
+//        double foldx1_2,foldy1_2,foldx2_2,foldy2_2;
+        double fx1,fx2,fx3,fx4,fy1,fy2,fy3,fy4;
+        for(k=0;k<(xvepre.size());k++)
+        {
+            QPainterPath xpath;
+            int ncolor = -3;
+            int nmarktype = xvepre[k].mnlanemarktype;
+            if(nmarktype >= 0)
+            {
+                if(nmarktype<2)
+                {
+                    if((nmarktype == 0)||(IsDrawMark(xvepre[k].mS)))
+                    {
+                        fx1 = xvepre[k].mfX + 0.5*flmw * cos(xvepre[k].mfhdg - M_PI/2.0);
+                        fy1 = (xvepre[k].mfY+0.5*flmw * sin(xvepre[k].mfhdg - M_PI/2.0))*(-1.0);
+                        fx2 = xvenxt[k].mfX+ 0.5*flmw * cos(xvenxt[k].mfhdg - M_PI/2.0);
+                        fy2 = (xvenxt[k].mfY+0.5*flmw * sin(xvenxt[k].mfhdg - M_PI/2.0))*(-1.0);
+                        fx3 = xvenxt[k].mfX + 0.5*flmw * cos(xvenxt[k].mfhdg + M_PI/2.0);
+                        fy3 = (xvenxt[k].mfY+0.5*flmw * sin(xvenxt[k].mfhdg + M_PI/2.0))*(-1.0);
+                        fx4 = xvepre[k].mfX+ 0.5*flmw * cos(xvepre[k].mfhdg + M_PI/2.0);
+                        fy4 = (xvepre[k].mfY+0.5*flmw * sin(xvepre[k].mfhdg + M_PI/2.0))*(-1.0);
+                        if(noldmarktype != nmarktype)
+                        {
+                        xpath.moveTo(fx1,fy1);
+                        xpath.lineTo(fx2,fy2);
+                        xpath.lineTo(fx3,fy3);
+                        xpath.lineTo(fx4,fy4);
+                        xpath.closeSubpath();
+                        }
+                        else
+                        {
+                            xpath.moveTo(foldx1,foldy1);
+                            xpath.lineTo(fx2,fy2);
+                            xpath.lineTo(fx3,fy3);
+                            xpath.lineTo(foldx2,foldy2);
+                            xpath.closeSubpath();
+                            foldx1 = fx2;
+                            foldy1 = fy2;
+                            foldx2 = fx3;
+                            foldy2 = fy3;
+                            noldmarktype = nmarktype;
+                        }
+                        ncolor = xvepre[k].mnlanecolor;
+
+
+                    }
+                }
+                else
+                {
+                    if((nmarktype == 2)||(nmarktype == 3)||(IsDrawMark(xvepre[k].mS)))
+                    {
+                        xpath.moveTo(xvepre[k].mfX + flmw * cos(xvenxt[k].mfhdg + M_PI/2.0),
+                                     (xvepre[k].mfY+flmw * sin(xvenxt[k].mfhdg + M_PI/2.0))*(-1.0));
+                        xpath.lineTo(xvenxt[k].mfX+ flmw * cos(xvepre[k].mfhdg + M_PI/2.0),
+                                     (xvenxt[k].mfY+flmw * sin(xvepre[k].mfhdg + M_PI/2.0))*(-1.0));
+
+                        xpath.lineTo(xvenxt[k].mfX + 2*flmw * cos(xvenxt[k].mfhdg + M_PI/2.0),
+                                     (xvenxt[k].mfY+2*flmw * sin(xvenxt[k].mfhdg + M_PI/2.0))*(-1.0));
+                        xpath.lineTo(xvepre[k].mfX+ 2*flmw * cos(xvepre[k].mfhdg + M_PI/2.0),
+                                     (xvepre[k].mfY+2*flmw * sin(xvepre[k].mfhdg + M_PI/2.0))*(-1.0));
+                        xpath.closeSubpath();
+                        ncolor = xvepre[k].mnlanecolor;
+                    }
+                    if((nmarktype == 2)||(nmarktype == 4)||(IsDrawMark(xvepre[k].mS)))
+                    {
+                        xpath.moveTo(xvepre[k].mfX + flmw * cos(xvenxt[k].mfhdg - M_PI/2.0),
+                                     (xvepre[k].mfY+flmw * sin(xvenxt[k].mfhdg - M_PI/2.0))*(-1.0));
+                        xpath.lineTo(xvenxt[k].mfX+ flmw * cos(xvepre[k].mfhdg - M_PI/2.0),
+                                     (xvenxt[k].mfY+flmw * sin(xvepre[k].mfhdg - M_PI/2.0))*(-1.0));
+
+                        xpath.lineTo(xvenxt[k].mfX + 2*flmw * cos(xvenxt[k].mfhdg - M_PI/2.0),
+                                     (xvenxt[k].mfY+2*flmw * sin(xvenxt[k].mfhdg - M_PI/2.0))*(-1.0));
+                        xpath.lineTo(xvepre[k].mfX+ 2*flmw * cos(xvepre[k].mfhdg - M_PI/2.0),
+                                     (xvepre[k].mfY+2*flmw * sin(xvepre[k].mfhdg - M_PI/2.0))*(-1.0));
+                        xpath.closeSubpath();
+                        ncolor = xvepre[k].mnlanecolor;
+                    }
+
+                }
+            }
+
+            if(ncolor != -3)
+            {
+                QGraphicsPathItem * pitem = new QGraphicsPathItem;
+                pitem->setPath(xpath);
+                QColor brushcolor;
+                switch (ncolor) {
+                case 0:
+                    brushcolor = Qt::white;
+                    break;
+                case 1:
+                    brushcolor = Qt::blue;
+                    break;
+                case 2:
+                    brushcolor = Qt::green;
+                    break;
+                case 3:
+                    brushcolor = Qt::red;
+                    break;
+                case 4:
+                    brushcolor = Qt::white;
+                    break;
+                case 5:
+                    brushcolor = Qt::yellow;
+                    break;
+                case 6:
+                    brushcolor = Qt::yellow; //orange use yellow replace
+                    break;
+                default:
+                    brushcolor = Qt::white;
+                    break;
+                }
+                pitem->setBrush(brushcolor);
+                pitem->setPen(QPen(brushcolor,0.001));
+//                pitem->setPos(mfViewMoveX + VIEW_WIDTH/2,-mfViewMoveY +VIEW_HEIGHT/2);
+//                mpscene->addItem(pitem);
+                xvectorgrapath.push_back(pitem);
+            }
+            else
+            {
+                noldmarktype = -1;
+            }
+
+
+        }
+
+    }
+
+    return xvectorgrapath;
+
+
+}
+
+bool xodrscenfunc::IsDrawMark(double s)
+{
+    const double dotdis = 10.0;
+    const double dotlen = 5.0;
+
+    double  y = fmod(s,dotdis);
+    if(y>dotlen)return true;
+    else
+    {
+        return false;
+    }
+}

+ 26 - 0
src/tool/map_lanetoxodr/xodrscenfunc.h

@@ -0,0 +1,26 @@
+#ifndef XODRSCENFUNC_H
+#define XODRSCENFUNC_H
+
+#include <QGraphicsScene>
+
+#include <QGraphicsPathItem>
+
+#include "xodrmake.h"
+
+#include "roaddigit.h"
+
+
+class xodrscenfunc
+{
+public:
+    xodrscenfunc();
+
+public:
+    static std::vector<QGraphicsPathItem *> GetRoadLaneItem(RoadDigit * prd);
+    static std::vector<QGraphicsPathItem *> GetRoadMarkItem(RoadDigit * prd);
+
+public:
+    static bool IsDrawMark(double s);
+};
+
+#endif // XODRSCENFUNC_H

+ 296 - 0
src/tool/map_lanetoxodr/xvmainwindow.cpp

@@ -0,0 +1,296 @@
+#include "xvmainwindow.h"
+#include "ui_xvmainwindow.h"
+
+#include <QMessageBox>
+#include <QFileDialog>
+
+#include <string.h>
+
+#include "xodrfunc.h"
+#include "roaddigit.h"
+#include "xodrscenfunc.h"
+
+#define VIEW_WIDTH 2000
+#define VIEW_HEIGHT 2000
+
+static bool IsNaN(double dat)
+{
+ qint64 & ref=*(qint64 *)&dat;
+ return (ref&0x7FF0000000000000) == 0x7FF0000000000000 && (ref&0xfffffffffffff)!=0;
+}
+
+
+XVMainWindow::XVMainWindow(QWidget *parent) :
+    QMainWindow(parent),
+    ui(new Ui::XVMainWindow)
+{
+    ui->setupUi(this);
+
+    myview = new MyView(this);
+    myview->setObjectName(QStringLiteral("graphicsView"));
+    myview->setGeometry(QRect(30, 30, 600, 600));
+
+    connect(myview,SIGNAL(dbclickxy(double,double)),this,SLOT(onClickXY(double,double)));
+
+
+    myview->setCacheMode(myview->CacheBackground);
+
+    mpscene = new  QGraphicsScene(0,0,VIEW_WIDTH,VIEW_HEIGHT);
+    mpscene->setBackgroundBrush(Qt::darkGreen);
+
+    myview->setScene(mpscene);
+
+    setWindowTitle("ADC OpenDrive Viewer");
+}
+
+XVMainWindow::~XVMainWindow()
+{
+    delete ui;
+}
+
+void XVMainWindow::resizeEvent(QResizeEvent *event)
+{
+    qDebug("resize");
+    QSize sizemain = ui->centralwidget->size();
+    qDebug("size x = %d y=%d",sizemain.width(),sizemain.height());
+    myview->setGeometry(0,30,sizemain.width(),sizemain.height()-30);
+}
+
+void XVMainWindow::on_actionLoad_triggered()
+{
+
+    if(mxodr.GetRoadCount() > 0)
+    {
+        QMessageBox::StandardButton button;
+        char strquest[256];
+        snprintf(strquest,256,"Do you Want to Load New File ?");
+        button=QMessageBox::question(this,"Move",strquest,QMessageBox::Yes|QMessageBox::No);
+        if(button==QMessageBox::No)
+        {
+            return;
+        }
+        else if(button==QMessageBox::Yes)
+        {
+
+        }
+    }
+
+
+#ifndef Android
+    QString strpath = QFileDialog::getOpenFileName(this,"Load XODR",".","*.xodr");
+    if(strpath.isEmpty())return;
+#else
+//    QMessageBox::warning(this,"warning","no file dialog.",QMessageBox::YesAll);
+    QString strpath = "/storage/emulated/0/map.xodr";
+
+
+#endif
+    LoadXODR(strpath);
+    UpdateScene();
+}
+
+void XVMainWindow::LoadXODR(QString strpath)
+{
+    mxodr.Clear();
+    OpenDrive * pxodr = &mxodr;  //because add to xodr,so don't delete
+    OpenDriveXmlParser x(pxodr);
+    if(!x.ReadFile(strpath.toStdString()))
+    {
+        QMessageBox::warning(this,"warn","Can't  load xodr file.");
+        return;
+    }
+
+    int nroadnum = pxodr->GetRoadCount();
+    int i;
+    double froadlen = 0;
+    for(i=0;i<nroadnum;i++)
+    {
+        Road * pRoad = pxodr->GetRoad(i);
+        if(IsNaN(pRoad->GetRoadLength()))
+        {
+            pxodr->DeleteRoad(i);
+            i--;
+            nroadnum--;
+            qDebug("delete road %s because length is NaN",pRoad->GetRoadId().data());
+        }
+        else
+        {
+            froadlen = froadlen + pRoad->GetRoadLength();
+        }
+    }
+
+    char strout[256];
+    snprintf(strout,256,"Road count is %d. Total Len is %f",mxodr.GetRoadCount(),froadlen);
+    QMessageBox::information(this,"Info",strout,QMessageBox::YesAll);
+}
+
+void XVMainWindow::UpdateScene()
+{
+    int i;
+    int nsize = mvectorviewitem.size();
+    for(i=0;i<nsize;i++)
+    {
+        mpscene->removeItem(mvectorviewitem.at(i));
+        delete mvectorviewitem.at(i);
+    }
+    mvectorviewitem.clear();
+
+    nsize = mxodr.GetRoadCount();
+
+    std::vector<RoadDigit> xvectorrd;
+    for(i=0;i<nsize;i++)
+    {
+        RoadDigit xrd(mxodr.GetRoad(i),10.0);
+        xvectorrd.push_back(xrd);
+    }
+    for(i=0;i<nsize;i++)
+    {
+        std::vector<QGraphicsPathItem *> xvectorlanepath = xodrscenfunc::GetRoadLaneItem(&(xvectorrd[i]));
+        int j;
+        int ncount = xvectorlanepath.size();
+        for(j=0;j<ncount;j++)
+        {
+            QGraphicsPathItem * pitem = xvectorlanepath[j];
+            pitem->setPos(mfViewMoveX +VIEW_WIDTH/2,-mfViewMoveY+VIEW_HEIGHT/2);
+            mpscene->addItem(pitem);
+            mvectorviewitem.push_back(pitem);
+        }
+    }
+
+    for(i=0;i<nsize;i++)
+    {
+        std::vector<QGraphicsPathItem *> xvectormarkpath = xodrscenfunc::GetRoadMarkItem(&(xvectorrd[i]));
+        int j;
+        int ncount = xvectormarkpath.size();
+        for(j=0;j<ncount;j++)
+        {
+            QGraphicsPathItem * pitem = xvectormarkpath[j];
+            pitem->setPos(mfViewMoveX +VIEW_WIDTH/2,-mfViewMoveY+VIEW_HEIGHT/2);
+            mpscene->addItem(pitem);
+            mvectorviewitem.push_back(pitem);
+        }
+    }
+}
+
+
+void XVMainWindow::on_actionZoom_In_triggered()
+{
+    myview->zoomIn();
+}
+
+void XVMainWindow::on_actionZoom_Out_triggered()
+{
+    myview->zoomOut();
+}
+
+void XVMainWindow::on_actionZoom_One_triggered()
+{
+    myview->zoomone();
+}
+
+void XVMainWindow::onClickXY(double x, double y)
+{
+    double selx,sely;
+    double lon,lat;
+    selx = (x - VIEW_WIDTH/2);
+    sely = (y - VIEW_HEIGHT/2) * (-1);
+
+    mfselx = selx;
+    mfsely = sely;
+
+//    double x0,y0;
+//    GaussProjCal(glon0,glat0,&x0,&y0);
+//    GaussProjInvCal(x0+selx,y0+sely,&lon,&lat);
+
+    double rel_x,rel_y;
+    rel_x = selx - mfViewMoveX;
+    rel_y = sely - mfViewMoveY;
+
+    Road * pRoad = 0;
+    GeometryBlock * pgeob;
+    double fdis,nearx,neary,hdg;
+    double fs;
+    int nlane;
+    if(xodrfunc::GetNearPoint(rel_x,rel_y,&mxodr,&pRoad,&pgeob,fdis,nearx,neary,hdg,50,&fs,&nlane) == 0)
+    {
+        qDebug("s:%f dis is %f nlane is %d",fs,fdis,nlane);
+        char strout[1000];
+        snprintf(strout,1000,"Road:%s s:%f dis:%f nlane:%d",pRoad->GetRoadId().data(),fs,fdis,nlane);
+ //       mpLabel_Status->setText(strout);
+        ui->statusbar->showMessage(strout,10000);
+
+    }
+    else
+    {
+        char strout[1000];
+        snprintf(strout,1000,"Click x:%f y:%f",rel_x,rel_y);
+        ui->statusbar->showMessage(strout,10000);
+        qDebug("not found near road.");
+    }
+}
+
+void XVMainWindow::on_actionSet_Move_triggered()
+{
+    QMessageBox::StandardButton button;
+    char strquest[256];
+    snprintf(strquest,256,"Want to Move Center to x:%f y:%f ?",-(mfViewMoveX - mfselx),-(mfViewMoveY-mfsely));
+    button=QMessageBox::question(this,"Move",strquest,QMessageBox::Yes|QMessageBox::No);
+    if(button==QMessageBox::No)
+    {
+        return;
+    }
+    else if(button==QMessageBox::Yes)
+    {
+
+    }
+
+    mfViewMoveX = mfViewMoveX - mfselx;
+    mfViewMoveY = mfViewMoveY - mfsely;
+
+    int nsize = mvectorviewitem.size();
+    int i;
+    for(i=0;i<nsize;i++)
+    {
+        mpscene->removeItem(mvectorviewitem.at(i));
+    }
+    for(i=0;i<nsize;i++)
+    {
+        mvectorviewitem.at(i)->setPos(mfViewMoveX +VIEW_WIDTH/2,-mfViewMoveY+VIEW_HEIGHT/2);
+        mpscene->addItem(mvectorviewitem.at(i));
+    }
+
+    myview->zoomIn();
+    myview->zoomOut();
+}
+
+void XVMainWindow::on_actionReset_Move_triggered()
+{
+    mfViewMoveX = 0;
+    mfViewMoveY = 0;
+    int nsize = mvectorviewitem.size();
+    int i;
+
+    for(i=0;i<nsize;i++)
+    {
+        mpscene->removeItem(mvectorviewitem.at(i));
+    }
+
+    for(i=0;i<nsize;i++)
+    {
+        mvectorviewitem.at(i)->setPos(mfViewMoveX +VIEW_WIDTH/2,-mfViewMoveY+VIEW_HEIGHT/2);
+        mpscene->addItem(mvectorviewitem.at(i));
+    }
+
+
+    myview->zoomIn();
+    myview->zoomOut();
+}
+
+void XVMainWindow::paintEvent(QPaintEvent * event)
+{
+    if(mbRefresh)
+    {
+        myview->setScene(mpscene);
+        mbRefresh = false;
+    }
+}

+ 70 - 0
src/tool/map_lanetoxodr/xvmainwindow.h

@@ -0,0 +1,70 @@
+#ifndef XVMAINWINDOW_H
+#define XVMAINWINDOW_H
+
+#include <QMainWindow>
+
+#include "myview.h"
+
+#include <QGraphicsScene>
+
+#include "OpenDrive/OpenDrive.h"
+#include "OpenDrive/OpenDriveXmlWriter.h"
+
+#include "OpenDrive/OpenDriveXmlParser.h"
+
+namespace Ui {
+class XVMainWindow;
+}
+
+class XVMainWindow : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit XVMainWindow(QWidget *parent = nullptr);
+    ~XVMainWindow();
+
+private slots:
+    void on_actionLoad_triggered();
+
+    void on_actionZoom_In_triggered();
+
+    void on_actionZoom_Out_triggered();
+
+    void on_actionZoom_One_triggered();
+
+    void onClickXY(double x, double y);
+
+    void on_actionSet_Move_triggered();
+
+    void on_actionReset_Move_triggered();
+
+public:
+     void resizeEvent(QResizeEvent *event);
+
+private slots:
+    virtual void paintEvent(QPaintEvent *);
+
+private:
+     void LoadXODR(QString strpath);
+     void UpdateScene();
+
+private:
+    Ui::XVMainWindow *ui;
+    MyView *myview;
+    QGraphicsScene * mpscene;
+
+    std::vector<QGraphicsPathItem *> mvectorviewitem;
+
+private:
+    OpenDrive mxodr;
+    double mfViewMoveX = 0;
+    double mfViewMoveY = 0;
+
+    double mfselx = 0;
+    double mfsely = 0;
+
+    bool mbRefresh = false;
+};
+
+#endif // XVMAINWINDOW_H

+ 73 - 0
src/tool/map_lanetoxodr/xvmainwindow.ui

@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>XVMainWindow</class>
+ <widget class="QMainWindow" name="XVMainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralwidget"/>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>800</width>
+     <height>28</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
+     <string>File</string>
+    </property>
+    <addaction name="actionLoad"/>
+    <addaction name="actionZoom_In"/>
+    <addaction name="actionZoom_Out"/>
+    <addaction name="actionZoom_One"/>
+    <addaction name="actionSet_Move"/>
+    <addaction name="actionReset_Move"/>
+   </widget>
+   <addaction name="menuFile"/>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+  <action name="actionLoad">
+   <property name="text">
+    <string>Load</string>
+   </property>
+  </action>
+  <action name="actionZoom_In">
+   <property name="text">
+    <string>Zoom In</string>
+   </property>
+  </action>
+  <action name="actionZoom_Out">
+   <property name="text">
+    <string>Zoom Out</string>
+   </property>
+  </action>
+  <action name="actionZoom_One">
+   <property name="text">
+    <string>Zoom One</string>
+   </property>
+  </action>
+  <action name="actionSet_Move">
+   <property name="text">
+    <string>Set Move</string>
+   </property>
+  </action>
+  <action name="actionReset_Move">
+   <property name="text">
+    <string>Reset Move</string>
+   </property>
+  </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 0 - 6
src/ui/ui_ads_hmi/ADCIntelligentVehicle.cpp

@@ -231,12 +231,6 @@ ADCIntelligentVehicle::ADCIntelligentVehicle(QWidget *parent)
     ServiceCarStatus.lidar_y_offset = atof(xp.GetParam("lidar_y_offset","0").data());
     ServiceCarStatus.lidar_y_offset = atof(xp.GetParam("lidar_y_offset","0").data());
 
 
 
 
-//   givlog->info("brain.");
-
-   //gstrmemradar = xp.GetParam("radar","radar");
-
-
-
     ui->listWidget->setIconSize(QSize(40,40));
     ui->listWidget->setIconSize(QSize(40,40));
     ui->stackedWidget->setCurrentIndex(0);
     ui->stackedWidget->setCurrentIndex(0);