Browse Source

rename namespaces

neozhaoliang 3 years ago
parent
commit
b425f7b8c1
77 changed files with 3799 additions and 574 deletions
  1. 7 7
      src/decition/decition_brain/decision/adc_adapter/base_adapter.cpp
  2. 6 6
      src/decition/decition_brain/decision/adc_adapter/base_adapter.h
  3. 6 6
      src/decition/decition_brain/decision/adc_adapter/bus_adapter.cpp
  4. 8 8
      src/decition/decition_brain/decision/adc_adapter/bus_adapter.h
  5. 6 6
      src/decition/decition_brain/decision/adc_adapter/ge3_adapter.cpp
  6. 9 9
      src/decition/decition_brain/decision/adc_adapter/ge3_adapter.h
  7. 6 6
      src/decition/decition_brain/decision/adc_adapter/hapo_adapter.cpp
  8. 8 8
      src/decition/decition_brain/decision/adc_adapter/hapo_adapter.h
  9. 6 6
      src/decition/decition_brain/decision/adc_adapter/qingyuan_adapter.cpp
  10. 9 9
      src/decition/decition_brain/decision/adc_adapter/qingyuan_adapter.h
  11. 6 6
      src/decition/decition_brain/decision/adc_adapter/vv7_adapter.cpp
  12. 9 11
      src/decition/decition_brain/decision/adc_adapter/vv7_adapter.h
  13. 6 6
      src/decition/decition_brain/decision/adc_adapter/yuhesen_adapter.cpp
  14. 9 11
      src/decition/decition_brain/decision/adc_adapter/yuhesen_adapter.h
  15. 4 4
      src/decition/decition_brain/decision/adc_adapter/zhongche_adapter.cpp
  16. 9 11
      src/decition/decition_brain/decision/adc_adapter/zhongche_adapter.h
  17. 7 7
      src/decition/decition_brain/decision/adc_controller/base_controller.cpp
  18. 5 5
      src/decition/decition_brain/decision/adc_controller/base_controller.h
  19. 9 9
      src/decition/decition_brain/decision/adc_controller/pid_controller.cpp
  20. 7 7
      src/decition/decition_brain/decision/adc_controller/pid_controller.h
  21. 0 0
      src/decition/decition_brain/decision/adc_math/core/include/splines/PolynomialXd.h
  22. 0 0
      src/decition/decition_brain/decision/adc_math/core/include/splines/QuarticPolynomial.h
  23. 0 0
      src/decition/decition_brain/decision/adc_math/core/include/splines/QuinticPolynomial.h
  24. 0 0
      src/decition/decition_brain/decision/adc_math/core/include/splines/Spline1dSegment.h
  25. 0 0
      src/decition/decition_brain/decision/adc_math/core/include/splines/Spline2dSegment.h
  26. 8 8
      src/decition/decition_brain/decision/adc_planner/base_planner.cpp
  27. 3 3
      src/decition/decition_brain/decision/adc_planner/base_planner.h
  28. 8 8
      src/decition/decition_brain/decision/adc_planner/dubins_planner.cpp
  29. 2 2
      src/decition/decition_brain/decision/adc_planner/dubins_planner.h
  30. 39 39
      src/decition/decition_brain/decision/adc_planner/frenet_planner.cpp
  31. 5 5
      src/decition/decition_brain/decision/adc_planner/frenet_planner.h
  32. 9 9
      src/decition/decition_brain/decision/adc_planner/lane_change_planner.cpp
  33. 1 1
      src/decition/decition_brain/decision/adc_planner/lane_change_planner.h
  34. 56 56
      src/decition/decition_brain/decision/adc_tools/compute_00.cpp
  35. 4 4
      src/decition/decition_brain/decision/adc_tools/compute_00.h
  36. 0 0
      src/decition/decition_brain/decision/adc_tools/dubins.cpp
  37. 0 0
      src/decition/decition_brain/decision/adc_tools/dubins.h
  38. 1 1
      src/decition/decition_brain/decision/adc_tools/gnss_coordinate_convert.cpp
  39. 0 0
      src/decition/decition_brain/decision/adc_tools/gnss_coordinate_convert.h
  40. 5 5
      src/decition/decition_brain/decision/adc_tools/gps_distance.cpp
  41. 1 1
      src/decition/decition_brain/decision/adc_tools/gps_distance.h
  42. 3 3
      src/decition/decition_brain/decision/adc_tools/parameter_status.h
  43. 8 8
      src/decition/decition_brain/decision/adc_tools/transfer.cpp
  44. 2 2
      src/decition/decition_brain/decision/adc_tools/transfer.h
  45. 49 49
      src/decition/decition_brain/decision/brain.cpp
  46. 11 11
      src/decition/decition_brain/decision/brain.h
  47. 0 0
      src/decition/decition_brain/decision/compute_00.cpp
  48. 4 4
      src/decition/decition_brain/decision/compute_00.h
  49. 0 0
      src/decition/decition_brain/decision/decide_from_gps.cpp
  50. 114 114
      src/decition/decition_brain/decision/decide_gps_00.cpp
  51. 17 17
      src/decition/decition_brain/decision/decide_gps_00.h
  52. 8 8
      src/decition/decition_brain/decision/decide_line_00.h
  53. 47 47
      src/decition/decition_brain/decision/decide_line_00_.cpp
  54. 0 0
      src/decition/decition_brain/decision/decision.pri
  55. 3 3
      src/decition/decition_brain/decision/decition_maker.h
  56. 1 1
      src/decition/decition_brain/decision/decition_type.h
  57. 0 0
      src/decition/decition_brain/decision/decition_voter.cpp
  58. 3 3
      src/decition/decition_brain/decision/decition_voter.h
  59. 0 0
      src/decition/decition_brain/decision/fanyaapi.cpp
  60. 0 0
      src/decition/decition_brain/decision/fanyaapi.h
  61. 0 0
      src/decition/decition_brain/decision/gnss_coordinate_convert.cpp
  62. 0 0
      src/decition/decition_brain/decision/gnss_coordinate_convert.h
  63. 179 0
      src/decition/decition_brain/decision/gnss_proj/gnss_proj.cpp
  64. 48 0
      src/decition/decition_brain/decision/gnss_proj/gnss_proj.h
  65. 5 0
      src/decition/decition_brain/decision/gnss_proj/gnss_proj.pri
  66. 0 0
      src/decition/decition_brain/decision/gps_distance.cpp
  67. 1 1
      src/decition/decition_brain/decision/gps_distance.h
  68. 8 8
      src/decition/decition_brain/decision/obs_predict.cpp
  69. 4 4
      src/decition/decition_brain/decision/obs_predict.h
  70. 1400 0
      src/decition/decition_brain/decision/tinyspline/tinyspline.c
  71. 1152 0
      src/decition/decition_brain/decision/tinyspline/tinyspline.h
  72. 7 0
      src/decition/decition_brain/decision/tinyspline/tinyspline.pri
  73. 350 0
      src/decition/decition_brain/decision/tinyspline/tinysplinecpp.cpp
  74. 90 0
      src/decition/decition_brain/decision/tinyspline/tinysplinecpp.h
  75. 0 0
      src/decition/decition_brain/decision/transfer.cpp
  76. 0 0
      src/decition/decition_brain/decision/transfer.h
  77. 1 1
      src/decition/decition_brain/decition_brain.pro

+ 7 - 7
src/decition/decition_brain/decition/adc_adapter/base_adapter.cpp → src/decition/decition_brain/decision/adc_adapter/base_adapter.cpp

@@ -1,23 +1,23 @@
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
-#include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_adapter/base_adapter.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
 
 
 
 
-iv::decition::BaseAdapter::BaseAdapter(){
+iv::decision::BaseAdapter::BaseAdapter(){
 
 }
-iv::decition::BaseAdapter::~BaseAdapter(){
+iv::decision::BaseAdapter::~BaseAdapter(){
 
 }
 
 
 
- iv::decition::Decition  iv::decition::BaseAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  path , float dSpeed, float obsDistacne ,
+ iv::decision::Decition  iv::decision::BaseAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  path , float dSpeed, float obsDistacne ,
                                                                       float  obsSpeed,float accAim,float accNow  , bool changingDangWei, Decition *decition){
 
 

+ 6 - 6
src/decition/decition_brain/decition/adc_adapter/base_adapter.h → src/decition/decition_brain/decision/adc_adapter/base_adapter.h

@@ -4,13 +4,13 @@
 
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
-#include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
 
 namespace iv {
-namespace decition {
+namespace decision {
 
         class BaseAdapter {
         public:
@@ -23,8 +23,8 @@ namespace decition {
 
 
 
-        virtual  iv::decition::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
-                                                          float  obsSpeed,float accAim,float accNow, bool changingDangWei,Decition *decition);
+        virtual  iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                          float  obsSpeed,float accAim,float accNow, bool changingDangWei,Decition *decision);
 
 
         private:

+ 6 - 6
src/decition/decition_brain/decition/adc_adapter/bus_adapter.cpp → src/decition/decition_brain/decision/adc_adapter/bus_adapter.cpp

@@ -1,4 +1,4 @@
-#include <decition/adc_adapter/bus_adapter.h>
+#include <decision/adc_adapter/bus_adapter.h>
 #include <common/constants.h>
 #include <common/car_status.h>
 #include <math.h>
@@ -9,17 +9,17 @@
 using namespace std;
 
 
-iv::decition::BusAdapter::BusAdapter(){
+iv::decision::BusAdapter::BusAdapter(){
     adapter_id=4;
     adapter_name="bus";
 }
-iv::decition::BusAdapter::~BusAdapter(){
+iv::decision::BusAdapter::~BusAdapter(){
 
 }
 
 
 
-iv::decition::Decition iv::decition::BusAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decision::Decition iv::decision::BusAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
     accAim=min(0.7f,accAim);
 
@@ -279,7 +279,7 @@ std::cout<<"========================================="<<std::endl;
 
 
 
-float iv::decition::BusAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decision::BusAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -315,7 +315,7 @@ float iv::decition::BusAdapter::limitBrake(float realSpeed, float controlBrake,f
 
 }
 
-float iv::decition::BusAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decision::BusAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
 
     controlSpeed=min((float)100.0,controlSpeed);
     controlSpeed=max((float)0.0,controlSpeed);

+ 8 - 8
src/decition/decition_brain/decition/adc_adapter/bus_adapter.h → src/decition/decition_brain/decision/adc_adapter/bus_adapter.h

@@ -3,17 +3,17 @@
 
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
 #include <vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_adapter/base_adapter.h>
-#include <decition/adc_tools/transfer.h>
-#include<decition/decide_gps_00.h>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
 
 
 namespace iv {
-     namespace decition {
+     namespace decision {
          class BusAdapter: public BaseAdapter {
                     public:
 
@@ -25,8 +25,8 @@ namespace iv {
                         BusAdapter();
                         ~BusAdapter();
 
-                        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);
+                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 6 - 6
src/decition/decition_brain/decition/adc_adapter/ge3_adapter.cpp → src/decition/decition_brain/decision/adc_adapter/ge3_adapter.cpp

@@ -1,4 +1,4 @@
-#include <decition/adc_adapter/ge3_adapter.h>
+#include <decision/adc_adapter/ge3_adapter.h>
 #include <common/constants.h>
 #include <common/car_status.h>
 #include <math.h>
@@ -9,17 +9,17 @@
 using namespace std;
 
 
-iv::decition::Ge3Adapter::Ge3Adapter(){
+iv::decision::Ge3Adapter::Ge3Adapter(){
     adapter_id=0;
     adapter_name="ge3";
 }
-iv::decition::Ge3Adapter::~Ge3Adapter(){
+iv::decision::Ge3Adapter::~Ge3Adapter(){
 
 }
 
 
 
-iv::decition::Decition iv::decition::Ge3Adapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decision::Decition iv::decision::Ge3Adapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                    float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
 
 
@@ -123,7 +123,7 @@ iv::decition::Decition iv::decition::Ge3Adapter::getAdapterDeciton(GPS_INS now_g
 
 
 
-float iv::decition::Ge3Adapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decision::Ge3Adapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -165,7 +165,7 @@ float iv::decition::Ge3Adapter::limitBrake(float realSpeed, float controlBrake,f
 
 }
 
-float iv::decition::Ge3Adapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decision::Ge3Adapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
     if(controlBrake>0){
         controlSpeed=0;
     }

+ 9 - 9
src/decition/decition_brain/decition/adc_adapter/ge3_adapter.h → src/decition/decition_brain/decision/adc_adapter/ge3_adapter.h

@@ -4,17 +4,17 @@
 
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
-#include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_adapter/base_adapter.h>
-#include <decition/adc_tools/transfer.h>
-#include<decition/decide_gps_00.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
 
 
 namespace iv {
-     namespace decition {
+     namespace decision {
          class Ge3Adapter: public BaseAdapter {
                     public:
 
@@ -24,8 +24,8 @@ namespace iv {
                         Ge3Adapter();
                         ~Ge3Adapter();
 
-                        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);
+                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 6 - 6
src/decition/decition_brain/decition/adc_adapter/hapo_adapter.cpp → src/decition/decition_brain/decision/adc_adapter/hapo_adapter.cpp

@@ -1,4 +1,4 @@
-#include <decition/adc_adapter/hapo_adapter.h>
+#include <decision/adc_adapter/hapo_adapter.h>
 #include <common/constants.h>
 #include <common/car_status.h>
 #include <math.h>
@@ -10,18 +10,18 @@ QTime doorOpenTime;
 
 using namespace std;
 
-iv::decition::HapoAdapter::HapoAdapter(){
+iv::decision::HapoAdapter::HapoAdapter(){
     adapter_id=5;
     adapter_name="hapo";
 }
-iv::decition::HapoAdapter::~HapoAdapter(){
+iv::decision::HapoAdapter::~HapoAdapter(){
 
 }
 
 #include "ivlog.h"
 extern iv::Ivlog * givlog;
 
-iv::decition::Decition iv::decition::HapoAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decision::Decition iv::decision::HapoAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
     accAim=min(0.7f,accAim);
 
@@ -311,7 +311,7 @@ givlog->debug("obs_distance","dSpeed: %f, realSpeed: %f, brake: %f",
 
 
 
-float iv::decition::HapoAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decision::HapoAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -347,7 +347,7 @@ float iv::decition::HapoAdapter::limitBrake(float realSpeed, float controlBrake,
 
 }
 
-float iv::decition::HapoAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decision::HapoAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
 
     controlSpeed=min((float)100.0,controlSpeed);
     controlSpeed=max((float)0.0,controlSpeed);

+ 8 - 8
src/decition/decition_brain/decition/adc_adapter/hapo_adapter.h → src/decition/decition_brain/decision/adc_adapter/hapo_adapter.h

@@ -3,17 +3,17 @@
 
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
 #include <vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_adapter/base_adapter.h>
-#include <decition/adc_tools/transfer.h>
-#include<decition/decide_gps_00.h>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
 
 
 namespace iv {
-     namespace decition {
+     namespace decision {
          class HapoAdapter: public BaseAdapter {
                     public:
 
@@ -25,8 +25,8 @@ namespace iv {
                         HapoAdapter();
                         ~HapoAdapter();
 
-                        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);
+                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 6 - 6
src/decition/decition_brain/decition/adc_adapter/qingyuan_adapter.cpp → src/decition/decition_brain/decision/adc_adapter/qingyuan_adapter.cpp

@@ -1,4 +1,4 @@
-#include <decition/adc_adapter/qingyuan_adapter.h>
+#include <decision/adc_adapter/qingyuan_adapter.h>
 #include <common/constants.h>
 #include <common/car_status.h>
 #include <math.h>
@@ -9,17 +9,17 @@
 using namespace std;
 
 
-iv::decition::QingYuanAdapter::QingYuanAdapter(){
+iv::decision::QingYuanAdapter::QingYuanAdapter(){
     adapter_id=1;
     adapter_name="qingyuan";
 }
-iv::decition::QingYuanAdapter::~QingYuanAdapter(){
+iv::decision::QingYuanAdapter::~QingYuanAdapter(){
 
 }
 
 
 
-iv::decition::Decition iv::decition::QingYuanAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decision::Decition iv::decision::QingYuanAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
 
 
@@ -262,7 +262,7 @@ std::cout<<"========================================="<<std::endl;
 
 
 
-float iv::decition::QingYuanAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decision::QingYuanAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -302,7 +302,7 @@ float iv::decition::QingYuanAdapter::limitBrake(float realSpeed, float controlBr
 
 }
 
-float iv::decition::QingYuanAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decision::QingYuanAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
 
     controlSpeed=min((float)100.0,controlSpeed);
     controlSpeed=max((float)0.0,controlSpeed);

+ 9 - 9
src/decition/decition_brain/decition/adc_adapter/qingyuan_adapter.h → src/decition/decition_brain/decision/adc_adapter/qingyuan_adapter.h

@@ -2,17 +2,17 @@
 #define QINGYUAN_ADAPTER_H
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
-#include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_adapter/base_adapter.h>
-#include <decition/adc_tools/transfer.h>
-#include<decition/decide_gps_00.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
 
 
 namespace iv {
-     namespace decition {
+     namespace decision {
          class QingYuanAdapter: public BaseAdapter {
                     public:
 
@@ -24,8 +24,8 @@ namespace iv {
                         QingYuanAdapter();
                         ~QingYuanAdapter();
 
-                        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);
+                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 6 - 6
src/decition/decition_brain/decition/adc_adapter/vv7_adapter.cpp → src/decition/decition_brain/decision/adc_adapter/vv7_adapter.cpp

@@ -1,4 +1,4 @@
-#include <decition/adc_adapter/vv7_adapter.h>
+#include <decision/adc_adapter/vv7_adapter.h>
 #include <common/constants.h>
 #include <common/car_status.h>
 #include <math.h>
@@ -9,17 +9,17 @@
 using namespace std;
 
 
-iv::decition::VV7Adapter::VV7Adapter(){
+iv::decision::VV7Adapter::VV7Adapter(){
     adapter_id= 2;
     adapter_name="vv7";
 }
-iv::decition::VV7Adapter::~VV7Adapter(){
+iv::decision::VV7Adapter::~VV7Adapter(){
 
 }
 
 
 
-iv::decition::Decition iv::decition::VV7Adapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decision::Decition iv::decision::VV7Adapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
 
 
@@ -100,7 +100,7 @@ std::cout<<"========================================="<<std::endl;
 
 
 
-float iv::decition::VV7Adapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decision::VV7Adapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -140,7 +140,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::decision::VV7Adapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
 
     controlSpeed=min((float)5.0,controlSpeed);
     controlSpeed=max((float)-7.0,controlSpeed);

+ 9 - 11
src/decition/decition_brain/decition/adc_adapter/vv7_adapter.h → src/decition/decition_brain/decision/adc_adapter/vv7_adapter.h

@@ -1,20 +1,18 @@
 #ifndef VV7_ADAPTER_H
 #define VV7_ADAPTER_H
 
-
-
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
-#include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_adapter/base_adapter.h>
-#include <decition/adc_tools/transfer.h>
-#include<decition/decide_gps_00.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
 
 
 namespace iv {
-     namespace decition {
+     namespace decision {
          class VV7Adapter: public BaseAdapter {
                     public:
 
@@ -26,8 +24,8 @@ namespace iv {
                         VV7Adapter();
                         ~VV7Adapter();
 
-                        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);
+                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 6 - 6
src/decition/decition_brain/decition/adc_adapter/yuhesen_adapter.cpp → src/decition/decition_brain/decision/adc_adapter/yuhesen_adapter.cpp

@@ -1,4 +1,4 @@
-#include <decition/adc_adapter/yuhesen_adapter.h>
+#include <decision/adc_adapter/yuhesen_adapter.h>
 #include <common/constants.h>
 #include <common/car_status.h>
 #include <math.h>
@@ -9,17 +9,17 @@
 using namespace std;
 
 
-iv::decition::YuHeSenAdapter::YuHeSenAdapter(){
+iv::decision::YuHeSenAdapter::YuHeSenAdapter(){
     adapter_id= 7;
     adapter_name="yuhesen";
 }
-iv::decition::YuHeSenAdapter::~YuHeSenAdapter(){
+iv::decision::YuHeSenAdapter::~YuHeSenAdapter(){
 
 }
 
 
 
-iv::decition::Decition iv::decition::YuHeSenAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decision::Decition iv::decision::YuHeSenAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
                                                                         float  obsSpeed,float accAim,float accNow  ,bool changingDangWei,Decition *decition){
 
 
@@ -103,7 +103,7 @@ if((*decition)->brake>0){
 
 
 
-float iv::decition::YuHeSenAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
+float iv::decision::YuHeSenAdapter::limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc){
 
     //刹车限制
 
@@ -143,7 +143,7 @@ float iv::decition::YuHeSenAdapter::limitBrake(float realSpeed, float controlBra
 
 }
 
-float iv::decition::YuHeSenAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
+float iv::decision::YuHeSenAdapter::limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed ){
 
     controlSpeed=min((float)5.0,controlSpeed);
     controlSpeed=max((float)-7.0,controlSpeed);

+ 9 - 11
src/decition/decition_brain/decition/adc_adapter/yuhesen_adapter.h → src/decition/decition_brain/decision/adc_adapter/yuhesen_adapter.h

@@ -1,20 +1,18 @@
 #ifndef YUHESEN_ADAPTER_H
 #define YUHESEN_ADAPTER_H
 
-
-
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
-#include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_adapter/base_adapter.h>
-#include <decition/adc_tools/transfer.h>
-#include<decition/decide_gps_00.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
 
 
 namespace iv {
-     namespace decition {
+     namespace decision {
          class YuHeSenAdapter: public BaseAdapter {
                     public:
 
@@ -26,8 +24,8 @@ namespace iv {
                         YuHeSenAdapter();
                         ~YuHeSenAdapter();
 
-                        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);
+                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 4 - 4
src/decition/decition_brain/decition/adc_adapter/zhongche_adapter.cpp → src/decition/decition_brain/decision/adc_adapter/zhongche_adapter.cpp

@@ -1,5 +1,5 @@
 
-#include <decition/adc_adapter/zhongche_adapter.h>
+#include <decision/adc_adapter/zhongche_adapter.h>
 #include <common/constants.h>
 #include <common/car_status.h>
 #include <math.h>
@@ -9,16 +9,16 @@
 using namespace std;
 
 
-iv::decition::ZhongcheAdapter::ZhongcheAdapter(){
+iv::decision::ZhongcheAdapter::ZhongcheAdapter(){
     adapter_id= 3;
     adapter_name="zhongche";
 }
-iv::decition::ZhongcheAdapter::~ZhongcheAdapter(){
+iv::decision::ZhongcheAdapter::~ZhongcheAdapter(){
 
 }
 
 
-iv::decition::Decition iv::decition::ZhongcheAdapter::getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistance ,
+iv::decision::Decition iv::decision::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){
 
 

+ 9 - 11
src/decition/decition_brain/decition/adc_adapter/zhongche_adapter.h → src/decition/decition_brain/decision/adc_adapter/zhongche_adapter.h

@@ -1,19 +1,17 @@
 #ifndef ZHONGCHE_ADAPTER_H
 #define ZHONGCHE_ADAPTER_H
 
-
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
-#include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_adapter/base_adapter.h>
-#include <decition/adc_tools/transfer.h>
-#include<decition/decide_gps_00.h>
-
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_adapter/base_adapter.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decide_gps_00.h>
 
 namespace iv {
-     namespace decition {
+     namespace decision {
          class ZhongcheAdapter: public BaseAdapter {
                     public:
 
@@ -25,8 +23,8 @@ namespace iv {
                         ZhongcheAdapter();
                         ~ZhongcheAdapter();
 
-                        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);
+                        iv::decision::Decition getAdapterDeciton(GPS_INS now_gps_ins, std::vector<Point2D>  trace , float dSpeed, float obsDistacne ,
+                                                                                 float  obsSpeed,float acc,float accNow  ,bool changingDangWei,Decition *decision);
 
                         float limitBrake(float realSpeed, float controlBrake,float dSpeed,float obsDistance , float ttc);
                         float limitSpeed(float realSpeed, float controlBrake,float dSpeed,float controlSpeed );

+ 7 - 7
src/decition/decition_brain/decition/adc_controller/base_controller.cpp → src/decition/decition_brain/decision/adc_controller/base_controller.cpp

@@ -1,17 +1,17 @@
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
-#include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_controller/base_controller.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_controller/base_controller.h>
 
 
 
 
-iv::decition::BaseController::BaseController(){
+iv::decision::BaseController::BaseController(){
 
 }
-iv::decition::BaseController::~BaseController(){
+iv::decision::BaseController::~BaseController(){
 
 }
 
@@ -30,7 +30,7 @@ iv::decition::BaseController::~BaseController(){
   * @return                     iv::decition::Decition
   */
 
- iv::decition::Decition  iv::decition::BaseController::getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path, float dSpeed, float obsDistacne,
+ iv::decision::Decition  iv::decision::BaseController::getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path, float dSpeed, float obsDistacne,
                                                                           float obsSpeed,bool computeAngle, bool computeAcc,Decition *decition){
 
 }

+ 5 - 5
src/decition/decition_brain/decition/adc_controller/base_controller.h → src/decition/decition_brain/decision/adc_controller/base_controller.h

@@ -3,13 +3,13 @@
 #define _IV_DECITION__BASE_CONTROLLER_
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
 #include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
 
 namespace iv {
-namespace decition {
+namespace decision {
 //根据传感器传输来的信息作出决策
 class BaseController {
 public:
@@ -35,8 +35,8 @@ public:
       * @param decition             决策信息结构体的指针
       * @return                     iv::decition::Decition
       */
-    virtual  iv::decition::Decition getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D>  path , float dSpeed, float obsDistacne , float  obsSpeed,
-                                                       bool computeAngle, bool computeAcc, Decition *decition);
+    virtual  iv::decision::Decition getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D>  path , float dSpeed, float obsDistacne , float  obsSpeed,
+                                                       bool computeAngle, bool computeAcc, Decition *decision);
 
 
 private:

+ 9 - 9
src/decition/decition_brain/decition/adc_controller/pid_controller.cpp → src/decition/decition_brain/decision/adc_controller/pid_controller.cpp

@@ -1,4 +1,4 @@
-#include <decition/adc_controller/pid_controller.h>
+#include <decision/adc_controller/pid_controller.h>
 #include <common/constants.h>
 #include <common/car_status.h>
 #include <math.h>
@@ -9,11 +9,11 @@
 using namespace std;
 
 
-iv::decition::PIDController::PIDController(){
+iv::decision::PIDController::PIDController(){
     controller_id = 0;
     controller_name="pid";
 }
-iv::decition::PIDController::~PIDController(){
+iv::decision::PIDController::~PIDController(){
 
 }
 
@@ -34,7 +34,7 @@ iv::decition::PIDController::~PIDController(){
  * @return                     iv::decition::Decition
  */
 
-iv::decition::Decition iv::decition::PIDController::getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path, float dSpeed, float obsDistacne, float obsSpeed,
+iv::decision::Decition iv::decision::PIDController::getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path, float dSpeed, float obsDistacne, float obsSpeed,
                                                                        bool computeAngle, bool computeAcc, Decition *decition){
 
     float realSpeed= now_gps_ins.speed;
@@ -51,7 +51,7 @@ iv::decition::Decition iv::decition::PIDController::getControlDecition(GPS_INS n
 
 
 
-float iv::decition::PIDController::getPidAngle(float realSpeed, std::vector<Point2D> trace, int roadMode){
+float iv::decision::PIDController::getPidAngle(float realSpeed, std::vector<Point2D> trace, int roadMode){
     double ang = 0;
     double EPos = 0, EAng = 0;
 
@@ -147,7 +147,7 @@ float iv::decition::PIDController::getPidAngle(float realSpeed, std::vector<Poin
 
 
 
-float iv::decition::PIDController::getAveDef(std::vector<Point2D> farTrace){
+float iv::decision::PIDController::getAveDef(std::vector<Point2D> farTrace){
     double sum_x = 0;
     double sum_y = 0;
     for (int i = 0; i < min(5, (int)farTrace.size()); i++)
@@ -162,7 +162,7 @@ float iv::decition::PIDController::getAveDef(std::vector<Point2D> farTrace){
 
 
 
-float iv::decition::PIDController::getPidAcc (GPS_INS gpsIns,float dSpeed, float obsDistance, float obsSpeed){
+float iv::decision::PIDController::getPidAcc (GPS_INS gpsIns,float dSpeed, float obsDistance, float obsSpeed){
 
     std::cout << "\n计算用obs速度:%f\n" << obsSpeed << std::endl;
     std::cout << "\n计算用obs距离:%f\n" << obsDistance << std::endl;
@@ -256,7 +256,7 @@ float iv::decition::PIDController::getPidAcc (GPS_INS gpsIns,float dSpeed, float
 }
 
 
-float iv::decition::PIDController::computeU(float obsDistance, float ds,float vs,float vt,float vh,float vl,float ttc,float ttcr){
+float iv::decision::PIDController::computeU(float obsDistance, float ds,float vs,float vt,float vh,float vl,float ttc,float ttcr){
 
     double Id = 0;
     double ed = ds - obsDistance;
@@ -318,7 +318,7 @@ float iv::decition::PIDController::computeU(float obsDistance, float ds,float vs
 }
 
 
-float iv::decition::PIDController::limiteU(float u,float ttc){
+float iv::decision::PIDController::limiteU(float u,float ttc){
     if(ttc<3 && u<-0.2){
         u=-0.2;
     }

+ 7 - 7
src/decition/decition_brain/decition/adc_controller/pid_controller.h → src/decition/decition_brain/decision/adc_controller/pid_controller.h

@@ -2,15 +2,15 @@
 #define _IV_DECITION__PID_CONTROLLER_
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
 #include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_controller/base_controller.h>
-#include <decition/adc_tools/transfer.h>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_controller/base_controller.h>
+#include <decision/adc_tools/transfer.h>
 
 namespace iv {
-        namespace decition {
+        namespace decision {
         //根据传感器传输来的信息作出决策
                     class PIDController: public BaseController {
                     public:
@@ -46,8 +46,8 @@ namespace iv {
                            */
 
 
-                        iv::decition::Decition getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path,float dSpeed, float obsDistacne,float  obsSpeed,
-                                                                  bool computeAngle, bool computeAcc, Decition *decition);
+                        iv::decision::Decition getControlDecition(GPS_INS now_gps_ins, std::vector<Point2D> path,float dSpeed, float obsDistacne,float  obsSpeed,
+                                                                  bool computeAngle, bool computeAcc, Decition *decision);
                         float  getPidAngle (float realSpeed, std::vector<Point2D> trace,int roadMode);
                         float  getAveDef (std::vector<Point2D> farTrace);
                         float  getPidAcc (GPS_INS gpsIns,float dSpeed, float obsDistacne, float obsSpeed);

+ 0 - 0
src/decition/decition_brain/decition/adc_math/core/include/splines/PolynomialXd.h → src/decition/decition_brain/decision/adc_math/core/include/splines/PolynomialXd.h


+ 0 - 0
src/decition/decition_brain/decition/adc_math/core/include/splines/QuarticPolynomial.h → src/decition/decition_brain/decision/adc_math/core/include/splines/QuarticPolynomial.h


+ 0 - 0
src/decition/decition_brain/decition/adc_math/core/include/splines/QuinticPolynomial.h → src/decition/decition_brain/decision/adc_math/core/include/splines/QuinticPolynomial.h


+ 0 - 0
src/decition/decition_brain/decition/adc_math/core/include/splines/Spline1dSegment.h → src/decition/decition_brain/decision/adc_math/core/include/splines/Spline1dSegment.h


+ 0 - 0
src/decition/decition_brain/decition/adc_math/core/include/splines/Spline2dSegment.h → src/decition/decition_brain/decision/adc_math/core/include/splines/Spline2dSegment.h


+ 8 - 8
src/decition/decition_brain/decition/adc_planner/base_planner.cpp → src/decition/decition_brain/decision/adc_planner/base_planner.cpp

@@ -1,21 +1,21 @@
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
-#include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_tools/transfer.h>
+#include <vector>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_tools/transfer.h>
 #include "perception/perceptionoutput.h"
-#include <decition/adc_planner/base_planner.h>
+#include <decision/adc_planner/base_planner.h>
 
 
 
 
 
 
-iv::decition::BasePlanner::BasePlanner(){
+iv::decision::BasePlanner::BasePlanner(){
 
 }
-iv::decition::BasePlanner::~BasePlanner(){
+iv::decision::BasePlanner::~BasePlanner(){
 
 }
 
@@ -31,7 +31,7 @@ iv::decition::BasePlanner::~BasePlanner(){
  * @param lidarGridPtr         激光雷达信息网格
  * @return                     返回一条车辆坐标系下的路径
  */
-std::vector<iv::Point2D> iv::decition::BasePlanner::getPath(GPS_INS now_gps_ins,const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+std::vector<iv::Point2D> iv::decision::BasePlanner::getPath(GPS_INS now_gps_ins,const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
 
 }
 

+ 3 - 3
src/decition/decition_brain/decition/adc_planner/base_planner.h → src/decition/decition_brain/decision/adc_planner/base_planner.h

@@ -2,14 +2,14 @@
 #define _IV_DECITION__BASE_PLANNER_
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
 #include<vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
 #include "perception/perceptionoutput.h"
 
 namespace iv {
-namespace decition {
+namespace decision {
 //根据传感器传输来的信息作出决策
     class BasePlanner {
     public:

+ 8 - 8
src/decition/decition_brain/decition/adc_planner/dubins_planner.cpp → src/decition/decition_brain/decision/adc_planner/dubins_planner.cpp

@@ -1,18 +1,18 @@
-#include <decition/adc_planner/dubins_planner.h>
-#include <decition/adc_tools/transfer.h>
-#include <decition/adc_tools/parameter_status.h>
+#include <decision/adc_planner/dubins_planner.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/adc_tools/parameter_status.h>
 #include <common/constants.h>
 
 #include <math.h>
 
-std::vector<iv::GPSData> iv::decition::DubinsPlanner::gpsMap;
+std::vector<iv::GPSData> iv::decision::DubinsPlanner::gpsMap;
 
-iv::decition::DubinsPlanner::DubinsPlanner(){
+iv::decision::DubinsPlanner::DubinsPlanner(){
     this->planner_id = 2;
     this->planner_name = "Dubins";
 }
 
-iv::decition::DubinsPlanner::~DubinsPlanner(){
+iv::decision::DubinsPlanner::~DubinsPlanner(){
 }
 
 /**
@@ -26,7 +26,7 @@ iv::decition::DubinsPlanner::~DubinsPlanner(){
  * @param lidarGridPtr         激光雷达信息网格
  * @return                     返回一条车辆坐标系下的路径
  */
-std::vector<iv::Point2D> iv::decition::DubinsPlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+std::vector<iv::Point2D> iv::decision::DubinsPlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
     std::vector<iv::Point2D> trace;
 
     double L = 2.6;
@@ -46,7 +46,7 @@ std::vector<iv::Point2D> iv::decition::DubinsPlanner::getPath(GPS_INS now_gps_in
 
 }
 
-int  iv::decition::DubinsPlanner::printConfiguration(double q[3], double x, void* user_data) {
+int  iv::decision::DubinsPlanner::printConfiguration(double q[3], double x, void* user_data) {
     GPSData gps;
     gps->roadMode=5;
     gps->gps_x=q[0];

+ 2 - 2
src/decition/decition_brain/decition/adc_planner/dubins_planner.h → src/decition/decition_brain/decision/adc_planner/dubins_planner.h

@@ -1,7 +1,7 @@
 #ifndef DUBINS_PLANNER_H
 #define DUBINS_PLANNER_H
 #include "base_planner.h"
-#include <decition/adc_tools/dubins.h>
+#include <decision/adc_tools/dubins.h>
 #include <QCoreApplication>
 
 #include <math.h>
@@ -13,7 +13,7 @@
 #include <string.h>
 
 namespace iv{
-namespace decition{
+namespace decision{
     class DubinsPlanner : public BasePlanner{
     public:
         DubinsPlanner();

+ 39 - 39
src/decition/decition_brain/decition/adc_planner/frenet_planner.cpp → src/decition/decition_brain/decision/adc_planner/frenet_planner.cpp

@@ -1,23 +1,23 @@
 #include "frenet_planner.h"
 
-#include <decition/adc_tools/transfer.h>
+#include <decision/adc_tools/transfer.h>
 #include <common/car_status.h>
-#include <decition/adc_tools/parameter_status.h>
-#include <decition/decide_gps_00.h>
-#include <decition/adc_planner/lane_change_planner.h>
+#include <decision/adc_tools/parameter_status.h>
+#include <decision/decide_gps_00.h>
+#include <decision/adc_planner/lane_change_planner.h>
 
 #include<Eigen/Dense>
 
 using namespace std;
 using namespace Eigen;
 
-iv::decition::FrenetPlanner::FrenetPlanner(){
+iv::decision::FrenetPlanner::FrenetPlanner(){
     this->planner_id = 1;
     this->planner_name = "Frenet";
     this->lidarGridPtr = NULL;
 }
 
-iv::decition::FrenetPlanner::~FrenetPlanner(){
+iv::decision::FrenetPlanner::~FrenetPlanner(){
     free(this->lidarGridPtr);
 }
 
@@ -34,7 +34,7 @@ iv::decition::FrenetPlanner::~FrenetPlanner(){
  * @param lidarGridPtr         激光雷达信息网格
  * @return                     返回一条车辆坐标系下的路径
  */
-std::vector<iv::Point2D> iv::decition::FrenetPlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+std::vector<iv::Point2D> iv::decision::FrenetPlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
     this->roadNow = -1;
     this->now_gps_ins = now_gps_ins;
     this->gpsMapLine = gpsMapLine;
@@ -61,7 +61,7 @@ std::vector<iv::Point2D> iv::decition::FrenetPlanner::getPath(GPS_INS now_gps_in
  * @param lidarGridPtr         激光雷达信息网格
  * @return
  */
-int iv::decition::FrenetPlanner::chooseRoadByFrenet(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offsetL, double offsetR, iv::LidarGridPtr lidarGridPtr,int roadNow){
+int iv::decision::FrenetPlanner::chooseRoadByFrenet(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offsetL, double offsetR, iv::LidarGridPtr lidarGridPtr,int roadNow){
     this->roadNow = roadNow;
     this->aimRoadByFrenet = -1;
     this->now_gps_ins = now_gps_ins;
@@ -87,7 +87,7 @@ int iv::decition::FrenetPlanner::chooseRoadByFrenet(GPS_INS now_gps_ins, const s
  * @param realsecSpeed         实时车速 [m/s]
  * @return                     返回一条frenet规划后并转换到车辆坐标系下的路径
  */
-std::vector<iv::Point2D> iv::decition::FrenetPlanner::getGpsTrace_AfterCalcFrenetTrace(const std::vector<iv::Point2D>& gpsTrace,double realsecSpeed){
+std::vector<iv::Point2D> iv::decision::FrenetPlanner::getGpsTrace_AfterCalcFrenetTrace(const std::vector<iv::Point2D>& gpsTrace,double realsecSpeed){
     vector<Point2D> trace;
     vector<FrenetPoint> frenet_s;
     double stp=0.0;
@@ -95,7 +95,7 @@ std::vector<iv::Point2D> iv::decition::FrenetPlanner::getGpsTrace_AfterCalcFrene
     FrenetPoint tmp={.x=gpsTrace[0].x,.y=gpsTrace[0].y,.s=0.0,.d=0.0};
     frenet_s.push_back(tmp);
     for(int i=1; i<gpsTrace.size(); ++i){
-        stp+=iv::decition::GetDistance(gpsTrace[i-1],gpsTrace[i]);
+        stp+=iv::decision::GetDistance(gpsTrace[i-1],gpsTrace[i]);
         tmp={.x=gpsTrace[i].x,.y=gpsTrace[i].y,.s=stp,.d=0.0};
         frenet_s.push_back(tmp);
     }
@@ -126,7 +126,7 @@ std::vector<iv::Point2D> iv::decition::FrenetPlanner::getGpsTrace_AfterCalcFrene
  * @param c_d_dd               车辆沿d方向的加速度。
  * @return                     返回一条frenet规划的最优路径
  */
-vector<iv::Point2D> iv::decition::FrenetPlanner::frenet_optimal_planning(iv::decition::FrenetPoint car_now_frenet_point,
+vector<iv::Point2D> iv::decision::FrenetPlanner::frenet_optimal_planning(iv::decision::FrenetPoint car_now_frenet_point,
                                                           const std::vector<FrenetPoint>& frenet_s, double c_speed, double c_d_d, double c_d_dd){
     double s0 = car_now_frenet_point.s;
     double c_d = car_now_frenet_point.d;
@@ -173,8 +173,8 @@ vector<iv::Point2D> iv::decition::FrenetPlanner::frenet_optimal_planning(iv::dec
  * @param s0                   车辆沿s方向的坐标
  * @return                     返回多条frenet路径
  */
-vector<iv::decition::Frenet_path> iv::decition::FrenetPlanner::calc_frenet_paths(double c_speed, double c_d, double c_d_d, double c_d_dd, double s0){
-    vector<iv::decition::Frenet_path> frenet_paths;
+vector<iv::decision::Frenet_path> iv::decision::FrenetPlanner::calc_frenet_paths(double c_speed, double c_d, double c_d_d, double c_d_dd, double s0){
+    vector<iv::decision::Frenet_path> frenet_paths;
     int roadNum = round(abs((leftWidth-rightWidth)/ServiceParameterStatus.D_ROAD_W));   //roadNum为frenet算法的起始道路序号
     //采样,并对每一个目标配置生成轨迹
     for(double di=leftWidth; di<=rightWidth; di+=ServiceParameterStatus.D_ROAD_W,roadNum--){
@@ -241,7 +241,7 @@ vector<iv::decition::Frenet_path> iv::decition::FrenetPlanner::calc_frenet_paths
  * @param frenet_s             frenet坐标系的s轴
  * @return                     通过引用传递返回带有x,y值的多条frenet路径
  */
-void iv::decition::FrenetPlanner::calc_global_paths(vector<Frenet_path>& fplist,const std::vector<FrenetPoint>& frenet_s){
+void iv::decision::FrenetPlanner::calc_global_paths(vector<Frenet_path>& fplist,const std::vector<FrenetPoint>& frenet_s){
 
     for(auto& fp:fplist){
         for(int i=0; i<fp.s.size(); ++i){
@@ -269,7 +269,7 @@ void iv::decition::FrenetPlanner::calc_global_paths(vector<Frenet_path>& fplist,
     }
 }
 
-void iv::decition::FrenetPlanner::calc_global_single_path(Frenet_path &fp, const std::vector<FrenetPoint> &frenet_s){
+void iv::decision::FrenetPlanner::calc_global_single_path(Frenet_path &fp, const std::vector<FrenetPoint> &frenet_s){
     for(int i=0; i<fp.s.size(); ++i){
         double ix,iy;
         //            Frenet2XY(&ix,&iy,fp.s[i],fp.d[i],frenet_s);  //第一种方法
@@ -301,7 +301,7 @@ void iv::decition::FrenetPlanner::calc_global_single_path(Frenet_path &fp, const
  * @param fplist               多条frenet路径
  * @return                     排除部分路径后的多条frenet路径
  */
-vector<iv::decition::Frenet_path> iv::decition::FrenetPlanner::check_paths(const vector<Frenet_path>& fplist){
+vector<iv::decision::Frenet_path> iv::decision::FrenetPlanner::check_paths(const vector<Frenet_path>& fplist){
     vector<Frenet_path> okind;
     int i=0;
     int j=0;
@@ -329,7 +329,7 @@ vector<iv::decition::Frenet_path> iv::decition::FrenetPlanner::check_paths(const
 }
 
 
-bool iv::decition::FrenetPlanner::check_single_path(const iv::decition::Frenet_path &fp){
+bool iv::decision::FrenetPlanner::check_single_path(const iv::decision::Frenet_path &fp){
     int j=0;
 
     cout<<"&&&&&&&&&&fp.roadflag: "<<fp.roadflag<<endl;
@@ -359,10 +359,10 @@ bool iv::decition::FrenetPlanner::check_single_path(const iv::decition::Frenet_p
  * @param car_now_frenet_point 车辆当前位置在frenet坐标系下的坐标
  * @return                     在路径上有障碍物返回false,否则返回true。
  */
-bool iv::decition::FrenetPlanner::check_collision(const iv::decition::Frenet_path &frenet_path){
+bool iv::decision::FrenetPlanner::check_collision(const iv::decision::Frenet_path &frenet_path){
     std::vector<Point2D> gpsTrace = frenet_path_to_gpsTrace(frenet_path);
     double obs=-1;
-    iv::decition::DecideGps00().computeObsOnRoadByFrenet(this->lidarGridPtr,gpsTrace,obs,this->gpsMapLine,this->PathPoint,this->now_gps_ins);
+    iv::decision::DecideGps00().computeObsOnRoadByFrenet(this->lidarGridPtr,gpsTrace,obs,this->gpsMapLine,this->PathPoint,this->now_gps_ins);
     if(obs > 0 && obs < 30)
         return false;
     else
@@ -376,7 +376,7 @@ bool iv::decition::FrenetPlanner::check_collision(const iv::decition::Frenet_pat
  * @param frenet_path          一条frenet路径
  * @return                     一条车辆坐标系下的路径
  */
-vector<iv::Point2D> iv::decition::FrenetPlanner::frenet_path_to_gpsTrace(const Frenet_path& frenet_path){
+vector<iv::Point2D> iv::decision::FrenetPlanner::frenet_path_to_gpsTrace(const Frenet_path& frenet_path){
     vector<iv::Point2D> gpsTrace;
     for (int i=0; i<frenet_path.x.size(); ++i) {
         gpsTrace.push_back(Point2D(frenet_path.x[i],frenet_path.y[i]));
@@ -386,14 +386,14 @@ vector<iv::Point2D> iv::decition::FrenetPlanner::frenet_path_to_gpsTrace(const F
 }
 
 
-double iv::decition::FrenetPlanner::distance(double x1, double y1, double x2, double y2)
+double iv::decision::FrenetPlanner::distance(double x1, double y1, double x2, double y2)
 {
     return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
 }
 
 
 //找出gpsTrace中距离(x,y)最近的一个点
-int iv::decition::FrenetPlanner::ClosestWaypoint(double x, double y, const std::vector<Point2D>& gpsTrace)
+int iv::decision::FrenetPlanner::ClosestWaypoint(double x, double y, const std::vector<Point2D>& gpsTrace)
 {
 
     double closestLen = 100000; //large number
@@ -420,7 +420,7 @@ int iv::decition::FrenetPlanner::ClosestWaypoint(double x, double y, const std::
   * |==========================================================| */
  // 车体坐标转frenet坐标。frenet坐标原点是 gpsTrace 中序号为0的点。
  // Transform from Cartesian x,y coordinates to Frenet s,d coordinates
-iv::decition::FrenetPoint iv::decition::FrenetPlanner::XY2Frenet(double x, double y, const std::vector<iv::Point2D>& gpsTrace){
+iv::decision::FrenetPoint iv::decision::FrenetPlanner::XY2Frenet(double x, double y, const std::vector<iv::Point2D>& gpsTrace){
     int next_wp=ClosestWaypoint( x,  y,  gpsTrace);
     int prev_wp = next_wp-1;  //prev_wp代表在next_wp的前一个点计算坐标,能够保证frenet_s都是依次相加的。避免在next_wp计算frenet_s的话,可能出现减的情况。
 //    if(next_wp == 0){
@@ -468,7 +468,7 @@ iv::decition::FrenetPoint iv::decition::FrenetPlanner::XY2Frenet(double x, doubl
 
  // frenet坐标转车体坐标。
  // Transform from Frenet s,d coordinates to Cartesian x,y
-void iv::decition::FrenetPlanner::Frenet2XY(double *res_x, double *res_y, double s, double d, const vector<iv::decition::FrenetPoint>& frenetTrace){
+void iv::decision::FrenetPlanner::Frenet2XY(double *res_x, double *res_y, double s, double d, const vector<iv::decision::FrenetPoint>& frenetTrace){
     int prev_wp = 0;
     //退出循环时,prev_wp 最大是等于 frenetTrace.size()-2。
     while(s > frenetTrace[prev_wp+1].s && (prev_wp < (int)(frenetTrace.size()-2) )){
@@ -490,7 +490,7 @@ void iv::decition::FrenetPlanner::Frenet2XY(double *res_x, double *res_y, double
  * |         车辆坐标系与 frenet 坐标系互转的第二种方法。           |
  * |==========================================================| */
 // 车体坐标转frenet坐标。frenet坐标原点是 gpsTrace 中序号为0的点。
-iv::decition::FrenetPoint iv::decition::FrenetPlanner::getFrenetfromXY(double x, double y, const std::vector<iv::Point2D>& gpsTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps){
+iv::decision::FrenetPoint iv::decision::FrenetPlanner::getFrenetfromXY(double x, double y, const std::vector<iv::Point2D>& gpsTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps){
     int next_wp=ClosestWaypoint( x,  y,  gpsTrace);
     int prev_wp = next_wp-1;  //prev_wp代表在next_wp的前一个点计算坐标,能够保证frenet_s都是依次相加的。避免在next_wp计算frenet_s的话,可能出现减的情况。
     //    if(next_wp == 0){
@@ -514,7 +514,7 @@ iv::decition::FrenetPoint iv::decition::FrenetPlanner::getFrenetfromXY(double x,
     return {x:x,y:y,s:frenet_s,d:pt.x,tangent_Ang:tmp_Angle};
 }
 
-void iv::decition::FrenetPlanner::getXYfromFrenet(double *res_x, double *res_y, double s, double d, const vector<iv::decition::FrenetPoint>& frenetTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps)
+void iv::decision::FrenetPlanner::getXYfromFrenet(double *res_x, double *res_y, double s, double d, const vector<iv::decision::FrenetPoint>& frenetTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps)
 {
     int prev_wp = -1;
 
@@ -534,7 +534,7 @@ void iv::decition::FrenetPlanner::getXYfromFrenet(double *res_x, double *res_y,
 }
 
 
-iv::decition::Quintic_polynomial::Quintic_polynomial(double xs, double vxs, double axs, double xe, double vxe, double axe, double T){
+iv::decision::Quintic_polynomial::Quintic_polynomial(double xs, double vxs, double axs, double xe, double vxe, double axe, double T){
     //计算五次多项式系数
     this->xs = xs;
     this->vxs = vxs;
@@ -564,32 +564,32 @@ iv::decition::Quintic_polynomial::Quintic_polynomial(double xs, double vxs, doub
     this->a5 = x(2,0);
 }
 
-iv::decition::Quintic_polynomial::~Quintic_polynomial(){
+iv::decision::Quintic_polynomial::~Quintic_polynomial(){
 }
 
-double iv::decition::Quintic_polynomial::calc_point(double t){
+double iv::decision::Quintic_polynomial::calc_point(double t){
     double xt = this->a0 + this->a1 * t + this->a2 * t*t + this->a3 * t*t*t + this->a4 * t*t*t*t + this->a5 * t*t*t*t*t;
     return xt;
 }
 
-double iv::decition::Quintic_polynomial::calc_first_derivative(double t){
+double iv::decision::Quintic_polynomial::calc_first_derivative(double t){
     double xt = this->a1 + 2*this->a2 * t + 3*this->a3 * t*t + 4*this->a4 * t*t*t + 5*this->a5 * t*t*t*t;
     return xt;
 }
 
-double iv::decition::Quintic_polynomial::calc_second_derivative(double t){
+double iv::decision::Quintic_polynomial::calc_second_derivative(double t){
     double xt = 2*this->a2 + 6*this->a3 * t + 12*this->a4 * t*t + 20*this->a5 * t*t*t;
     return xt;
 }
 
-double iv::decition::Quintic_polynomial::calc_third_derivative(double t){
+double iv::decision::Quintic_polynomial::calc_third_derivative(double t){
     double xt = 6*this->a3 + 24*this->a4 * t + 60*this->a5 * t*t;
     return xt;
 }
 
 
 
-iv::decition::Quartic_polynomial::Quartic_polynomial(double xs, double vxs, double axs, double vxe, double axe, double T){
+iv::decision::Quartic_polynomial::Quartic_polynomial(double xs, double vxs, double axs, double vxe, double axe, double T){
     //计算四次多项式系数
     this->xs = xs;
     this->vxs = vxs;
@@ -615,29 +615,29 @@ iv::decition::Quartic_polynomial::Quartic_polynomial(double xs, double vxs, doub
     this->a4 = x(1,0);
 }
 
-iv::decition::Quartic_polynomial::~Quartic_polynomial(){
+iv::decision::Quartic_polynomial::~Quartic_polynomial(){
 }
 
-double iv::decition::Quartic_polynomial::calc_point(double t){
+double iv::decision::Quartic_polynomial::calc_point(double t){
     double xt = this->a0 + this->a1*t + this->a2*t*t + this->a3*t*t*t + this->a4*t*t*t*t;
     return xt;
 }
 
-double iv::decition::Quartic_polynomial::calc_first_derivative(double t){
+double iv::decision::Quartic_polynomial::calc_first_derivative(double t){
     double xt = this->a1 + 2*this->a2*t + 3*this->a3*t*t + 4*this->a4*t*t*t;
     return xt;
 }
 
-double iv::decition::Quartic_polynomial::calc_second_derivative(double t){
+double iv::decision::Quartic_polynomial::calc_second_derivative(double t){
     double xt = 2*this->a2 + 6*this->a3*t + 12*this->a4*t*t;
     return xt;
 }
 
-double iv::decition::Quartic_polynomial::calc_third_derivative(double t){
+double iv::decision::Quartic_polynomial::calc_third_derivative(double t){
     double xt = 6*this->a3 + 24*this->a4*t;
     return xt;
 }
 
-bool iv::decition::FrenetPlanner::comp(const iv::decition::Frenet_path &a, const iv::decition::Frenet_path &b){
+bool iv::decision::FrenetPlanner::comp(const iv::decision::Frenet_path &a, const iv::decision::Frenet_path &b){
     return a.cf < b.cf;
 }

+ 5 - 5
src/decition/decition_brain/decition/adc_planner/frenet_planner.h → src/decition/decition_brain/decision/adc_planner/frenet_planner.h

@@ -4,7 +4,7 @@
 #include "base_planner.h"
 
 namespace iv{
-namespace decition{
+namespace decision{
 
     //x,y分别为frenet轨迹点相对于车辆的x,y轴坐标
     //s,d分别为frenet轨迹点相对于frenet坐标系的s,d轴坐标值
@@ -130,13 +130,13 @@ namespace decition{
          */
         std::vector<iv::Point2D> getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr);
         int chooseRoadByFrenet(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offsetL, double offsetR, iv::LidarGridPtr lidarGridPtr,int roadNow);
-        static iv::decition::FrenetPoint XY2Frenet(double x, double y, const std::vector<Point2D>& gpsTracet);
-        static void Frenet2XY(double *x, double *y, double s, double d, const std::vector<iv::decition::FrenetPoint>& frenetTrace);
+        static iv::decision::FrenetPoint XY2Frenet(double x, double y, const std::vector<Point2D>& gpsTracet);
+        static void Frenet2XY(double *x, double *y, double s, double d, const std::vector<iv::decision::FrenetPoint>& frenetTrace);
         static double distance(double x1, double y1, double x2, double y2);
         static int ClosestWaypoint(double x, double y, const std::vector<Point2D>& gpsTrace);
         static FrenetPoint getFrenetfromXY(double x, double y, const std::vector<iv::Point2D>& gpsTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
-        static void getXYfromFrenet(double *res_x, double *res_y, double s, double d, const std::vector<iv::decition::FrenetPoint>& frenetTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
-        static bool comp(const iv::decition::Frenet_path &a,const iv::decition::Frenet_path &b);
+        static void getXYfromFrenet(double *res_x, double *res_y, double s, double d, const std::vector<iv::decision::FrenetPoint>& frenetTrace,const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
+        static bool comp(const iv::decision::Frenet_path &a,const iv::decision::Frenet_path &b);
 
     private:
         std::vector<iv::Point2D> getGpsTrace_AfterCalcFrenetTrace(const std::vector<iv::Point2D>& gpsTrace,double realsecSpeed);

+ 9 - 9
src/decition/decition_brain/decition/adc_planner/lane_change_planner.cpp → src/decition/decition_brain/decision/adc_planner/lane_change_planner.cpp

@@ -1,16 +1,16 @@
-#include <decition/adc_planner/lane_change_planner.h>
-#include <decition/adc_tools/transfer.h>
-#include <decition/adc_tools/parameter_status.h>
+#include <decision/adc_planner/lane_change_planner.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/adc_tools/parameter_status.h>
 #include <common/constants.h>
 
 #include <math.h>
 
-iv::decition::LaneChangePlanner::LaneChangePlanner(){
+iv::decision::LaneChangePlanner::LaneChangePlanner(){
     this->planner_id = 0;
     this->planner_name = "LaneChange";
 }
 
-iv::decition::LaneChangePlanner::~LaneChangePlanner(){
+iv::decision::LaneChangePlanner::~LaneChangePlanner(){
 }
 
 /**
@@ -24,7 +24,7 @@ iv::decition::LaneChangePlanner::~LaneChangePlanner(){
  * @param lidarGridPtr         激光雷达信息网格
  * @return                     返回一条车辆坐标系下的路径
  */
-std::vector<iv::Point2D> iv::decition::LaneChangePlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
+std::vector<iv::Point2D> iv::decision::LaneChangePlanner::getPath(GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint, double offset, iv::LidarGridPtr lidarGridPtr){
     std::vector<iv::Point2D> trace;
     trace = this->getGpsTrace(now_gps_ins,gpsMapLine,PathPoint);
     if(offset!=0){
@@ -33,7 +33,7 @@ std::vector<iv::Point2D> iv::decition::LaneChangePlanner::getPath(GPS_INS now_gp
     return trace;
 }
 
-bool iv::decition::LaneChangePlanner::checkAvoidEnable(const std::vector<double>& obsDisVector, int roadAim){
+bool iv::decision::LaneChangePlanner::checkAvoidEnable(const std::vector<double>& obsDisVector, int roadAim){
     int roadNow = ServiceParameterStatus.now_road_num;
     if ((obsDisVector[roadAim]>0 && obsDisVector[roadAim]<obsDisVector[roadNow]+ServiceCarStatus.msysparam.vehLenth)||
             (obsDisVector[roadAim]>0 && obsDisVector[roadAim]<15))
@@ -64,7 +64,7 @@ bool iv::decition::LaneChangePlanner::checkAvoidEnable(const std::vector<double>
     return true;
 }
 
-std::vector<iv::Point2D> iv::decition::LaneChangePlanner::getGpsTrace(iv::GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint){
+std::vector<iv::Point2D> iv::decision::LaneChangePlanner::getGpsTrace(iv::GPS_INS now_gps_ins, const std::vector<GPSData>& gpsMapLine, int PathPoint){
     std::vector<iv::Point2D> trace;
 
     if (gpsMapLine.size() > 400 && PathPoint >= 0) {
@@ -137,7 +137,7 @@ std::vector<iv::Point2D> iv::decition::LaneChangePlanner::getGpsTrace(iv::GPS_IN
     return trace;
 }
 
-std::vector<iv::Point2D> iv::decition::LaneChangePlanner::getGpsTraceOffset(const std::vector<Point2D>& gpsTrace, double offset){
+std::vector<iv::Point2D> iv::decision::LaneChangePlanner::getGpsTraceOffset(const std::vector<Point2D>& gpsTrace, double offset){
     if (offset==0)
     {
         return gpsTrace;

+ 1 - 1
src/decition/decition_brain/decition/adc_planner/lane_change_planner.h → src/decition/decition_brain/decision/adc_planner/lane_change_planner.h

@@ -4,7 +4,7 @@
 #include "base_planner.h"
 
 namespace iv{
-namespace decition{
+namespace decision{
     class LaneChangePlanner : public BasePlanner{
     public:
         LaneChangePlanner();

+ 56 - 56
src/decition/decition_brain/decition/adc_tools/compute_00.cpp → src/decition/decition_brain/decision/adc_tools/compute_00.cpp

@@ -1,8 +1,8 @@
-#include <decition/adc_tools/compute_00.h>
-#include <decition/decide_gps_00.h>
-#include <decition/adc_tools/gps_distance.h>
-#include <decition/decition_type.h>
-#include <decition/adc_tools/transfer.h>
+#include <decision/adc_tools/compute_00.h>
+#include <decision/decide_gps_00.h>
+#include <decision/adc_tools/gps_distance.h>
+#include <decision/decition_type.h>
+#include <decision/adc_tools/transfer.h>
 #include <common/constants.h>
 #include <math.h>
 #include <iostream>
@@ -12,35 +12,35 @@ using namespace std;
 
 #define PI (3.1415926535897932384626433832795)
 
-iv::decition::Compute00::Compute00() {
+iv::decision::Compute00::Compute00() {
 
 }
-iv::decition::Compute00::~Compute00() {
+iv::decision::Compute00::~Compute00() {
 
 }
 
 
-double iv::decition::Compute00::angleLimit = 700;
-double iv::decition::Compute00::lastEA = 0;
-double iv::decition::Compute00::lastEP = 0;
-double iv::decition::Compute00::decision_Angle = 0;
-double iv::decition::Compute00::lastAng = 0;
-int iv::decition::Compute00::lastEsrID = -1;
-int  iv::decition::Compute00::lastEsrCount = 0;
-int iv::decition::Compute00::lastEsrIDAvoid = -1;
-int  iv::decition::Compute00::lastEsrCountAvoid = 0;
+double iv::decision::Compute00::angleLimit = 700;
+double iv::decision::Compute00::lastEA = 0;
+double iv::decision::Compute00::lastEP = 0;
+double iv::decision::Compute00::decision_Angle = 0;
+double iv::decision::Compute00::lastAng = 0;
+int iv::decision::Compute00::lastEsrID = -1;
+int  iv::decision::Compute00::lastEsrCount = 0;
+int iv::decision::Compute00::lastEsrIDAvoid = -1;
+int  iv::decision::Compute00::lastEsrCountAvoid = 0;
 
-iv::GPS_INS  iv::decition::Compute00::nearTpoint;
-iv::GPS_INS  iv::decition::Compute00::farTpoint;
-double  iv::decition::Compute00::bocheAngle;
+iv::GPS_INS  iv::decision::Compute00::nearTpoint;
+iv::GPS_INS  iv::decision::Compute00::farTpoint;
+double  iv::decision::Compute00::bocheAngle;
 
 
 
-iv::GPS_INS  iv::decition::Compute00::dTpoint0;
-iv::GPS_INS  iv::decition::Compute00::dTpoint1;
-iv::GPS_INS  iv::decition::Compute00::dTpoint2;
-iv::GPS_INS  iv::decition::Compute00::dTpoint3;
-double  iv::decition::Compute00::dBocheAngle;
+iv::GPS_INS  iv::decision::Compute00::dTpoint0;
+iv::GPS_INS  iv::decision::Compute00::dTpoint1;
+iv::GPS_INS  iv::decision::Compute00::dTpoint2;
+iv::GPS_INS  iv::decision::Compute00::dTpoint3;
+double  iv::decision::Compute00::dBocheAngle;
 
 
 std::vector<int> lastEsrIdVector;
@@ -48,7 +48,7 @@ std::vector<int> lastEsrCountVector;
 
 
 
-int iv::decition::Compute00::getDesiredSpeed(std::vector<GPSData> gpsMap)
+int iv::decision::Compute00::getDesiredSpeed(std::vector<GPSData> gpsMap)
 {
     int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
     int endIndex = gpsMap.size() - 1;
@@ -192,7 +192,7 @@ int iv::decition::Compute00::getDesiredSpeed(std::vector<GPSData> gpsMap)
 
 //首次找点
 
-int iv::decition::Compute00::getFirstNearestPointIndex(GPS_INS rp, std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
+int iv::decision::Compute00::getFirstNearestPointIndex(GPS_INS rp, std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
 {
     int index = -1;
     //	DecideGps00().minDis = iv::MaxValue;
@@ -225,7 +225,7 @@ int iv::decition::Compute00::getFirstNearestPointIndex(GPS_INS rp, std::vector<G
 }
 
 //search pathpoint
-int iv::decition::Compute00::getNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
+int iv::decision::Compute00::getNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap, int lastIndex, double mindis, double maxAngle)
 {
     int index = -1;
     float minDis = 10;
@@ -262,7 +262,7 @@ int iv::decition::Compute00::getNearestPointIndex(GPS_INS rp, const std::vector<
 }
 
 
-double iv::decition::Compute00::getAveDef(std::vector<Point2D> farTrace)
+double iv::decision::Compute00::getAveDef(std::vector<Point2D> farTrace)
 {
     double sum_x = 0;
     double sum_y = 0;
@@ -281,7 +281,7 @@ double iv::decition::Compute00::getAveDef(std::vector<Point2D> farTrace)
 
 
 
-double iv::decition::Compute00::getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX)
+double iv::decision::Compute00::getAvoidAveDef(std::vector<Point2D> farTrace, double avoidX)
 {
     double sum_x = 0;
     double sum_y = 0;
@@ -303,7 +303,7 @@ double iv::decition::Compute00::getAvoidAveDef(std::vector<Point2D> farTrace, do
 
 
 
-double iv::decition::Compute00::getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed) {
+double iv::decision::Compute00::getDecideAngle(std::vector<Point2D>  gpsTrace, double realSpeed) {
 
     double ang = 0;
     double EPos = 0, EAng = 0;
@@ -408,7 +408,7 @@ double iv::decition::Compute00::getDecideAngle(std::vector<Point2D>  gpsTrace, d
 
 
 
-int  iv::decition::Compute00::getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed)
+int  iv::decision::Compute00::getSpeedPointIndex(std::vector<Point2D> gpsTrace, double realSpeed)
 {
     int index = 1;
     double sumdis = 0;
@@ -423,7 +423,7 @@ int  iv::decition::Compute00::getSpeedPointIndex(std::vector<Point2D> gpsTrace,
     return index;
 }
 
-iv::Point2D iv::decition::Compute00::getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+iv::Point2D iv::decision::Compute00::getLidarObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
 
     iv::Point2D obsPoint(-1, -1);
     vector<Point2D> gpsTraceLeft;
@@ -547,7 +547,7 @@ iv::Point2D iv::decition::Compute00::getLidarObsPoint(std::vector<Point2D> gpsTr
 }
 
 //1220
-iv::Point2D iv::decition::Compute00::getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+iv::Point2D iv::decision::Compute00::getLidarRearObsPoint(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
 
     iv::Point2D obsPoint(-1, -1);
     vector<Point2D> gpsTraceLeft;
@@ -664,7 +664,7 @@ iv::Point2D iv::decition::Compute00::getLidarRearObsPoint(std::vector<Point2D> g
 }
 
 
-iv::Point2D iv::decition::Compute00::getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
+iv::Point2D iv::decision::Compute00::getLidarObsPointAvoid(std::vector<Point2D> gpsTrace, iv::LidarGridPtr lidarGridPtr) {
 
     iv::Point2D obsPoint(-1, -1);
     vector<Point2D> gpsTraceLeft;
@@ -810,7 +810,7 @@ iv::Point2D iv::decition::Compute00::getLidarObsPointAvoid(std::vector<Point2D>
 
 
 
-int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum,int *esrPathpoint) {
+int  iv::decision::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int roadNum,int *esrPathpoint) {
     bool isRemove = false;
 
     float xiuzheng=0;
@@ -874,7 +874,7 @@ int  iv::decition::Compute00::getEsrIndex(std::vector<Point2D> gpsTrace,int road
 
 
 
-int  iv::decition::Compute00::getRearEsrIndex(std::vector<Point2D> gpsTrace,int roadNum) {
+int  iv::decision::Compute00::getRearEsrIndex(std::vector<Point2D> gpsTrace,int roadNum) {
     bool isRemove = false;
 
     float xiuzheng = ServiceCarStatus.msysparam.rearRadarGpsXiuzheng;
@@ -977,7 +977,7 @@ int  iv::decition::Compute00::getRearEsrIndex(std::vector<Point2D> gpsTrace,int
 
 
 
-int  iv::decition::Compute00::getEsrIndexAvoid(std::vector<Point2D> gpsTrace) {
+int  iv::decision::Compute00::getEsrIndexAvoid(std::vector<Point2D> gpsTrace) {
     bool isRemove = false;
 
     for (int j = 1; j < gpsTrace.size() - 1 && !isRemove; j++)
@@ -1047,7 +1047,7 @@ int  iv::decition::Compute00::getEsrIndexAvoid(std::vector<Point2D> gpsTrace) {
 
 
 
-double iv::decition::Compute00::getObsSpeed(Point2D obsPoint, double realSecSpeed) {
+double iv::decision::Compute00::getObsSpeed(Point2D obsPoint, double realSecSpeed) {
     double obsSpeed = 0 - realSecSpeed;
     double minDis = iv::MaxValue;
     for (int i = 0; i < 64; i++)
@@ -1073,7 +1073,7 @@ double iv::decition::Compute00::getObsSpeed(Point2D obsPoint, double realSecSpee
 
 
 
-double iv::decition::Compute00::getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX) {
+double iv::decision::Compute00::getDecideAvoidAngle(std::vector<Point2D>  gpsTrace, double realSpeed, float avoidX) {
 
     double ang = 0;
     double EPos = 0, EAng = 0;
@@ -1165,7 +1165,7 @@ double iv::decition::Compute00::getDecideAvoidAngle(std::vector<Point2D>  gpsTra
 }
 
 
-std::vector<iv::GPSData>   iv::decition::Compute00::getBesideGpsMapLine(iv::GPS_INS now_gps_ins, vector<iv::GPSData>gpsMapLine, float avoidX) {
+std::vector<iv::GPSData>   iv::decision::Compute00::getBesideGpsMapLine(iv::GPS_INS now_gps_ins, vector<iv::GPSData>gpsMapLine, float avoidX) {
 
     vector<vector<iv::GPSData>> maps;
     vector<iv::GPSData> gpsMapLineBeside;
@@ -1267,7 +1267,7 @@ std::vector<iv::GPSData>   iv::decition::Compute00::getBesideGpsMapLine(iv::GPS_
 double IEPos = 0, IEang = 0;
 
 
-double iv::decition::Compute00::getDecideAngleByLanePID(double realSpeed) {
+double iv::decision::Compute00::getDecideAngleByLanePID(double realSpeed) {
 
     double ang = 0;
     double EPos = 0, EAng = 0;
@@ -1355,7 +1355,7 @@ double iv::decition::Compute00::getDecideAngleByLanePID(double realSpeed) {
 
 
 
-double iv::decition::Compute00::bocheCompute(GPS_INS nowGps, GPS_INS aimGps) {
+double iv::decision::Compute00::bocheCompute(GPS_INS nowGps, GPS_INS aimGps) {
 
     GaussProjCal(aimGps.gps_lng, aimGps.gps_lat, &aimGps.gps_x, &aimGps.gps_y);
     Point2D pt = Coordinate_Transfer(nowGps.gps_x, nowGps.gps_y, aimGps);
@@ -1531,7 +1531,7 @@ double iv::decition::Compute00::bocheCompute(GPS_INS nowGps, GPS_INS aimGps) {
 
 
 //返回垂直平分线的斜率
-double iv::decition::Compute00::pingfenxian_xielv(double x_1, double y_1, double x_2, double y_2, double angle_1) {
+double iv::decision::Compute00::pingfenxian_xielv(double x_1, double y_1, double x_2, double y_2, double angle_1) {
     double angl, x_3, angle_3;
     if (tan(angle_1 == 0))
     {
@@ -1589,7 +1589,7 @@ double iv::decition::Compute00::pingfenxian_xielv(double x_1, double y_1, double
 
 
 
-double iv::decition::Compute00::getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps) {
+double iv::decision::Compute00::getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps) {
     double heading = nowGps.ins_heading_angle *PI/180;
     double x1 = nowGps.gps_x;
     double y1 = nowGps.gps_y;
@@ -1624,7 +1624,7 @@ double iv::decition::Compute00::getQieXianAngle(GPS_INS nowGps, GPS_INS aimGps)
   */
 
 
-int iv::decition::Compute00::bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps)
+int iv::decision::Compute00::bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps)
 {
 
 
@@ -1711,7 +1711,7 @@ int iv::decition::Compute00::bocheDirectCompute(GPS_INS nowGps, GPS_INS aimGps)
 }
 
 
-double iv::decition::Compute00::min_rad_zhuanxiang(double *R_M, double *min_rad) {
+double iv::decision::Compute00::min_rad_zhuanxiang(double *R_M, double *min_rad) {
     double L_c = 4.749;//车长
     double rad_1;
     double rad_2;
@@ -1728,7 +1728,7 @@ double iv::decition::Compute00::min_rad_zhuanxiang(double *R_M, double *min_rad)
 }
 
 
-double iv::decition::Compute00::qiedian_n(double x_1, double y_1, double R_M,double min_rad, double *x_2, double *y_2, double *real_rad ) {
+double iv::decision::Compute00::qiedian_n(double x_1, double y_1, double R_M,double min_rad, double *x_2, double *y_2, double *real_rad ) {
 
     if (x_1 > 0 && y_1 > 0)
     {
@@ -1747,7 +1747,7 @@ double iv::decition::Compute00::qiedian_n(double x_1, double y_1, double R_M,dou
 }
 
 
-double iv::decition::Compute00::liangzhixian_jiaodian(double x_1,double y_1,double x_2,double y_2,double ange1,double real_rad,double *x_3,double *y_3) {
+double iv::decision::Compute00::liangzhixian_jiaodian(double x_1,double y_1,double x_2,double y_2,double ange1,double real_rad,double *x_3,double *y_3) {
     double b1, b2;
     double k1, k2;
     if (ange1!=(PI*0.5))
@@ -1770,7 +1770,7 @@ double iv::decition::Compute00::liangzhixian_jiaodian(double x_1,double y_1,doub
 }
 
 
-double iv::decition::Compute00::chuizhipingfenxian_xielv(double x_1,double y_1,double ange1,double real_rad,double min_rad,double *angle_3) {
+double iv::decision::Compute00::chuizhipingfenxian_xielv(double x_1,double y_1,double ange1,double real_rad,double min_rad,double *angle_3) {
     double k1, k2;
     double  angle_j;
     k2 = tan(real_rad);
@@ -1804,7 +1804,7 @@ double iv::decition::Compute00::chuizhipingfenxian_xielv(double x_1,double y_1,d
 }
 
 
-double iv::decition::Compute00::yuanxin(double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
+double iv::decision::Compute00::yuanxin(double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
                                         double *x_o_1,double *y_o_1,double *x_o_2,double *y_o_2) {
     double b2, b3, k2, k3;
     b2 = y_2 - tan(real_rad)*x_2;
@@ -1820,7 +1820,7 @@ double iv::decition::Compute00::yuanxin(double x_2,double y_2,double x_3,double
 }
 
 
-double iv::decition::Compute00::yuanxin_qiedian(double ange1,double x_o_1,double y_o_1, double x_o_2,double y_o_2,
+double iv::decision::Compute00::yuanxin_qiedian(double ange1,double x_o_1,double y_o_1, double x_o_2,double y_o_2,
                                                 double x_1,double y_1,double x_2,double y_2,double x_3,double y_3,double real_rad,double angle_3,double R_M,
                                                 double *x_t_n, double *y_t_n, double *x_t_f, double *y_t_f)
 {
@@ -1983,7 +1983,7 @@ double iv::decition::Compute00::yuanxin_qiedian(double ange1,double x_o_1,double
 }
 
 
-int iv::decition::Compute00::getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap)
+int iv::decision::Compute00::getNoAngleNearestPointIndex(GPS_INS rp, const std::vector<GPSData> gpsMap)
 {
     int index = -1;
     int startIndex = 0;     // startIndex = 0 则每一次都是遍历整条地图路线
@@ -2005,7 +2005,7 @@ int iv::decition::Compute00::getNoAngleNearestPointIndex(GPS_INS rp, const std::
 }
 
 
-double iv::decition::Compute00::getObsSpeedByFrenet(Point2D obsPoint, double realSecSpeed,const vector<Point2D> gpsTrace, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps) {
+double iv::decision::Compute00::getObsSpeedByFrenet(Point2D obsPoint, double realSecSpeed,const vector<Point2D> gpsTrace, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps) {
     double obsSpeed = 0 - realSecSpeed;
     double minDis = iv::MaxValue;
     FrenetPoint esr_obs_F_point;
@@ -2022,7 +2022,7 @@ double iv::decition::Compute00::getObsSpeedByFrenet(Point2D obsPoint, double rea
                 {
                     minDis = tmpDis;
 //                    esr_obs_F_point = iv::decition::FrenetPlanner::XY2Frenet(xxx, yyy, gpsTrace);
-                    esr_obs_F_point = iv::decition::FrenetPlanner::getFrenetfromXY(xxx, yyy, gpsTrace,gpsMap,pathpoint,nowGps);
+                    esr_obs_F_point = iv::decision::FrenetPlanner::getFrenetfromXY(xxx, yyy, gpsTrace,gpsMap,pathpoint,nowGps);
 //                    obsSpeed = ServiceCarStatus.obs_radar[i].speed_y;
                     double speedx=ServiceCarStatus.obs_radar[i].speed_x;  //障碍物相对于车辆x轴的速度
                     double speedy=ServiceCarStatus.obs_radar[i].speed_y;  //障碍物相对于车辆y轴的速度
@@ -2040,7 +2040,7 @@ double iv::decition::Compute00::getObsSpeedByFrenet(Point2D obsPoint, double rea
 }
 
 
-int iv::decition::Compute00::getEsrIndexByFrenet(std::vector<Point2D> gpsTrace, FrenetPoint &esrObsPoint, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps){
+int iv::decision::Compute00::getEsrIndexByFrenet(std::vector<Point2D> gpsTrace, FrenetPoint &esrObsPoint, std::vector<iv::GPSData> gpsMap,int pathpoint,GPS_INS nowGps){
     double minDistance = numeric_limits<double>::max();
     int minDis_index=-1;
 
@@ -2052,7 +2052,7 @@ int iv::decition::Compute00::getEsrIndexByFrenet(std::vector<Point2D> gpsTrace,
 
             //将毫米波障碍物位置转换到frenet坐标系下
 //            esrObsPoint = iv::decition::FrenetPlanner::XY2Frenet(xxx,yyy,gpsTrace);
-            esrObsPoint = iv::decition::FrenetPlanner::getFrenetfromXY(xxx,yyy,gpsTrace,gpsMap,pathpoint,nowGps);
+            esrObsPoint = iv::decision::FrenetPlanner::getFrenetfromXY(xxx,yyy,gpsTrace,gpsMap,pathpoint,nowGps);
 
             //如果障碍物与道路的横向距离d<=3.0*ServiceCarStatus.msysparam.vehWidth / 4.0,则认为道路上有障碍物。
             //s则可理解为障碍物距离。为障碍物与车辆沿着道路方向的距离,而不是空间上的x或y坐标或者直线距离。

+ 4 - 4
src/decition/decition_brain/decition/adc_tools/compute_00.h → src/decition/decition_brain/decision/adc_tools/compute_00.h

@@ -4,12 +4,12 @@
 
 #include <common/gps_type.h>
 #include <common/obstacle_type.h>
-#include <decition/decition_type.h>
-#include<vector> 
-#include <decition/decide_gps_00.h>
+#include <decision/decition_type.h>
+#include <vector>
+#include <decision/decide_gps_00.h>
 
 namespace iv {
-    namespace decition {
+    namespace decision {
     //根据传感器传输来的信息作出决策
         class Compute00 {
         public:

+ 0 - 0
src/decition/decition_brain/decition/adc_tools/dubins.cpp → src/decition/decition_brain/decision/adc_tools/dubins.cpp


+ 0 - 0
src/decition/decition_brain/decition/adc_tools/dubins.h → src/decition/decition_brain/decision/adc_tools/dubins.h


+ 1 - 1
src/decition/decition_brain/decition/adc_tools/gnss_coordinate_convert.cpp → src/decition/decition_brain/decision/adc_tools/gnss_coordinate_convert.cpp

@@ -1,4 +1,4 @@
-#include <decition/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
 
 void gps2xy(double J4, double K4, double *x, double *y)
 {

+ 0 - 0
src/decition/decition_brain/decition/adc_tools/gnss_coordinate_convert.h → src/decition/decition_brain/decision/adc_tools/gnss_coordinate_convert.h


+ 5 - 5
src/decition/decition_brain/decition/adc_tools/gps_distance.cpp → src/decition/decition_brain/decision/adc_tools/gps_distance.cpp

@@ -1,16 +1,16 @@
-#include <decition/adc_tools/gps_distance.h>
+#include <decision/adc_tools/gps_distance.h>
 #include <math.h>
 #define M_PI (3.1415926535897932384626433832795)
 
 // 计算弧度
-double iv::decition::rad(double d)
+double iv::decision::rad(double d)
 {
     const double PI = 3.1415926535898;
     return d * PI / 180.0;
 }
 
 // 从两个gps坐标点(经纬度)获得两点的直线距离,单位是米
-double iv::decition::CalcDistance(double fLati1, double fLong1, double fLati2, double fLong2)
+double iv::decision::CalcDistance(double fLati1, double fLong1, double fLati2, double fLong2)
 {
     const float EARTH_RADIUS = 6378.137;
     double radLat1 = rad(fLati1);
@@ -26,7 +26,7 @@ double iv::decition::CalcDistance(double fLati1, double fLong1, double fLati2, d
 
 
 // 从直角坐标两点的直线距离,单位是米
-double iv::decition::DirectDistance(double x1, double y1, double x2, double y2)
+double iv::decision::DirectDistance(double x1, double y1, double x2, double y2)
 {
     double s = sqrt(pow((x1-x2), 2) +pow((y1-y2), 2));
     return s;
@@ -34,7 +34,7 @@ double iv::decition::DirectDistance(double x1, double y1, double x2, double y2)
 
 
 // 从直角坐标计算两点的夹角
-double iv::decition::DirectAngle(double x1, double y1, double x2, double y2)
+double iv::decision::DirectAngle(double x1, double y1, double x2, double y2)
 {
     double angle = atan((y2 - y1) / (x2 - x1)) * 180 / M_PI;
     return angle;

+ 1 - 1
src/decition/decition_brain/decition/gps_distance.h → src/decition/decition_brain/decision/adc_tools/gps_distance.h

@@ -3,7 +3,7 @@
 #define _IV_DECITION_GPS_DISTANCE_
 
 namespace iv {
-	namespace decition {
+	namespace decision {
         // 计算弧度
 		double rad(double d);
 

+ 3 - 3
src/decition/decition_brain/decition/adc_tools/parameter_status.h → src/decition/decition_brain/decision/adc_tools/parameter_status.h

@@ -10,7 +10,7 @@
 #include <control/vv7.h>
 
 namespace iv {
-    namespace decition {
+    namespace decision {
         class ParameterStatus : public boost::noncopyable
         {
         public:
@@ -99,9 +99,9 @@ namespace iv {
 
 
     };
-        typedef boost::serialization::singleton<iv::decition::ParameterStatus> ParameterStatusSingleton;
+        typedef boost::serialization::singleton<iv::decision::ParameterStatus> ParameterStatusSingleton;
 }
-#define ServiceParameterStatus iv::decition::ParameterStatusSingleton::get_mutable_instance()
+#define ServiceParameterStatus iv::decision::ParameterStatusSingleton::get_mutable_instance()
 
 }
 

+ 8 - 8
src/decition/decition_brain/decition/adc_tools/transfer.cpp → src/decition/decition_brain/decision/adc_tools/transfer.cpp

@@ -1,5 +1,5 @@
-#include <decition/adc_tools/transfer.h>
-#include <decition/decition_type.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/decition_type.h>
 #include <math.h>
 #include <iostream>
 #include <fstream>
@@ -9,7 +9,7 @@ using namespace std;
 
 
 ///大地转车体
-iv::Point2D iv::decition::Coordinate_Transfer(double x_path, double y_path, iv::GPS_INS pos)
+iv::Point2D iv::decision::Coordinate_Transfer(double x_path, double y_path, iv::GPS_INS pos)
 {
     double x_vehicle, y_vehicle;
     double theta = atan2(x_path - pos.gps_x, y_path - pos.gps_y);
@@ -23,7 +23,7 @@ iv::Point2D iv::decition::Coordinate_Transfer(double x_path, double y_path, iv::
 }
 
 ///车体转大地
-iv::GPS_INS iv::decition::Coordinate_UnTransfer(double x_path, double y_path, iv::GPS_INS pos)
+iv::GPS_INS iv::decision::Coordinate_UnTransfer(double x_path, double y_path, iv::GPS_INS pos)
 {
     iv::GPS_INS gps_ins;
     double x_vehicle, y_vehicle;
@@ -40,12 +40,12 @@ iv::GPS_INS iv::decition::Coordinate_UnTransfer(double x_path, double y_path, iv
     return  gps_ins;
 }
 
-double iv::decition::GetDistance(iv::Point2D x1, iv::Point2D x2)
+double iv::decision::GetDistance(iv::Point2D x1, iv::Point2D x2)
 {
     return sqrt((x1.x - x2.x) * (x1.x - x2.x) + (x1.y - x2.y) * (x1.y - x2.y));
 }
 
-double iv::decition::GetDistance(iv::GPS_INS p1, iv::GPS_INS p2)
+double iv::decision::GetDistance(iv::GPS_INS p1, iv::GPS_INS p2)
 {
     return sqrt((p1.gps_x - p2.gps_x) * (p1.gps_x - p2.gps_x) + (p1.gps_y - p2.gps_y) * (p1.gps_y - p2.gps_y));
 }
@@ -54,7 +54,7 @@ double iv::decition::GetDistance(iv::GPS_INS p1, iv::GPS_INS p2)
 
 
 //GPS转大地坐标
-void iv::decition::BLH2XYZ(iv::GPS_INS gp)
+void iv::decision::BLH2XYZ(iv::GPS_INS gp)
 {
     int nFlag = 2;
 
@@ -126,7 +126,7 @@ void iv::decition::BLH2XYZ(iv::GPS_INS gp)
 }
 
 
-double iv::decition::GetL0InDegree(double dLIn)
+double iv::decision::GetL0InDegree(double dLIn)
 {
     //3°带求带号及中央子午线经度(d的形式)
     //具体公式请参阅《常用大地坐标系及其变换》朱华统,解放军出版社138页

+ 2 - 2
src/decition/decition_brain/decition/transfer.h → src/decition/decition_brain/decision/adc_tools/transfer.h

@@ -3,11 +3,11 @@
 #define _IV_DECITION_TRANSFER_
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include<vector> 
 
 namespace iv {
-    namespace decition {
+    namespace decision {
         //根据传感器传输来的信息作出决策
 
         double GetL0InDegree(double dLIn);

+ 49 - 49
src/decition/decition_brain/decition/brain.cpp → src/decition/decition_brain/decision/brain.cpp

@@ -1,10 +1,10 @@
- #include <decition/brain.h>
+#include <decision/brain.h>
 #include <fstream>
 #include <time.h>
 #include <exception>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
 #include <common/logout.h>
-#include <decition/adc_tools/transfer.h>
+#include <decision/adc_tools/transfer.h>
 
 #include <iostream>
 #include "xmlparam.h"
@@ -21,8 +21,8 @@ extern std::string gstrmemchassis;
 #define LOG_ENABLE
 
 namespace iv {
-namespace decition {
-iv::decition::BrainDecition * gbrain;
+namespace decision {
+iv::decision::BrainDecition * gbrain;
 
 
         void ListenTraceMap(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
@@ -110,7 +110,7 @@ iv::decition::BrainDecition * gbrain;
 
 
 
-iv::decition::BrainDecition::BrainDecition()
+iv::decision::BrainDecition::BrainDecition()
 {
     //    mpasd = new Adcivstatedb();
     look1 = 0.0;
@@ -129,40 +129,40 @@ iv::decition::BrainDecition::BrainDecition()
     eyes = new iv::perception::Eyes();
     //	decitionMaker = new iv::decition::DecitionMaker();
 
-    decitionGps00 = new iv::decition::DecideGps00();
-    decitionLine00=new iv::decition::DecideLine00();
+    decitionGps00 = new iv::decision::DecideGps00();
+    decitionLine00=new iv::decision::DecideLine00();
 
     //	decitionGpsUnit = new iv::decition::DecideGpsUnit();
 
     //	decitionExecuter = new iv::decition::DecitionExecuter(controller);
 
-    iv::decition::gbrain = this;
+    iv::decision::gbrain = this;
 
 
-    mpa = iv::modulecomm::RegisterRecv("tracemap",iv::decition::ListenTraceMap);
+    mpa = iv::modulecomm::RegisterRecv("tracemap",iv::decision::ListenTraceMap);
 
-    mpvbox = iv::modulecomm::RegisterRecv("vbox",iv::decition::ListenVbox);
+    mpvbox = iv::modulecomm::RegisterRecv("vbox",iv::decision::ListenVbox);
 
     mpaVechicleState = iv::modulecomm::RegisterSend(gstrmembrainstate.data(),10000,10);
 
 
     mpaToPlatform = iv::modulecomm::RegisterSend("toplatform",10*sizeof(iv::platform::PlatFormMsg),10);
-    mpaDecition = iv::modulecomm::RegisterSend(gstrmemdecition.data(),10*sizeof(iv::decition::DecitionBasic),1);
+    mpaDecition = iv::modulecomm::RegisterSend(gstrmemdecition.data(),10*sizeof(iv::decision::DecitionBasic),1);
 
-    mpaPAD = iv::modulecomm::RegisterRecv("pad",iv::decition::ListenPAD);
-    mpaHMI = iv::modulecomm::RegisterRecv("hmi",iv::decition::ListenHMI);
+    mpaPAD = iv::modulecomm::RegisterRecv("pad",iv::decision::ListenPAD);
+    mpaHMI = iv::modulecomm::RegisterRecv("hmi",iv::decision::ListenHMI);
 
-    mpaPlatform = iv::modulecomm::RegisterRecv("platformfrom",iv::decition::ListenPlatform);
+    mpaPlatform = iv::modulecomm::RegisterRecv("platformfrom",iv::decision::ListenPlatform);
 
-    mpaGroup = iv::modulecomm::RegisterRecv("p900_send",iv::decition::ListenGroup);
+    mpaGroup = iv::modulecomm::RegisterRecv("p900_send",iv::decision::ListenGroup);
  //   iv::modulecomm::RegisterRecv("map_index",ListenMap_change_req);
 
-    v2x = iv::modulecomm::RegisterRecv("v2x",iv::decition::Listenv2x);
-    ultra = iv::modulecomm::RegisterRecv("ultra",iv::decition::Listenultra);
+    v2x = iv::modulecomm::RegisterRecv("v2x",iv::decision::Listenv2x);
+    ultra = iv::modulecomm::RegisterRecv("ultra",iv::decision::Listenultra);
 
     mpamapreq = iv::modulecomm::RegisterSend("mapreq",1000,1);
 
-    ModuleFun funchassis =std::bind(&iv::decition::BrainDecition::UpdateChassis,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
+    ModuleFun funchassis =std::bind(&iv::decision::BrainDecition::UpdateChassis,this,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5);
     void * pa = iv::modulecomm::RegisterRecvPlus(gstrmemchassis.data(),funchassis);
 
     mpaPlanTrace = iv::modulecomm::RegisterSend("plantrace",100000,1);
@@ -174,29 +174,29 @@ iv::decition::BrainDecition::BrainDecition()
 
 }
 
-iv::decition::BrainDecition::~BrainDecition()
+iv::decision::BrainDecition::~BrainDecition()
 {
 }
 
 
-void iv::decition::BrainDecition::inialize() {
+void iv::decision::BrainDecition::inialize() {
     //	controller->inialize();
     eyes->inialize();
     //    carcall->start();
 }
 
 
-void iv::decition::BrainDecition::run() {
+void iv::decision::BrainDecition::run() {
 
     double last = 0;
 
-    iv::decition::Decition decition_gps = NULL;
-    iv::decition::Decition decition_lidar = NULL;
-    iv::decition::Decition decition_radar = NULL;
-    iv::decition::Decition decition_camera = NULL;
-    iv::decition::Decition decition_localmap = NULL;
+    iv::decision::Decition decition_gps = NULL;
+    iv::decision::Decition decition_lidar = NULL;
+    iv::decision::Decition decition_radar = NULL;
+    iv::decision::Decition decition_camera = NULL;
+    iv::decision::Decition decition_localmap = NULL;
 
-    iv::decition::Decition dgtemp(new iv::decition::DecitionBasic);
+    iv::decision::Decition dgtemp(new iv::decision::DecitionBasic);
     decition_gps = dgtemp;
     decition_gps->brake = 0;
     decition_gps->accelerator = 0;
@@ -556,7 +556,7 @@ void iv::decition::BrainDecition::run() {
 
         iv::ObsLiDAR obs_lidar_tmp(new std::vector<iv::ObstacleBasic>);
         iv::ObsRadar obs_radar_tmp(new std::vector<iv::ObstacleBasic>);
-        iv::decition::Decition decition_final(new iv::decition::DecitionBasic);
+        iv::decision::Decition decition_final(new iv::decision::DecitionBasic);
 
         if (obs_lidar_) {	//激光雷达有障碍物
             //          std::cout<<"obs lidar size = "<<obs_lidar_->size()<<std::endl;
@@ -806,7 +806,7 @@ void iv::decition::BrainDecition::run() {
     std::cout << "\n\n\n\n\n\n\n\n\n\n\nbrain线程退出\n" << std::endl;
 }
 
-bool iv::decition::BrainDecition::loadMapFromFile(std::string fileName) {
+bool iv::decision::BrainDecition::loadMapFromFile(std::string fileName) {
     std::ifstream fis(fileName);//获取文件
     std::string line;
     std::vector<std::string> des;
@@ -856,7 +856,7 @@ bool iv::decition::BrainDecition::loadMapFromFile(std::string fileName) {
     return true;
 }
 
-bool iv::decition::BrainDecition::loadMapFromFile2(std::string fileName) {
+bool iv::decision::BrainDecition::loadMapFromFile2(std::string fileName) {
     std::ifstream fis(fileName);//获取文件
     std::string line;
     std::vector<std::string> des;
@@ -892,7 +892,7 @@ bool iv::decition::BrainDecition::loadMapFromFile2(std::string fileName) {
     return true;
 }
 
-bool iv::decition::BrainDecition::loadMapFromFile3(std::string fileName) {
+bool iv::decision::BrainDecition::loadMapFromFile3(std::string fileName) {
     std::ifstream fis(fileName);//获取文件
     std::string line;
     std::vector<std::string> des;
@@ -928,7 +928,7 @@ bool iv::decition::BrainDecition::loadMapFromFile3(std::string fileName) {
     return true;
 }
 
-bool iv::decition::BrainDecition::loadMapFromFile4(std::string fileName) {
+bool iv::decision::BrainDecition::loadMapFromFile4(std::string fileName) {
     std::ifstream fis(fileName);//获取文件
     std::string line;
     std::vector<std::string> des;
@@ -964,17 +964,17 @@ bool iv::decition::BrainDecition::loadMapFromFile4(std::string fileName) {
     return true;
 }
 
-void iv::decition::BrainDecition::start() {
-    thread_run = new boost::thread(boost::bind(&iv::decition::BrainDecition::run, this));
+void iv::decision::BrainDecition::start() {
+    thread_run = new boost::thread(boost::bind(&iv::decision::BrainDecition::run, this));
 }
 
-void iv::decition::BrainDecition::stop() {
+void iv::decision::BrainDecition::stop() {
     //    carcall->stop();
     thread_run->interrupt();
     thread_run->join();
 }
 
-void iv::decition::BrainDecition::UpdateMap(const char *mapdata, const int mapdatasize)
+void iv::decision::BrainDecition::UpdateMap(const char *mapdata, const int mapdatasize)
 {
     //    std::cout<<"update map "<<std::endl;
     int gpsunitsize = sizeof(iv::GPS_INS);
@@ -1036,7 +1036,7 @@ void iv::decition::BrainDecition::UpdateMap(const char *mapdata, const int mapda
     }
 }
 
-void iv::decition::BrainDecition::ShareDecition(iv::decition::Decition decition)
+void iv::decision::BrainDecition::ShareDecition(iv::decision::Decition decition)
 {
     iv::brain::decition xdecition;
     xdecition.set_accelerator(decition->accelerator);
@@ -1111,7 +1111,7 @@ void iv::decition::BrainDecition::ShareDecition(iv::decition::Decition decition)
     }
 }
 
-void iv::decition::BrainDecition::ShareBrainstate(iv::brain::brainstate xbs)
+void iv::decision::BrainDecition::ShareBrainstate(iv::brain::brainstate xbs)
 {
     int nsize = xbs.ByteSize();
     char * str = new char[nsize];
@@ -1127,7 +1127,7 @@ void iv::decition::BrainDecition::ShareBrainstate(iv::brain::brainstate xbs)
     }
 }
 
-void iv::decition::BrainDecition::UpdateHMI(const char *pdata, const int ndatasize)
+void iv::decision::BrainDecition::UpdateHMI(const char *pdata, const int ndatasize)
 {
     if(ndatasize < sizeof(iv::hmi::HMIBasic))return;
 
@@ -1156,7 +1156,7 @@ void iv::decition::BrainDecition::UpdateHMI(const char *pdata, const int ndatasi
 
 }
 
-void iv::decition::BrainDecition::UpdatePAD(const char *pdata, const int ndatasize)
+void iv::decision::BrainDecition::UpdatePAD(const char *pdata, const int ndatasize)
 {
 //    if(ndatasize < sizeof(iv::hmi::HMIBasic))return;
 
@@ -1185,7 +1185,7 @@ void iv::decition::BrainDecition::UpdatePAD(const char *pdata, const int ndatasi
 
 }
 
-void iv::decition::BrainDecition::UpdatePlatform(const char *pdata, const int ndatasize)
+void iv::decision::BrainDecition::UpdatePlatform(const char *pdata, const int ndatasize)
 {
     if(ndatasize < sizeof(iv::platform::PlatFormMsg))return;
 
@@ -1201,7 +1201,7 @@ void iv::decition::BrainDecition::UpdatePlatform(const char *pdata, const int nd
 
 }
 
-void iv::decition::BrainDecition::UpdateChassis(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
+void iv::decision::BrainDecition::UpdateChassis(const char *strdata, const unsigned int nSize, const unsigned int index, const QDateTime *dt, const char *strmemname)
 {
     iv::chassis xchassis;
     static int ncount = 0;
@@ -1253,7 +1253,7 @@ void iv::decition::BrainDecition::UpdateChassis(const char *strdata, const unsig
     //    }
 }
 
-void iv::decition::BrainDecition::UpdateGroupInfo(const char *pdata, const int ndatasize){
+void iv::decision::BrainDecition::UpdateGroupInfo(const char *pdata, const int ndatasize){
 
     iv::radio::radio_send group_message;
     if(false == group_message.ParseFromArray(pdata,ndatasize))
@@ -1274,7 +1274,7 @@ void iv::decition::BrainDecition::UpdateGroupInfo(const char *pdata, const int n
 
 }
 
-void iv::decition::BrainDecition::UpdateVbox(const char *pdata, const int ndatasize){
+void iv::decision::BrainDecition::UpdateVbox(const char *pdata, const int ndatasize){
 
     iv::vbox::vbox group_message;
     if(false == group_message.ParseFromArray(pdata,ndatasize))
@@ -1302,7 +1302,7 @@ void iv::decition::BrainDecition::UpdateVbox(const char *pdata, const int ndatas
 
 }
 
-void iv::decition::BrainDecition::Updatev2x(const char *pdata, const int ndatasize){
+void iv::decision::BrainDecition::Updatev2x(const char *pdata, const int ndatasize){
 
     iv::v2x::v2x v2x_message;
     if(false == v2x_message.ParseFromArray(pdata,ndatasize))
@@ -1365,7 +1365,7 @@ void iv::decition::BrainDecition::Updatev2x(const char *pdata, const int ndatasi
 
 }
 
-void iv::decition::BrainDecition::Updateultra(const char *pdata, const int ndatasize)
+void iv::decision::BrainDecition::Updateultra(const char *pdata, const int ndatasize)
 {
     iv::ultrasonic::ultrasonic ultraarry;
     if(false == ultraarry.ParseFromArray(pdata,ndatasize))
@@ -1389,11 +1389,11 @@ void iv::decition::BrainDecition::Updateultra(const char *pdata, const int ndata
 }
 
 
-void iv::decition::BrainDecition::UpdateSate(){
+void iv::decision::BrainDecition::UpdateSate(){
      decitionGps00->isFirstRun=true;
 }
 
-void iv::decition::BrainDecition::adjuseGpsLidarPosition(){
+void iv::decision::BrainDecition::adjuseGpsLidarPosition(){
 
     ServiceCarStatus.msysparam.lidarGpsXiuzheng -=  ServiceCarStatus.msysparam.gpsOffset_y;
     ServiceCarStatus.msysparam.radarGpsXiuzheng -=  ServiceCarStatus.msysparam.gpsOffset_y;

+ 11 - 11
src/decition/decition_brain/decition/brain.h → src/decition/decition_brain/decision/brain.h

@@ -11,12 +11,12 @@
 //#include <control/controller.h>
 //#include <control/can.h>
 #include <perception/eyes.h>
-#include <decition/decition_maker.h>
+#include <decision/decition_maker.h>
 //#include <decition/decition_executer.h>
-#include <decition/decition_voter.h>
-#include <decition/decide_gps_00.h>
-#include <decition/decide_line_00.h>
-#include <decition/adc_tools/compute_00.h>
+#include <decision/decition_voter.h>
+#include <decision/decide_gps_00.h>
+#include <decision/decide_line_00.h>
+#include <decision/adc_tools/compute_00.h>
 #include <perception/sensor.h>
 #include <perception/sensor_camera.h>
 #include <perception/sensor_gps.h>
@@ -49,7 +49,7 @@
 #include "fanyaapi.h"
 
 namespace iv {
-	namespace decition {
+	namespace decision {
 		class BrainDecition
 		{
 		public:
@@ -93,12 +93,12 @@ namespace iv {
 		//	iv::perception::Eyes* eyes;							//眼睛
  //           iv::carcalling::carcalling* carcall;
 			iv::perception::Eyes* eyes;
-			iv::decition::DecitionMaker* decitionMaker;			//决策器
-			iv::decition::DecitionVoter* decitionVoter;			//决策仲裁 判断器
+			iv::decision::DecitionMaker* decitionMaker;			//决策器
+			iv::decision::DecitionVoter* decitionVoter;			//决策仲裁 判断器
 //			iv::decition::DecitionExecuter* decitionExecuter;	//决策执行器
 
-            iv::decition::DecideGps00* decitionGps00;			//决策器
-              iv::decition::DecideLine00* decitionLine00;
+            iv::decision::DecideGps00* decitionGps00;			//决策器
+              iv::decision::DecideLine00* decitionLine00;
 
 //			boost::shared_ptr<iv::control::Controller> controller;	//实际车辆控制器
 
@@ -131,7 +131,7 @@ namespace iv {
             void * mpaObsTraceRight;
 
 
-            void ShareDecition(iv::decition::Decition decition);
+            void ShareDecition(iv::decision::Decition decision);
             void ShareBrainstate(iv::brain::brainstate xbs);
 
         private:

+ 0 - 0
src/decition/decition_brain/decition/compute_00.cpp → src/decition/decition_brain/decision/compute_00.cpp


+ 4 - 4
src/decition/decition_brain/decition/compute_00.h → src/decition/decition_brain/decision/compute_00.h

@@ -4,12 +4,12 @@
 
 #include <common/gps_type.h>
 #include <common/obstacle_type.h>
-#include <decition/decition_type.h>
-#include<vector> 
-#include <decition/decide_gps_00.h>
+#include <decision/decition_type.h>
+#include <vector>
+#include <decision/decide_gps_00.h>
 
 namespace iv {
-    namespace decition {
+    namespace decision {
     //根据传感器传输来的信息作出决策
         class Compute00 {
         public:

+ 0 - 0
src/decition/decition_brain/decition/decide_from_gps.cpp → src/decition/decition_brain/decision/decide_from_gps.cpp


+ 114 - 114
src/decition/decition_brain/decition/decide_gps_00.cpp → src/decition/decition_brain/decision/decide_gps_00.cpp

@@ -1,9 +1,9 @@
-#include <decition/decide_gps_00.h>
-#include <decition/adc_tools/compute_00.h>
-#include <decition/adc_tools/gps_distance.h>
-#include <decition/decition_type.h>
-#include <decition/adc_tools/transfer.h>
-#include <decition/obs_predict.h>
+#include <decision/decide_gps_00.h>
+#include <decision/adc_tools/compute_00.h>
+#include <decision/adc_tools/gps_distance.h>
+#include <decision/decition_type.h>
+#include <decision/adc_tools/transfer.h>
+#include <decision/obs_predict.h>
 #include <common/constants.h>
 #include <common/car_status.h>
 #include <math.h>
@@ -11,10 +11,10 @@
 #include <fstream>
 #include <control/can.h>
 #include <time.h>
-#include <decition/adc_controller/base_controller.h>
-#include <decition/adc_controller/pid_controller.h>
-#include <decition/adc_planner/lane_change_planner.h>
-#include <decition/adc_planner/frenet_planner.h>
+#include <decision/adc_controller/base_controller.h>
+#include <decision/adc_controller/pid_controller.h>
+#include <decision/adc_planner/lane_change_planner.h>
+#include <decision/adc_planner/frenet_planner.h>
 #include <QTime>
 
 using namespace std;
@@ -24,59 +24,59 @@ extern iv::Ivlog * givlog;
 
 #define PI (3.1415926535897932384626433832795)
 
-iv::decition::DecideGps00::DecideGps00() {
+iv::decision::DecideGps00::DecideGps00() {
 
 }
-iv::decition::DecideGps00::~DecideGps00() {
+iv::decision::DecideGps00::~DecideGps00() {
 
 }
 
-float iv::decition::DecideGps00::xiuzhengCs=0;
+float iv::decision::DecideGps00::xiuzhengCs=0;
 
-int iv::decition::DecideGps00::PathPoint = -1;
-double iv::decition::DecideGps00::minDis = iv::MaxValue;
-double iv::decition::DecideGps00::maxAngle = iv::MinValue;
+int iv::decision::DecideGps00::PathPoint = -1;
+double iv::decision::DecideGps00::minDis = iv::MaxValue;
+double iv::decision::DecideGps00::maxAngle = iv::MinValue;
 //int iv::decition::DecideGps00::lastGpsIndex = iv::MaxValue;
-int iv::decition::DecideGps00::lastGpsIndex = 0;
-double iv::decition::DecideGps00::controlSpeed = 0;
-double iv::decition::DecideGps00::controlBrake = 0;
-double iv::decition::DecideGps00::controlAng = 0;
-double iv::decition::DecideGps00::Iv = 0;
-double iv::decition::DecideGps00::lastU = 0;
-double iv::decition::DecideGps00::lastVt = 0;
-double iv::decition::DecideGps00::lastEv = 0;
-
-int iv::decition::DecideGps00::gpsLineParkIndex = 0;
-int iv::decition::DecideGps00::gpsMapParkIndex = 0;
-double iv::decition::DecideGps00::lastDistance = MaxValue;
-double iv::decition::DecideGps00::lastPreObsDistance = MaxValue;
-double iv::decition::DecideGps00::obsDistance = -1;
-double iv::decition::DecideGps00::obsSpeed=0;
-double iv::decition::DecideGps00::obsDistanceAvoid = -1;
-double iv::decition::DecideGps00::lastDistanceAvoid = -1;
-
-double iv::decition::DecideGps00::lidarDistance = -1;
-double iv::decition::DecideGps00::myesrDistance = -1;
-double iv::decition::DecideGps00::lastLidarDis = -1;
-
-bool iv::decition::DecideGps00::parkMode = false;
-bool iv::decition::DecideGps00::readyParkMode = false;
-
-bool iv::decition::DecideGps00::zhucheMode = false;
-bool iv::decition::DecideGps00::readyZhucheMode = false;
-bool iv::decition::DecideGps00::hasZhuched = false;
-
-double iv::decition::DecideGps00::lastLidarDisAvoid = -1;
-double iv::decition::DecideGps00::lidarDistanceAvoid = -1;
-
-int iv::decition::DecideGps00::finishPointNum = -1;
-int iv::decition::DecideGps00::zhuchePointNum = 0;
+int iv::decision::DecideGps00::lastGpsIndex = 0;
+double iv::decision::DecideGps00::controlSpeed = 0;
+double iv::decision::DecideGps00::controlBrake = 0;
+double iv::decision::DecideGps00::controlAng = 0;
+double iv::decision::DecideGps00::Iv = 0;
+double iv::decision::DecideGps00::lastU = 0;
+double iv::decision::DecideGps00::lastVt = 0;
+double iv::decision::DecideGps00::lastEv = 0;
+
+int iv::decision::DecideGps00::gpsLineParkIndex = 0;
+int iv::decision::DecideGps00::gpsMapParkIndex = 0;
+double iv::decision::DecideGps00::lastDistance = MaxValue;
+double iv::decision::DecideGps00::lastPreObsDistance = MaxValue;
+double iv::decision::DecideGps00::obsDistance = -1;
+double iv::decision::DecideGps00::obsSpeed=0;
+double iv::decision::DecideGps00::obsDistanceAvoid = -1;
+double iv::decision::DecideGps00::lastDistanceAvoid = -1;
+
+double iv::decision::DecideGps00::lidarDistance = -1;
+double iv::decision::DecideGps00::myesrDistance = -1;
+double iv::decision::DecideGps00::lastLidarDis = -1;
+
+bool iv::decision::DecideGps00::parkMode = false;
+bool iv::decision::DecideGps00::readyParkMode = false;
+
+bool iv::decision::DecideGps00::zhucheMode = false;
+bool iv::decision::DecideGps00::readyZhucheMode = false;
+bool iv::decision::DecideGps00::hasZhuched = false;
+
+double iv::decision::DecideGps00::lastLidarDisAvoid = -1;
+double iv::decision::DecideGps00::lidarDistanceAvoid = -1;
+
+int iv::decision::DecideGps00::finishPointNum = -1;
+int iv::decision::DecideGps00::zhuchePointNum = 0;
 
 ///kkcai, 2020-01-03
-bool iv::decition::DecideGps00::isFirstRun = true;
+bool iv::decision::DecideGps00::isFirstRun = true;
 //////////////////////////////////////////////
 
-float iv::decition::DecideGps00::minDecelerate=0;
+float iv::decision::DecideGps00::minDecelerate=0;
 //bool iv::decition::DecideGps00::startingFlag = true;//起步标志,在起步时需要进行frenet规划。
 
 double offset_real = 0;
@@ -185,7 +185,7 @@ std::vector<double> lastDistanceVector(roadSum, -1);
 bool qiedianCount = false;
 //日常展示
 
-iv::decition::Decition iv::decition::DecideGps00::getDecideFromGPS(GPS_INS now_gps_ins,
+iv::decision::Decition iv::decision::DecideGps00::getDecideFromGPS(GPS_INS now_gps_ins,
                                                                    const std::vector<GPSData> gpsMapLine,
                                                                    iv::LidarGridPtr lidarGridPtr,
                                                                    std::vector<iv::Perception::PerceptionOutput> lidar_per,
@@ -1996,7 +1996,7 @@ iv::decition::Decition iv::decition::DecideGps00::getDecideFromGPS(GPS_INS now_g
     return gps_decition;
 }
 
-iv::Station iv::decition::DecideGps00::getNearestStation(iv::GPS_INS now_gps_ins,std::vector<Station> station_n,std::vector<GPSData> gpsMap){
+iv::Station iv::decision::DecideGps00::getNearestStation(iv::GPS_INS now_gps_ins,std::vector<Station> station_n,std::vector<GPSData> gpsMap){
 
     int now_index=0,front_index=0;
     int station_size=station_n.size();
@@ -2052,7 +2052,7 @@ iv::Station iv::decition::DecideGps00::getNearestStation(iv::GPS_INS now_gps_ins
 
 }
 
-void iv::decition::DecideGps00::initMethods(){
+void iv::decision::DecideGps00::initMethods(){
 
     pid_Controller= new PIDController();
     ge3_Adapter = new Ge3Adapter();
@@ -2078,7 +2078,7 @@ void iv::decition::DecideGps00::initMethods(){
 }
 
 
-void iv::decition::DecideGps00::phaseSpeedDecition(iv::decition::Decition  decition, double secSpeed, double obsDis, double obsSpeed, GPS_INS gpsIns ) {
+void iv::decision::DecideGps00::phaseSpeedDecition(iv::decision::Decition  decition, double secSpeed, double obsDis, double obsSpeed, GPS_INS gpsIns ) {
 
     pid_Controller->getControlDecition( gpsIns, gpsTraceNow,  dSpeed,  obsDis,  obsSpeed, false, true, &decition);
 
@@ -2102,7 +2102,7 @@ void iv::decition::DecideGps00::phaseSpeedDecition(iv::decition::Decition  decit
 
 
 
-std::vector<iv::Point2D> iv::decition::DecideGps00::getGpsTrace(iv::GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, int lastIndex, bool circleMode) {
+std::vector<iv::Point2D> iv::decision::DecideGps00::getGpsTrace(iv::GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, int lastIndex, bool circleMode) {
     vector<iv::Point2D> trace;
     //	int  PathPoint = Compute00().getNearestPointIndex(now_gps_ins, gpsMapLine, DecideGps00::lastGpsIndex, DecideGps00::minDis, DecideGps00::maxAngle);
     /*if (PathPoint != -1)
@@ -2190,7 +2190,7 @@ std::vector<iv::Point2D> iv::decition::DecideGps00::getGpsTrace(iv::GPS_INS now_
     return trace;
 }
 
-std::vector<iv::Point2D>  iv::decition::DecideGps00::getGpsTraceOffset(std::vector<Point2D> gpsTrace, double offset) {
+std::vector<iv::Point2D>  iv::decision::DecideGps00::getGpsTraceOffset(std::vector<Point2D> gpsTrace, double offset) {
 
     if (offset==0)
     {
@@ -2248,9 +2248,9 @@ std::vector<iv::Point2D>  iv::decition::DecideGps00::getGpsTraceOffset(std::vect
 }
 
 
-double iv::decition::DecideGps00::getAngle(std::vector<Point2D> gpsTrace,GPS_INS gpsIns,iv::decition::Decition decition) {
+double iv::decision::DecideGps00::getAngle(std::vector<Point2D> gpsTrace,GPS_INS gpsIns,iv::decision::Decition decition) {
     double angle=0;
-    if ( abs(iv::decition::DecideGps00().minDis) < 20 && abs(iv::decition::DecideGps00().maxAngle) < 100)
+    if ( abs(iv::decision::DecideGps00().minDis) < 20 && abs(iv::decision::DecideGps00().maxAngle) < 100)
     {
         //   angle = iv::decition::Compute00().getDecideAngle(gpsTrace, realspeed);
         pid_Controller->getControlDecition(gpsIns, gpsTrace,  -1,  -1,  -1, true, false, &decition);
@@ -2259,9 +2259,9 @@ double iv::decition::DecideGps00::getAngle(std::vector<Point2D> gpsTrace,GPS_INS
     return angle;
 }
 
-double iv::decition::DecideGps00::getSpeed(std::vector<Point2D> gpsTrace) {
+double iv::decision::DecideGps00::getSpeed(std::vector<Point2D> gpsTrace) {
     double speed=0;
-    int speedPoint = iv::decition::Compute00().getSpeedPointIndex(gpsTrace, max(10.0, realspeed));
+    int speedPoint = iv::decision::Compute00().getSpeedPointIndex(gpsTrace, max(10.0, realspeed));
     speed = gpsTrace[speedPoint].speed;
     for (int i = 0; i < speedPoint; i++) {
         speed = min(speed, gpsTrace[i].speed);
@@ -2309,12 +2309,12 @@ double iv::decition::DecideGps00::getSpeed(std::vector<Point2D> gpsTrace) {
 
 
 
-void iv::decition::DecideGps00::getEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
+void iv::decision::DecideGps00::getEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
 
 
     int esrPathpoint;
 
-    esrIndex = iv::decition::Compute00().getEsrIndex(gpsTrace, roadNum, &esrPathpoint);
+    esrIndex = iv::decision::Compute00().getEsrIndex(gpsTrace, roadNum, &esrPathpoint);
 
     if (esrIndex != -1)
     {
@@ -2341,9 +2341,9 @@ void iv::decition::DecideGps00::getEsrObsDistance(std::vector<Point2D> gpsTrace,
 
 
 
-void iv::decition::DecideGps00::getEsrObsDistanceAvoid() {
+void iv::decision::DecideGps00::getEsrObsDistanceAvoid() {
 
-    esrIndexAvoid = iv::decition::Compute00().getEsrIndexAvoid(gpsTraceAvoid);
+    esrIndexAvoid = iv::decision::Compute00().getEsrIndexAvoid(gpsTraceAvoid);
 
     if (esrIndexAvoid != -1)
     {
@@ -2368,7 +2368,7 @@ void iv::decition::DecideGps00::getEsrObsDistanceAvoid() {
 
 
 
-double iv::decition::DecideGps00::limitAngle(double speed, double angle) {
+double iv::decision::DecideGps00::limitAngle(double speed, double angle) {
     double preAngle = angle;
 
     if (speed > 15)
@@ -2431,7 +2431,7 @@ double iv::decition::DecideGps00::limitAngle(double speed, double angle) {
 
 
 
-double iv::decition::DecideGps00::limitSpeed(double angle, double speed) {
+double iv::decision::DecideGps00::limitSpeed(double angle, double speed) {
 
     if (abs(angle) > 500 && speed > 8) speed = 8;
     else if (abs(angle) > 350 && speed > 14) speed = 14;
@@ -2443,7 +2443,7 @@ double iv::decition::DecideGps00::limitSpeed(double angle, double speed) {
 }
 
 
-bool iv::decition::DecideGps00::checkAvoidEnable(double avoidX, iv::LidarGridPtr lidarGridPtr,int roadNum) {
+bool iv::decision::DecideGps00::checkAvoidEnable(double avoidX, iv::LidarGridPtr lidarGridPtr,int roadNum) {
 
     if ((obsDisVector[roadNum]>0 && obsDisVector[roadNum]<obsDisVector[roadNow]+ServiceCarStatus.msysparam.vehLenth)||
             (obsDisVector[roadNum]>0 && obsDisVector[roadNum]<15))
@@ -2476,7 +2476,7 @@ bool iv::decition::DecideGps00::checkAvoidEnable(double avoidX, iv::LidarGridPtr
 
 
 
-bool iv::decition::DecideGps00::checkReturnEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum) {
+bool iv::decision::DecideGps00::checkReturnEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum) {
     //lsn
     if (obsDisVector[roadNum]>0 && obsDisVector[roadNum]<20)
     {
@@ -2513,39 +2513,39 @@ bool iv::decition::DecideGps00::checkReturnEnable(double avoidX, iv::LidarGridPt
 }
 
 
-void iv::decition::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
+void iv::decision::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
 
 
 
     if (lidarGridPtr == NULL)
     {
-        iv::decition::DecideGps00::lidarDistanceAvoid = iv::decition::DecideGps00::lastLidarDisAvoid;
+        iv::decision::DecideGps00::lidarDistanceAvoid = iv::decision::DecideGps00::lastLidarDisAvoid;
     }
     else {
         obsPointAvoid = Compute00().getLidarObsPointAvoid(gpsTraceAvoid, lidarGridPtr);
-        iv::decition::DecideGps00::lastLidarDisAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
+        iv::decision::DecideGps00::lastLidarDisAvoid = iv::decision::DecideGps00::lidarDistanceAvoid;
     }
-    std::cout << "\nLidarAvoid距离:%f\n" << iv::decition::DecideGps00::lidarDistanceAvoid << std::endl;
+    std::cout << "\nLidarAvoid距离:%f\n" << iv::decision::DecideGps00::lidarDistanceAvoid << std::endl;
     getEsrObsDistanceAvoid();
 
     //lidarDistanceAvoid = -1;   //20200103 apollo_fu
 
-    if (esrDistanceAvoid>0 && iv::decition::DecideGps00::lidarDistanceAvoid > 0)
+    if (esrDistanceAvoid>0 && iv::decision::DecideGps00::lidarDistanceAvoid > 0)
     {
-        if (iv::decition::DecideGps00::lidarDistanceAvoid >= esrDistanceAvoid)
+        if (iv::decision::DecideGps00::lidarDistanceAvoid >= esrDistanceAvoid)
         {
             obsDistanceAvoid = esrDistanceAvoid;
             obsSpeedAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].speed_y;
         }
         else if (!ServiceCarStatus.obs_radar.empty())
         {
-            obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
+            obsDistanceAvoid = iv::decision::DecideGps00::lidarDistanceAvoid;
             obsSpeedAvoid = Compute00().getObsSpeed(obsPointAvoid, secSpeed);
             std::cout << "\n计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
         }
         else
         {
-            obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
+            obsDistanceAvoid = iv::decision::DecideGps00::lidarDistanceAvoid;
             obsSpeedAvoid = obsSpeedAvoid = 0 - secSpeed;;
             std::cout << "\n毫米波无数据,计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
         }
@@ -2555,9 +2555,9 @@ void iv::decition::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
         obsDistanceAvoid = esrDistanceAvoid;
         obsSpeedAvoid = ServiceCarStatus.obs_radar[esrIndexAvoid].speed_y;
     }
-    else if (iv::decition::DecideGps00::lidarDistanceAvoid > 0)
+    else if (iv::decision::DecideGps00::lidarDistanceAvoid > 0)
     {
-        obsDistanceAvoid = iv::decition::DecideGps00::lidarDistanceAvoid;
+        obsDistanceAvoid = iv::decision::DecideGps00::lidarDistanceAvoid;
         obsSpeedAvoid = Compute00().getObsSpeed(obsPointAvoid, secSpeed);
         std::cout << "\n计算obsSpeed:%f\n" << obsSpeedAvoid << std::endl;
     }
@@ -2572,15 +2572,15 @@ void iv::decition::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
 
 
 
-    if (iv::decition::DecideGps00::obsDistanceAvoid <0 && obsLostTimeAvoid<4)
+    if (iv::decision::DecideGps00::obsDistanceAvoid <0 && obsLostTimeAvoid<4)
     {
-        iv::decition::DecideGps00::obsDistanceAvoid = iv::decition::DecideGps00::lastDistanceAvoid;
+        iv::decision::DecideGps00::obsDistanceAvoid = iv::decision::DecideGps00::lastDistanceAvoid;
         obsLostTimeAvoid++;
     }
     else
     {
         obsLostTimeAvoid = 0;
-        iv::decition::DecideGps00::lastDistanceAvoid = -1;
+        iv::decision::DecideGps00::lastDistanceAvoid = -1;
     }
 
 
@@ -2588,13 +2588,13 @@ void iv::decition::DecideGps00::getObsAvoid(iv::LidarGridPtr lidarGridPtr) {
 
     if (obsDistanceAvoid>0)
     {
-        iv::decition::DecideGps00::lastDistanceAvoid = obsDistanceAvoid;
+        iv::decision::DecideGps00::lastDistanceAvoid = obsDistanceAvoid;
     }
 
-    std::cout << "\nODSAvoid距离:%f\n" << iv::decition::DecideGps00::obsDistanceAvoid << std::endl;
+    std::cout << "\nODSAvoid距离:%f\n" << iv::decision::DecideGps00::obsDistanceAvoid << std::endl;
 }
 
-void iv::decition::DecideGps00::init() {
+void iv::decision::DecideGps00::init() {
     for (int i = 0; i < roadSum; i++)
     {
         lastEsrIdVector.push_back(-1);
@@ -2611,7 +2611,7 @@ void iv::decition::DecideGps00::init() {
 
 #include <QTime>
 
-void iv::decition::DecideGps00::computeObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,
+void iv::decision::DecideGps00::computeObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,
                                                  const std::vector<GPSData> gpsMapLine, std::vector<iv::Perception::PerceptionOutput> lidar_per) {
 
     //    QTime xTime;
@@ -2838,7 +2838,7 @@ void iv::decition::DecideGps00::computeObsOnRoad(iv::LidarGridPtr lidarGridPtr,
 
 
 //1220
-void iv::decition::DecideGps00::computeRearObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,
+void iv::decision::DecideGps00::computeRearObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,
                                                      const std::vector<GPSData> gpsMapLine) {
 
     double obs,obsSd;
@@ -3036,7 +3036,7 @@ void iv::decition::DecideGps00::computeRearObsOnRoad(iv::LidarGridPtr lidarGridP
 
 
 
-void iv::decition::DecideGps00::predictObsOnRoad(std::vector<iv::Perception::PerceptionOutput> lidar_per,std::vector<Point2D> gpsTrace,double realSpeed){
+void iv::decision::DecideGps00::predictObsOnRoad(std::vector<iv::Perception::PerceptionOutput> lidar_per,std::vector<Point2D> gpsTrace,double realSpeed){
     double preObsDis;
 
     if(!lidar_per.empty()){
@@ -3052,7 +3052,7 @@ void iv::decition::DecideGps00::predictObsOnRoad(std::vector<iv::Perception::Per
     }
 }
 
-int iv::decition::DecideGps00::chooseAvoidRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per) {
+int iv::decision::DecideGps00::chooseAvoidRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per) {
     roadPre = -1;
 
     //    if (roadNow<roadOri)
@@ -3194,7 +3194,7 @@ int iv::decition::DecideGps00::chooseAvoidRoad(iv::LidarGridPtr lidarGridPtr, GP
     return roadPre;
 }
 
-int iv::decition::DecideGps00::chooseBackRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per) {
+int iv::decision::DecideGps00::chooseBackRoad(iv::LidarGridPtr lidarGridPtr, GPS_INS now_gps_ins, std::vector<GPSData> gpsMapLine,std::vector<iv::Perception::PerceptionOutput> lidar_per) {
     roadPre = -1;
 
     //   computeObsOnRoad(lidarGridPtr, gpsTraceNow, roadNow,gpsMapLine,lidar_per);
@@ -3297,7 +3297,7 @@ int iv::decition::DecideGps00::chooseBackRoad(iv::LidarGridPtr lidarGridPtr, GPS
 }
 
 
-double iv::decition::DecideGps00::trumpet() {
+double iv::decision::DecideGps00::trumpet() {
     if (trumpetFirstCount)
     {
         trumpetFirstCount = false;
@@ -3317,7 +3317,7 @@ double iv::decition::DecideGps00::trumpet() {
 
 
 
-double iv::decition::DecideGps00::transferP() {
+double iv::decision::DecideGps00::transferP() {
     if (transferFirstCount)
     {
         transferFirstCount = false;
@@ -3336,7 +3336,7 @@ double iv::decition::DecideGps00::transferP() {
 
 
 
-void  iv::decition::DecideGps00::handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
+void  iv::decision::DecideGps00::handBrakePark(iv::decision::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
 
     if (abs(now_gps_ins.speed)>0.1)
     {
@@ -3360,14 +3360,14 @@ void  iv::decition::DecideGps00::handBrakePark(iv::decition::Decition  decition,
 
 
 
-void iv::decition::DecideGps00::getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins) {
+void iv::decision::DecideGps00::getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins) {
     gmapsL.clear();
     gmapsR.clear();
     for (int i = 0; i < 31; i++)
     {
         std::vector<iv::GPSData> gpsMapLineBeside;
         //	gpsMapLineBeside = iv::decition::ComputeUnit().getBesideGpsMapLine(*ServiceCarStatus.location, navigation_data, -0.5*i);
-        gpsMapLineBeside = iv::decition::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, -0.5*i);
+        gpsMapLineBeside = iv::decision::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, -0.5*i);
 
         gmapsL.push_back(gpsMapLineBeside);
     }
@@ -3377,7 +3377,7 @@ void iv::decition::DecideGps00::getMapBeside(std::vector<iv::GPSData> navigation
     {
         std::vector<iv::GPSData> gpsMapLineBeside;
         //		gpsMapLineBeside = iv::decition::ComputeUnit().getBesideGpsMapLine(*ServiceCarStatus.location, navigation_data, 0.5*i);
-        gpsMapLineBeside = iv::decition::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, 0.5*i);
+        gpsMapLineBeside = iv::decision::Compute00().getBesideGpsMapLine(now_gps_ins, navigation_data, 0.5*i);
 
         gmapsR.push_back(gpsMapLineBeside);
     }
@@ -3385,7 +3385,7 @@ void iv::decition::DecideGps00::getMapBeside(std::vector<iv::GPSData> navigation
 }
 
 
-bool iv::decition::DecideGps00::checkChaoCheBack(iv::LidarGridPtr lidarGridPtr) {
+bool iv::decision::DecideGps00::checkChaoCheBack(iv::LidarGridPtr lidarGridPtr) {
 
     if (lidarGridPtr == NULL)
     {
@@ -3420,7 +3420,7 @@ bool iv::decition::DecideGps00::checkChaoCheBack(iv::LidarGridPtr lidarGridPtr)
 
 }
 
-void iv::decition::DecideGps00::updateGroupDate(GPS_INS now_gps_ins,float realspeed,float theta,float s){
+void iv::decision::DecideGps00::updateGroupDate(GPS_INS now_gps_ins,float realspeed,float theta,float s){
     Point2D pt = Coordinate_Transfer( now_gps_ins.gps_x, now_gps_ins.gps_y, group_ori_gps);
 
     ServiceCarStatus.group_x_local=pt.x;
@@ -3441,7 +3441,7 @@ void iv::decition::DecideGps00::updateGroupDate(GPS_INS now_gps_ins,float realsp
 
 
 
-float  iv::decition::DecideGps00::ComputeTrafficLightSpeed(int traffic_light_color, int traffic_light_time,  const std::vector<GPSData> gpsMapLine,int traffic_light_pathpoint,
+float  iv::decision::DecideGps00::ComputeTrafficLightSpeed(int traffic_light_color, int traffic_light_time,  const std::vector<GPSData> gpsMapLine,int traffic_light_pathpoint,
                                                            int pathpoint,float secSpeed,float dSpeed){
     float traffic_speed=200;
     float traffic_dis=0;
@@ -3535,10 +3535,10 @@ float  iv::decition::DecideGps00::ComputeTrafficLightSpeed(int traffic_light_col
 
 }
 
-void iv::decition::DecideGps00::computeObsOnRoadByFrenet(iv::LidarGridPtr lidarGridPtr, const std::vector<Point2D>& gpsTrace, double & obs, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps)
+void iv::decision::DecideGps00::computeObsOnRoadByFrenet(iv::LidarGridPtr lidarGridPtr, const std::vector<Point2D>& gpsTrace, double & obs, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps)
 {
     //    Point2D obsCombinePoint = Point2D(-1,-1);
-    iv::decition::FrenetPoint car_now_frenet_point = iv::decition::FrenetPlanner::getFrenetfromXY(0,0,gpsTrace,gpsMap,pathpoint,nowGps);
+    iv::decision::FrenetPoint car_now_frenet_point = iv::decision::FrenetPlanner::getFrenetfromXY(0,0,gpsTrace,gpsMap,pathpoint,nowGps);
     double obsSd;
     if (lidarGridPtr == NULL)
     {
@@ -3548,7 +3548,7 @@ void iv::decition::DecideGps00::computeObsOnRoadByFrenet(iv::LidarGridPtr lidarG
     else {
         obsPoint = Compute00().getLidarObsPoint(gpsTrace, lidarGridPtr);
         //        lidarDistance = obsPoint.y-2.5;   //激光距离推到车头
-        iv::decition::FrenetPoint lidarFPointTmp = iv::decition::FrenetPlanner::getFrenetfromXY(this->obsPoint.x,this->obsPoint.y,gpsTrace,gpsMap,pathpoint,nowGps);
+        iv::decision::FrenetPoint lidarFPointTmp = iv::decision::FrenetPlanner::getFrenetfromXY(this->obsPoint.x,this->obsPoint.y,gpsTrace,gpsMap,pathpoint,nowGps);
         lidarDistance = lidarFPointTmp.s - car_now_frenet_point.s - 2.5;
 
         //    lidarDistance=-1;
@@ -3658,10 +3658,10 @@ void iv::decition::DecideGps00::computeObsOnRoadByFrenet(iv::LidarGridPtr lidarG
     }
 }
 
-void iv::decition::DecideGps00::getRearEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
+void iv::decision::DecideGps00::getRearEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum) {
 
 
-    esrIndex = iv::decition::Compute00().getRearEsrIndex(gpsTrace, roadNum);
+    esrIndex = iv::decision::Compute00().getRearEsrIndex(gpsTrace, roadNum);
 
     if (esrIndex != -1)
     {
@@ -3674,9 +3674,9 @@ void iv::decition::DecideGps00::getRearEsrObsDistance(std::vector<Point2D> gpsTr
     }
 }
 
-void iv::decition::DecideGps00::getEsrObsDistanceByFrenet(const std::vector<Point2D>& gpsTrace, const FrenetPoint car_now_frenet_point, FrenetPoint &esrObs_F_Point, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps) {
+void iv::decision::DecideGps00::getEsrObsDistanceByFrenet(const std::vector<Point2D>& gpsTrace, const FrenetPoint car_now_frenet_point, FrenetPoint &esrObs_F_Point, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps) {
 
-    esrIndex = iv::decition::Compute00().getEsrIndexByFrenet(gpsTrace,esrObs_F_Point,gpsMap,pathpoint,nowGps);
+    esrIndex = iv::decision::Compute00().getEsrIndexByFrenet(gpsTrace,esrObs_F_Point,gpsMap,pathpoint,nowGps);
 
     if (esrIndex != -1)
     {
@@ -3698,7 +3698,7 @@ void iv::decition::DecideGps00::getEsrObsDistanceByFrenet(const std::vector<Poin
     }
 }
 
-void iv::decition::DecideGps00::getV2XTrafficPositionVector(const std::vector<GPSData> gpsMapLine){
+void iv::decision::DecideGps00::getV2XTrafficPositionVector(const std::vector<GPSData> gpsMapLine){
     v2xTrafficVector.clear();
     for (int var = 0; var < gpsMapLine.size(); var++) {
         if(gpsMapLine[var]->roadMode==6 || gpsMapLine[var]->mode2==1000001){
@@ -3707,7 +3707,7 @@ void iv::decition::DecideGps00::getV2XTrafficPositionVector(const std::vector<GP
     }
 }
 
-float iv::decition::DecideGps00::ComputeV2XTrafficLightSpeed(iv::TrafficLight trafficLight, const std::vector<GPSData> gpsMapLine,std::vector<int> v2xTrafficVector,
+float iv::decision::DecideGps00::ComputeV2XTrafficLightSpeed(iv::TrafficLight trafficLight, const std::vector<GPSData> gpsMapLine,std::vector<int> v2xTrafficVector,
                                                              int pathpoint,float secSpeed,float dSpeed, bool circleMode){
     float trafficSpeed=200;
     int nearTraffixPoint=-1;
@@ -3784,7 +3784,7 @@ float iv::decition::DecideGps00::ComputeV2XTrafficLightSpeed(iv::TrafficLight tr
     return trafficSpeed;
 }
 
-bool iv::decition::DecideGps00::computeTrafficPass(float trafficDis,int trafficColor,float trafficTime,float realSecSpeed,float dSecSpeed){
+bool iv::decision::DecideGps00::computeTrafficPass(float trafficDis,int trafficColor,float trafficTime,float realSecSpeed,float dSecSpeed){
     float passTime=0;
     if (trafficColor==2 || trafficColor==3){
         return false;
@@ -3802,7 +3802,7 @@ bool iv::decition::DecideGps00::computeTrafficPass(float trafficDis,int trafficC
 
 }
 
-float iv::decition::DecideGps00::computeTrafficSpeedLimt(float trafficDis){
+float iv::decision::DecideGps00::computeTrafficSpeedLimt(float trafficDis){
     float limit=200;
     if(trafficDis<10){
         limit = 0;
@@ -3818,7 +3818,7 @@ float iv::decition::DecideGps00::computeTrafficSpeedLimt(float trafficDis){
 
 
 
-bool iv::decition::DecideGps00::adjuseultra(){
+bool iv::decision::DecideGps00::adjuseultra(){
     bool front=false,back=false,left=false,right=false;
     for(int i=1;i<=13;i++)
     {
@@ -3850,7 +3850,7 @@ bool iv::decition::DecideGps00::adjuseultra(){
 
 }
 
-void iv::decition::DecideGps00::transferGpsMode2( const std::vector<GPSData> gpsMapLine){
+void iv::decision::DecideGps00::transferGpsMode2( const std::vector<GPSData> gpsMapLine){
     if(  gpsMapLine[PathPoint]->mode2==3000){
         if(obsDistance>5){
             obsDistance=200;
@@ -3858,7 +3858,7 @@ void iv::decition::DecideGps00::transferGpsMode2( const std::vector<GPSData> gps
         dSpeed=min(dSpeed,5.0);
     }
 }
-float iv::decition::DecideGps00::computeAvoidX(int roadAim,int roadOri,GPSData gps,float vehWidth){
+float iv::decision::DecideGps00::computeAvoidX(int roadAim,int roadOri,GPSData gps,float vehWidth){
     if(roadAim==roadOri){
         return 0;
     }

+ 17 - 17
src/decition/decition_brain/decition/decide_gps_00.h → src/decition/decition_brain/decision/decide_gps_00.h

@@ -3,26 +3,26 @@
 #define _IV_DECITION__DECIDE_GPS_00_
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
 #include <vector>
-#include <decition/adc_tools/gnss_coordinate_convert.h>
-#include <decition/adc_planner/frenet_planner.h>
-#include<decition/adc_controller/pid_controller.h>
-#include <decition/adc_adapter/ge3_adapter.h>
-#include <decition/adc_adapter/qingyuan_adapter.h>
-#include <decition/adc_adapter/vv7_adapter.h>
-#include <decition/adc_adapter/zhongche_adapter.h>
-#include <decition/adc_adapter/bus_adapter.h>
-#include <decition/adc_adapter/hapo_adapter.h>
-#include <decition/adc_adapter/zhongche_adapter.h>
-#include <decition/adc_adapter/yuhesen_adapter.h>
+#include <decision/adc_tools/gnss_coordinate_convert.h>
+#include <decision/adc_planner/frenet_planner.h>
+#include <decision/adc_controller/pid_controller.h>
+#include <decision/adc_adapter/ge3_adapter.h>
+#include <decision/adc_adapter/qingyuan_adapter.h>
+#include <decision/adc_adapter/vv7_adapter.h>
+#include <decision/adc_adapter/zhongche_adapter.h>
+#include <decision/adc_adapter/bus_adapter.h>
+#include <decision/adc_adapter/hapo_adapter.h>
+#include <decision/adc_adapter/zhongche_adapter.h>
+#include <decision/adc_adapter/yuhesen_adapter.h>
 #include "perception/perceptionoutput.h"
 #include "ivlog.h"
 #include <memory>
 
 namespace iv {
-namespace decition {
+namespace decision {
 //根据传感器传输来的信息作出决策
 class DecideGps00 {
 public:
@@ -153,7 +153,7 @@ public:
 
 
     static double getAngle(std::vector<Point2D> gpsTrace);
-    double getAngle(std::vector<Point2D> gpsTrace, GPS_INS gpsIns,iv::decition::Decition decition);
+    double getAngle(std::vector<Point2D> gpsTrace, GPS_INS gpsIns,iv::decision::Decition decision);
     static double getSpeed(std::vector<Point2D> gpsTrace);
 
     static void getEsrObsDistance(std::vector<Point2D> gpsTrace, int roadNum);
@@ -161,7 +161,7 @@ public:
     static void getEsrObsDistanceAvoid();
 
     void getObsAvoid(iv::LidarGridPtr lidarGridPtr);
-    void phaseSpeedDecition(iv::decition::Decition decition, double secSpeed, double obsDis, double obsSpeed, GPS_INS gpsIns );
+    void phaseSpeedDecition(iv::decision::Decition decision, double secSpeed, double obsDis, double obsSpeed, GPS_INS gpsIns );
 
     double limitAngle(double speed, double angle);
     double limitSpeed(double angle, double speed);
@@ -170,7 +170,7 @@ public:
     bool checkReturnEnable(double avoidX, iv::LidarGridPtr lidarGridPtr, int roadNum);
 
     void computeObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,const std::vector<GPSData> gpsMapLine, std::vector<iv::Perception::PerceptionOutput> lidar_per);
-    static void getEsrObsDistanceByFrenet(const std::vector<Point2D>& gpsTrace, iv::decition::FrenetPoint car_now_frenet_point,iv::decition::FrenetPoint &esrObs_F_Point, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
+    static void getEsrObsDistanceByFrenet(const std::vector<Point2D>& gpsTrace, iv::decision::FrenetPoint car_now_frenet_point,iv::decision::FrenetPoint &esrObs_F_Point, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
 
     void computeRearObsOnRoad(iv::LidarGridPtr lidarGridPtr, std::vector<Point2D> gpsTrace, int roadNum,const std::vector<GPSData> gpsMapLine);
     void computeObsOnRoadByFrenet(iv::LidarGridPtr lidarGridPtr,const std::vector<Point2D>& gpsTrace, double & obs, const std::vector<iv::GPSData>& gpsMap,int pathpoint,GPS_INS nowGps);
@@ -182,7 +182,7 @@ public:
 
     void getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins);
 
-    void  handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins);
+    void  handBrakePark(iv::decision::Decition  decision, long duringTime, GPS_INS now_gps_ins);
 
     bool checkChaoCheBack(iv::LidarGridPtr);
     double trumpet();

+ 8 - 8
src/decition/decition_brain/decition/decide_line_00.h → src/decition/decition_brain/decision/decide_line_00.h

@@ -3,16 +3,16 @@
 #define _IV_DECITION__DECIDE_LINE_00_
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include <common/obstacle_type.h>
-#include<vector> 
-#include <decition/gnss_coordinate_convert.h>
-#include <decition/decide_gps_00.h>
+#include <vector>
+#include <decision/gnss_coordinate_convert.h>
+#include <decision/decide_gps_00.h>
 
 
 
 namespace iv {
-	namespace decition {
+	namespace decision {
 		//根据传感器传输来的信息作出决策
         class DecideLine00 {
 		public:
@@ -115,7 +115,7 @@ namespace iv {
 
 			void getObsAvoid(iv::LidarGridPtr lidarGridPtr);
 
-            void phaseSpeedDecition(iv::decition::Decition decition, double secSpeed, double obsDistance, double obsSpeed, GPS_INS gpsIns );
+            void phaseSpeedDecition(iv::decision::Decition decision, double secSpeed, double obsDistance, double obsSpeed, GPS_INS gpsIns );
 
 			double limitAngle(double speed, double angle);
 			double limitSpeed(double angle, double speed);
@@ -131,7 +131,7 @@ namespace iv {
 
 			void getMapBeside(std::vector<iv::GPSData> navigation_data, iv::GPS_INS now_gps_ins);
 
-			void  handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins);
+			void  handBrakePark(iv::decision::Decition  decision, long duringTime, GPS_INS now_gps_ins);
 
 
 			double trumpet();
@@ -236,7 +236,7 @@ namespace iv {
 
 
 		private:
-               iv::decition::DecideGps00* decitionGpstool ;			//决策器
+               iv::decision::DecideGps00* decitionGpstool ;			//决策器
                std::shared_ptr<DecideGps00> mdecitionGpstool;
 		};
 

+ 47 - 47
src/decition/decition_brain/decition/decide_line_00_.cpp → src/decition/decition_brain/decision/decide_line_00_.cpp

@@ -1,8 +1,8 @@
-#include <decition/decide_line_00.h>
-#include <decition/compute_00.h>
-#include <decition/gps_distance.h>
-#include <decition/decition_type.h>
-#include <decition/transfer.h>
+#include <decision/decide_line_00.h>
+#include <decision/compute_00.h>
+#include <decision/gps_distance.h>
+#include <decision/decition_type.h>
+#include <decision/transfer.h>
 #include <common/constants.h>
 #include <common/car_status.h>
 #include <math.h>
@@ -14,51 +14,51 @@ using namespace std;
 
 #define PI (3.1415926535897932384626433832795)
 
-iv::decition::DecideLine00::DecideLine00() {
-      decitionGpstool = new iv::decition::DecideGps00();
+iv::decision::DecideLine00::DecideLine00() {
+      decitionGpstool = new iv::decision::DecideGps00();
       mdecitionGpstool.reset(decitionGpstool);
 }
-iv::decition::DecideLine00::~DecideLine00() {
+iv::decision::DecideLine00::~DecideLine00() {
 
 }
 
 
-int iv::decition::DecideLine00::PathPoint = -1;
-double iv::decition::DecideLine00::minDis = iv::MaxValue;
-double iv::decition::DecideLine00::maxAngle = iv::MinValue;
+int iv::decision::DecideLine00::PathPoint = -1;
+double iv::decision::DecideLine00::minDis = iv::MaxValue;
+double iv::decision::DecideLine00::maxAngle = iv::MinValue;
 //int iv::decition::DecideLine00::lastGpsIndex = iv::MaxValue;
-int iv::decition::DecideLine00::lastGpsIndex = 0;
-double iv::decition::DecideLine00::controlSpeed = 0;
-double iv::decition::DecideLine00::controlBrake = 0;
-double iv::decition::DecideLine00::controlAng = 0;
-double iv::decition::DecideLine00::Iv = 0;
-double iv::decition::DecideLine00::lastU = 0;
-double iv::decition::DecideLine00::lastVt = 0;
-double iv::decition::DecideLine00::lastEv = 0;
+int iv::decision::DecideLine00::lastGpsIndex = 0;
+double iv::decision::DecideLine00::controlSpeed = 0;
+double iv::decision::DecideLine00::controlBrake = 0;
+double iv::decision::DecideLine00::controlAng = 0;
+double iv::decision::DecideLine00::Iv = 0;
+double iv::decision::DecideLine00::lastU = 0;
+double iv::decision::DecideLine00::lastVt = 0;
+double iv::decision::DecideLine00::lastEv = 0;
 
-int iv::decition::DecideLine00::gpsLineParkIndex = 0;
-int iv::decition::DecideLine00::gpsMapParkIndex = 0;
-double iv::decition::DecideLine00::lastDistance = MaxValue;
-double iv::decition::DecideLine00::obsDistance = -1;
-double iv::decition::DecideLine00::obsDistanceAvoid = -1;
-double iv::decition::DecideLine00::lastDistanceAvoid = -1;
+int iv::decision::DecideLine00::gpsLineParkIndex = 0;
+int iv::decision::DecideLine00::gpsMapParkIndex = 0;
+double iv::decision::DecideLine00::lastDistance = MaxValue;
+double iv::decision::DecideLine00::obsDistance = -1;
+double iv::decision::DecideLine00::obsDistanceAvoid = -1;
+double iv::decision::DecideLine00::lastDistanceAvoid = -1;
 
-double iv::decition::DecideLine00::lidarDistance = -1;
-double iv::decition::DecideLine00::myesrDistance = -1;
-double iv::decition::DecideLine00::lastLidarDis = -1;
+double iv::decision::DecideLine00::lidarDistance = -1;
+double iv::decision::DecideLine00::myesrDistance = -1;
+double iv::decision::DecideLine00::lastLidarDis = -1;
 
-bool iv::decition::DecideLine00::parkMode = false;
-bool iv::decition::DecideLine00::readyParkMode = false;
+bool iv::decision::DecideLine00::parkMode = false;
+bool iv::decision::DecideLine00::readyParkMode = false;
 
-bool iv::decition::DecideLine00::zhucheMode = false;
-bool iv::decition::DecideLine00::readyZhucheMode = false;
-bool iv::decition::DecideLine00::hasZhuched = false;
+bool iv::decision::DecideLine00::zhucheMode = false;
+bool iv::decision::DecideLine00::readyZhucheMode = false;
+bool iv::decision::DecideLine00::hasZhuched = false;
 
-double iv::decition::DecideLine00::lastLidarDisAvoid = -1;
-double iv::decition::DecideLine00::lidarDistanceAvoid = -1;
+double iv::decision::DecideLine00::lastLidarDisAvoid = -1;
+double iv::decision::DecideLine00::lidarDistanceAvoid = -1;
 
-int iv::decition::DecideLine00::finishPointNum = 0;
-int iv::decition::DecideLine00::zhuchePointNum = 0;
+int iv::decision::DecideLine00::finishPointNum = 0;
+int iv::decision::DecideLine00::zhuchePointNum = 0;
 
 
 
@@ -66,7 +66,7 @@ int iv::decition::DecideLine00::zhuchePointNum = 0;
 
 //日常展示
 
-iv::decition::Decition    iv::decition::DecideLine00::getDecideFromGPS(GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, iv::LidarGridPtr lidarGridPtr,
+iv::decision::Decition    iv::decision::DecideLine00::getDecideFromGPS(GPS_INS now_gps_ins, const std::vector<GPSData> gpsMapLine, iv::LidarGridPtr lidarGridPtr,
                                                                        std::vector<iv::Perception::PerceptionOutput> lidar_per) {
 
 	Decition gps_decition(new DecitionBasic);
@@ -169,7 +169,7 @@ iv::decition::Decition    iv::decition::DecideLine00::getDecideFromGPS(GPS_INS n
 
     gpsTraceOri=getGpsTraceByMobileEye(ServiceCarStatus.Lane.curvature,ServiceCarStatus.Lane.heading,
                                        (ServiceCarStatus.aftermarketLane.dist_to_lane_l+ServiceCarStatus.aftermarketLane.dist_to_lane_r)*0.5);
-     controlAng = iv::decition::Compute00().getDecideAngleByLanePID(realspeed);
+     controlAng = iv::decision::Compute00().getDecideAngleByLanePID(realspeed);
   //  controlAng = iv::decition::Compute00().getDecideAngle(gpsTraceOri, realspeed);
     if(outGarageTimeLast!=-1){
         outGarageTimeNow=GetTickCount();
@@ -428,7 +428,7 @@ iv::decition::Decition    iv::decition::DecideLine00::getDecideFromGPS(GPS_INS n
 
 
 
-void iv::decition::DecideLine00::phaseSpeedDecition(iv::decition::Decition  decition, double secSpeed, double obsDistance, double obsSpeed, GPS_INS gpsIns) {
+void iv::decision::DecideLine00::phaseSpeedDecition(iv::decision::Decition  decition, double secSpeed, double obsDistance, double obsSpeed, GPS_INS gpsIns) {
 
     //      obsDistance = -1;
 
@@ -777,11 +777,11 @@ void iv::decition::DecideLine00::phaseSpeedDecition(iv::decition::Decition  deci
 
     if (obsDistance>0)
     {
-        iv::decition::DecideGps00::lastDistance = obsDistance;
+        iv::decision::DecideGps00::lastDistance = obsDistance;
     }
     else
     {
-        iv::decition::DecideGps00::lastDistance = 200;
+        iv::decision::DecideGps00::lastDistance = 200;
     }
 
 
@@ -833,7 +833,7 @@ void iv::decition::DecideLine00::phaseSpeedDecition(iv::decition::Decition  deci
 
 
 
-double iv::decition::DecideLine00::limitAngle(double speed, double angle) {
+double iv::decision::DecideLine00::limitAngle(double speed, double angle) {
 	double preAngle = angle;
 
 	if (speed > 15)
@@ -896,7 +896,7 @@ double iv::decition::DecideLine00::limitAngle(double speed, double angle) {
 
 
 
-double iv::decition::DecideLine00::limitSpeed(double angle, double speed) {
+double iv::decision::DecideLine00::limitSpeed(double angle, double speed) {
 
 	if (abs(angle) > 500 && speed > 8) speed = 8;
 	else if (abs(angle) > 350 && speed > 14) speed = 14;
@@ -923,7 +923,7 @@ double iv::decition::DecideLine00::limitSpeed(double angle, double speed) {
 
 
 
-double iv::decition::DecideLine00::trumpet() {
+double iv::decision::DecideLine00::trumpet() {
 	if (trumpetFirstCount)
 	{
 		trumpetFirstCount = false;
@@ -941,7 +941,7 @@ double iv::decition::DecideLine00::trumpet() {
 }
 
 
-void  iv::decition::DecideLine00::handBrakePark(iv::decition::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
+void  iv::decision::DecideLine00::handBrakePark(iv::decision::Decition  decition, long duringTime, GPS_INS now_gps_ins) {
 
 	if (abs(now_gps_ins.speed)>0.1)
 	{
@@ -964,7 +964,7 @@ void  iv::decition::DecideLine00::handBrakePark(iv::decition::Decition  decition
 
 
 
-std::vector<iv::Point2D> iv::decition::DecideLine00::getGpsTraceByMobileEye(float a,float b, float c){
+std::vector<iv::Point2D> iv::decision::DecideLine00::getGpsTraceByMobileEye(float a,float b, float c){
     vector<iv::Point2D> trace;
     for(int i=0; i<600;i++){
        float y=0.1*i;

+ 0 - 0
src/decition/decition_brain/decition/decition.pri → src/decition/decition_brain/decision/decision.pri


+ 3 - 3
src/decition/decition_brain/decition/decition_maker.h → src/decition/decition_brain/decision/decition_maker.h

@@ -3,11 +3,11 @@
 #define _IV_DECITION_DECITION_MAKER_
 
 #include <common/gps_type.h>
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 #include<vector> 
 
 namespace iv {
-	namespace decition {
+	namespace decision {
 		//根据传感器传输来的信息作出决策
 		class DecitionMaker
 		{
@@ -34,7 +34,7 @@ namespace iv {
 
 			GPS_INS getNearestGpsIns(iv::GPS_INS gps_ins, const std::vector<iv::GPSData> navigation_data);
 
-			iv::decition::Decition getDecideForGPS(iv::GPS_INS gpsIns, const std::vector<iv::GPSData> navigation_data);
+			iv::decision::Decition getDecideForGPS(iv::GPS_INS gpsIns, const std::vector<iv::GPSData> navigation_data);
 
 			void getStartPoint(iv::GPS_INS gps_ins, const std::vector<iv::GPSData> navigation_data);
 

+ 1 - 1
src/decition/decition_brain/decition/decition_type.h → src/decition/decition_brain/decision/decition_type.h

@@ -3,7 +3,7 @@
 #define _IV_DECITION_DECITION_TYPE_
 #include <common/boost.h>
 namespace iv {
-namespace decition {
+namespace decision {
 struct DecitionBasic {
     float speed;				//车速
     float wheel_angle;			//转向角度

+ 0 - 0
src/decition/decition_brain/decition/decition_voter.cpp → src/decition/decition_brain/decision/decition_voter.cpp


+ 3 - 3
src/decition/decition_brain/decition/decition_voter.h → src/decition/decition_brain/decision/decition_voter.h

@@ -8,17 +8,17 @@
 #ifndef _IV_DECITION_VOTER_
 #define _IV_DECITION_VOTER_
 
-#include <decition/decition_type.h>
+#include <decision/decition_type.h>
 
 namespace iv {
-	namespace decition {
+	namespace decision {
 		class DecitionVoter
 		{
 		public:
 			DecitionVoter();
 			~DecitionVoter();
 
-			void decideFromAll(iv::decition::Decition & decition_final,iv::decition::Decition & decition_lidar, iv::decition::Decition & decition_radar, iv::decition::Decition & decition_camera, iv::decition::Decition & decition_gps, iv::decition::Decition & decition_localmap);
+			void decideFromAll(iv::decision::Decition & decition_final,iv::decision::Decition & decition_lidar, iv::decision::Decition & decition_radar, iv::decision::Decition & decition_camera, iv::decision::Decition & decition_gps, iv::decision::Decition & decition_localmap);
 
 		private:
 

+ 0 - 0
src/decition/decition_brain/decition/fanyaapi.cpp → src/decition/decition_brain/decision/fanyaapi.cpp


+ 0 - 0
src/decition/decition_brain/decition/fanyaapi.h → src/decition/decition_brain/decision/fanyaapi.h


+ 0 - 0
src/decition/decition_brain/decition/gnss_coordinate_convert.cpp → src/decition/decition_brain/decision/gnss_coordinate_convert.cpp


+ 0 - 0
src/decition/decition_brain/decition/gnss_coordinate_convert.h → src/decition/decition_brain/decision/gnss_coordinate_convert.h


+ 179 - 0
src/decition/decition_brain/decision/gnss_proj/gnss_proj.cpp

@@ -0,0 +1,179 @@
+#include <cmath>
+#include <stdio.h>
+#include "gnss_proj.h"
+
+namespace iv {
+namespace localization {
+
+// 椭球体半长轴
+const static double WGS84_a = 6378137.0;
+// 第一离心率平方
+const static double WGS84_e2 = 0.006694380022903;
+// 第二离心率平方
+const static double WGS84_ep2 = WGS84_e2 / (1 - WGS84_e2);
+// 第一离心率高次方
+const static double WGS84_e4 = WGS84_e2 * WGS84_e2;
+const static double WGS84_e6 = WGS84_e2 * WGS84_e4;
+// 将经线长度作为纬度的函数进行 Taylor 展开时前四项的系数
+const static double WGS84_a1 = 1 - WGS84_e2 / 4 - (3 * WGS84_e4) / 64 - (5 * WGS84_e6) / 256;
+const static double WGS84_a2 = (3 * WGS84_e2) / 8 + (3 * WGS84_e4) / 32 + (45 * WGS84_e6) / 1024;
+const static double WGS84_a3 = (15 * WGS84_e4) / 256 + (45 * WGS84_e6) / 1024;
+const static double WGS84_a4 = (35 * WGS84_e6) / 3072;
+// UTM 展平因子,距离中心线 220km 的两经线会被近似拉伸为平行线
+const static double UTM_k0 = 0.9996;
+
+inline double deg2rad(double x) { return x * 0.017453292519943295; }
+
+inline double rad2deg(double x) { return x * 57.29577951308232; }
+
+
+int getUTMZoneNumber(double latitude, double longitude)
+{
+    longitude = longitude - int((longitude + 180) / 360) * 360;
+    int zone_number = int((longitude + 180) / 6) + 1;
+    if (latitude >= 56 && latitude < 64 && longitude >= 3 && longitude < 12)
+    {
+        zone_number = 32;
+    }
+
+    if (latitude >= 72 && latitude < 84)
+    {
+        if      (longitude >= 0  && longitude <  9) zone_number = 31;
+        else if (longitude >= 9  && longitude < 21) zone_number = 33;
+        else if (longitude >= 21 && longitude < 33) zone_number = 35;
+        else if (longitude >= 21 && longitude < 42) zone_number = 37;
+    }
+    return zone_number;
+}
+
+
+char getUTMLetterDesignator(double latitude)
+{
+    char LetterDesignator;
+
+    if     ((84 >= latitude) && (latitude >= 72))  LetterDesignator = 'X';
+    else if ((72 > latitude) && (latitude >= 64))  LetterDesignator = 'W';
+    else if ((64 > latitude) && (latitude >= 56))  LetterDesignator = 'V';
+    else if ((56 > latitude) && (latitude >= 48))  LetterDesignator = 'U';
+    else if ((48 > latitude) && (latitude >= 40))  LetterDesignator = 'T';
+    else if ((40 > latitude) && (latitude >= 32))  LetterDesignator = 'S';
+    else if ((32 > latitude) && (latitude >= 24))  LetterDesignator = 'R';
+    else if ((24 > latitude) && (latitude >= 16))  LetterDesignator = 'Q';
+    else if ((16 > latitude) && (latitude >= 8))   LetterDesignator = 'P';
+    else if (( 8 > latitude) && (latitude >= 0))   LetterDesignator = 'N';
+    else if (( 0 > latitude) && (latitude >= -8))  LetterDesignator = 'M';
+    else if ((-8 > latitude) && (latitude >= -16)) LetterDesignator = 'L';
+    else if((-16 > latitude) && (latitude >= -24)) LetterDesignator = 'K';
+    else if((-24 > latitude) && (latitude >= -32)) LetterDesignator = 'J';
+    else if((-32 > latitude) && (latitude >= -40)) LetterDesignator = 'H';
+    else if((-40 > latitude) && (latitude >= -48)) LetterDesignator = 'G';
+    else if((-48 > latitude) && (latitude >= -56)) LetterDesignator = 'F';
+    else if((-56 > latitude) && (latitude >= -64)) LetterDesignator = 'E';
+    else if((-64 > latitude) && (latitude >= -72)) LetterDesignator = 'D';
+    else if((-72 > latitude) && (latitude >= -80)) LetterDesignator = 'C';
+    else LetterDesignator = 'Z';
+    return LetterDesignator;
+}
+
+
+void getUTMZone(double latitude, double longitude, char* UTMZone)
+{
+    int zone_number = getUTMZoneNumber(latitude, longitude);
+    char letter = getUTMLetterDesignator(latitude);
+    snprintf(UTMZone, 4, "%d%c", zone_number, letter);
+}
+
+
+void latlon2NE(double latitude, double longitude,
+               double &northing, double &easting)
+{
+    double lat_rad = deg2rad(latitude);
+    double lon_rad = deg2rad(longitude);
+
+    // 经线在输入点处的曲率半径
+    double N = WGS84_a / sqrt(1 - WGS84_e2 * sin(lat_rad) * sin(lat_rad));
+    // 赤道沿经线到输入点的长度,使用 Taylor 展开逼近计算
+    double M = WGS84_a * (
+        WGS84_a1 * lat_rad -
+        WGS84_a2 * sin(2 * lat_rad) +
+        WGS84_a3 * sin(4 * lat_rad) -
+        WGS84_a4 * sin(6 * lat_rad)
+    );
+
+    double lon_origin = (getUTMZoneNumber(latitude, longitude) - 1) * 6 - 180 + 3;
+    lon_origin = deg2rad(lon_origin);
+
+    double T = tan(lat_rad) * tan(lat_rad);
+    double C = WGS84_ep2 * cos(lat_rad) * cos(lat_rad);
+    double A = (lon_rad - lon_origin) * cos(lat_rad);
+    double A2 = A * A;
+    double A3 = A2 * A;
+    double A4 = A2 * A2;
+    double A5 = A4 * A;
+    double A6 = A4 * A2;
+
+    easting = 500000 + UTM_k0 * N * (
+        A + (1 - T + C) * A3 / 6 +
+        (5 - 18 * T + T * T + 72 * C - 58 * WGS84_ep2) * A5 / 120
+    );
+
+    northing = M + N * tan(lat_rad) * (
+        A2 / 2 + (5 - T + 9 * C + 4 * C *C) * A4 / 24 +
+        (61 - 58 * T + T * T + 600 * C - 330 * WGS84_ep2) * A6 / 720
+    );
+    northing *= UTM_k0;
+}
+
+
+void NE2latlon(double northing, double easting,
+               double &latitude, double &longitude,
+               int zone)
+{
+    double x = easting - 500000;
+    double y = northing;
+
+    const static double e1 = (1 - sqrt(1 - WGS84_e2)) / (1 + sqrt(1 - WGS84_e2));
+    const static double e2 = e1 * e1;
+    const static double e3 = e2 * e1;
+    const static double e4 = e3 * e1;
+
+    double lon_origin = (zone - 1) * 6 - 180 + 3;
+    double M = y / UTM_k0;
+    double mu = M / (
+        WGS84_a * (
+            1 - WGS84_e2 / 4 - (3 * WGS84_e4) / 64 - (5 * WGS84_e6) / 256
+        )
+    );
+    double phi1 = mu + (3 * e1 / 2 - 27 * e3 / 32) * sin(2 * mu) +
+        (21 * e2 / 16 - 55 * e4 / 32) * sin(4 * mu) +
+        (151 * e3 / 96) * sin(6 * mu);
+
+    double z = sqrt(1 - WGS84_e2 * sin(phi1) * sin(phi1));
+    double N1 = WGS84_a / z;
+    double T1 = tan(phi1) * tan(phi1);
+    double C1 = WGS84_ep2 * cos(phi1) * cos(phi1);
+    double R1 = WGS84_a * (1 - WGS84_e2) / (z * z * z);
+    double D = x / (N1 * UTM_k0);
+    double D2 = D * D;
+    double D3 = D2 * D;
+    double D4 = D2 * D2;
+    double D5 = D4 * D;
+    double D6 = D4 * D2;
+
+    latitude = phi1 - (N1 * tan(phi1) / R1) * (
+        D2 / 2 -
+        (5 + 3 * T1 + 10 * C1 - 4 * C1 * C1 - 9 * WGS84_ep2) * D4 / 24 +
+        (61 + 90 * T1 + 298 * C1 + 45 * T1 * T1 - 252 * WGS84_ep2 - 3 * C1 * C1) * D6 / 720
+    );
+    latitude = rad2deg(latitude);
+
+    longitude = (
+        D - ( 1 + 2 * T1 * C1) * D3 / 6 +
+        (5 - 2 *C1 + 28 * T1 - 3 * C1 * C1 + 8 * WGS84_ep2 + 24 *T1 * T1) * D5 / 120
+    ) / cos(phi1);
+
+    longitude = rad2deg(longitude) + lon_origin;
+}
+
+}
+}

+ 48 - 0
src/decition/decition_brain/decision/gnss_proj/gnss_proj.h

@@ -0,0 +1,48 @@
+/*
+ * --------------------------------------------
+ * 简易版本的 (纬度, 经度) 和 UTM (北, 东) 坐标系互转
+ * --------------------------------------------
+ *
+ * 在线验证地址 https://www.latlong.net/lat-long-utm.html
+ *
+ * 头文件提供 5 个函数的接口:
+ *
+ * 1. latlon2NE 用于将 (纬度,经度) 转换为 UTM 坐标系下 (北,东) 坐标。
+ * 2. NE2latlon 用于将 UTM 下 (北,东) 坐标转换为 (纬度,经度)。
+ * 3. getUTMZoneNumber 用于获得给定纬经度点所在的 UTM 时区编号,返回值为整数,
+ *    如天津地区返回 50。
+ * 4. getUTMLetterDesignator 用于获得给定纬经度点所在的 UTM 时区编码,
+ *    返回值为字符,如天津地区返回 'S'。
+ * 5. getUTMZone 是上面两个函数的组合,返回 UTM 坐标时区,返回值是字符串,
+ *    如天津地区返回 '50S'。
+ *
+ * 转换公式参考:
+ *
+ * 1. 大地测量学基础. 孔祥元. 武汉大学出版社.
+ * 2. Conformal Map Projections in Geodesy. Krakiwsky. E.J.
+*/
+
+#ifndef GNSS_COORDINATE_CONVERSION_H
+#define GNSS_COORDINATE_CONVERSION_H
+
+#pragma once
+
+namespace iv {
+namespace localization {
+
+int getUTMZoneNumber(double latitude, double longitude);
+
+char getUTMLetterDesignator(double latitude);
+
+void getUTMZone(double latitude, double longitude, char* UTMZone);
+
+void latlon2NE(double latitude, double longitude,
+               double& northing, double& easting);
+
+void NE2latlon(double northing, double easting,
+               double& latitude, double& longitude,
+               int zone = 50);
+
+}
+}
+#endif // GNSS_COORDINATE_CONVERSION_H

+ 5 - 0
src/decition/decition_brain/decision/gnss_proj/gnss_proj.pri

@@ -0,0 +1,5 @@
+HEADERS += \
+    $$PWD/gnss_proj.h
+
+SOURCES += \
+    $$PWD/gnss_proj.cpp

+ 0 - 0
src/decition/decition_brain/decition/gps_distance.cpp → src/decition/decition_brain/decision/gps_distance.cpp


+ 1 - 1
src/decition/decition_brain/decition/adc_tools/gps_distance.h → src/decition/decition_brain/decision/gps_distance.h

@@ -3,7 +3,7 @@
 #define _IV_DECITION_GPS_DISTANCE_
 
 namespace iv {
-	namespace decition {
+	namespace decision {
         // 计算弧度
 		double rad(double d);
 

+ 8 - 8
src/decition/decition_brain/decition/obs_predict.cpp → src/decition/decition_brain/decision/obs_predict.cpp

@@ -1,10 +1,10 @@
-#include <decition/obs_predict.h>
-#include <decition/decition_type.h>
+#include <decision/obs_predict.h>
+#include <decision/decition_type.h>
 #include <common/gps_type.h>
 #include <math.h>
 #include <iostream>
 #include <fstream>
-#include <decition/adc_tools/transfer.h>
+#include <decision/adc_tools/transfer.h>
 #include "perception/perceptionoutput.h"
 #include<common/constants.h>
 
@@ -12,7 +12,7 @@ using namespace std;
 #define PI (3.1415926535897932384626433832795)
 
 
-double iv::decition::PredictObsDistance( double realSpeed,std::vector<Point2D>  gpsTrace,std::vector<iv::Perception::PerceptionOutput> lidar_per){
+double iv::decision::PredictObsDistance( double realSpeed,std::vector<Point2D>  gpsTrace,std::vector<iv::Perception::PerceptionOutput> lidar_per){
 
     double crashDistance=200;
     for(int i=0;i<lidar_per.size();i++){
@@ -48,7 +48,7 @@ double iv::decition::PredictObsDistance( double realSpeed,std::vector<Point2D>
 
 }
 
-double iv::decition::getCrashDis(double realSpeed,std::vector<Point2D>  gpsTrace,iv::Perception::PerceptionOutput obs){
+double iv::decision::getCrashDis(double realSpeed,std::vector<Point2D>  gpsTrace,iv::Perception::PerceptionOutput obs){
     double dis=0;
     int length=min(300,(int)gpsTrace.size());
     int step=10;
@@ -71,7 +71,7 @@ double iv::decition::getCrashDis(double realSpeed,std::vector<Point2D>  gpsTrace
 
 
 
-int iv::decition::getFrameCount(double realSpeed,std::vector<Point2D>  gpsTrace){
+int iv::decision::getFrameCount(double realSpeed,std::vector<Point2D>  gpsTrace){
     double lenth=0;
     for(int i =0 ; i<gpsTrace.size()-1;i++){
         lenth +=GetDistance(gpsTrace[i],gpsTrace[i+1]);
@@ -83,7 +83,7 @@ int iv::decition::getFrameCount(double realSpeed,std::vector<Point2D>  gpsTrace)
     return frame;
 }
 
-int  iv::decition::getPoiIndex(double realSpeed,std::vector<Point2D>  gpsTrace,int frame){
+int  iv::decision::getPoiIndex(double realSpeed,std::vector<Point2D>  gpsTrace,int frame){
 
 
 
@@ -103,7 +103,7 @@ int  iv::decition::getPoiIndex(double realSpeed,std::vector<Point2D>  gpsTrace,i
     return index;
 }
 
-double iv::decition::getTime(double realSpeed,std::vector<Point2D>  gpsTrace,int frame ,double *dis){
+double iv::decision::getTime(double realSpeed,std::vector<Point2D>  gpsTrace,int frame ,double *dis){
     int size=gpsTrace.size()-1;
     int f=min(frame,size);
 

+ 4 - 4
src/decition/decition_brain/decition/obs_predict.h → src/decition/decition_brain/decision/obs_predict.h

@@ -3,13 +3,13 @@
 
 #include <common/gps_type.h>
 #include <common/obstacle_type.h>
-#include <decition/decition_type.h>
-#include<vector>
-#include <decition/decide_gps_00.h>
+#include <decision/decition_type.h>
+#include <vector>
+#include <decision/decide_gps_00.h>
 #include "perception/perceptionoutput.h"
 
 namespace iv {
-    namespace decition {
+    namespace decision {
     //根据传感器传输来的信息作出决策
     double PredictObsDistance(double realSpeed,std::vector<Point2D>  gpsTrace,std::vector<iv::Perception::PerceptionOutput> lidar_per);
     double getCrashDis(double realSpeed,std::vector<Point2D>  gpsTrace,iv::Perception::PerceptionOutput obs);

+ 1400 - 0
src/decition/decition_brain/decision/tinyspline/tinyspline.c

@@ -0,0 +1,1400 @@
+#include <tinyspline_ros/tinyspline.h>
+
+#include <stdlib.h> /* malloc, free */
+#include <math.h> /* fabs, sqrt */
+#include <string.h> /* memcpy, memmove, strcmp */
+#include <setjmp.h> /* setjmp, longjmp */
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Error handling                                                           *
+*                                                                             *
+******************************************************************************/
+#define TRY(x, y) y = (tsError) setjmp(x); if (y == 0) {
+#define CATCH } else {
+#define ETRY }
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Data Types                                                               *
+*                                                                             *
+******************************************************************************/
+/**
+ * Stores the private data of a ::tsBSpline.
+ */
+struct tsBSplineImpl
+{
+	size_t deg; /**< Degree of B-Spline basis function. */
+	size_t dim; /**< Dimension of control points (2D => x, y) */
+	size_t n_ctrlp; /**< Number of control points. */
+	size_t n_knots; /**< Number of knots (n_ctrlp + deg + 1). */
+};
+
+/**
+ * Stores the private data of a ::tsDeBoorNet.
+ */
+struct tsDeBoorNetImpl
+{
+	tsReal u; /**< The evaluated knot value. */
+	size_t k; /**< The index [u_k, u_k+1) */
+	size_t s; /**< Multiplicity of u_k. */
+	size_t h; /**< Number of insertions required to obtain result. */
+	size_t dim; /**< Dimension of points. (2D => x, y) */
+	size_t n_points; /** Number of points in 'points'. */
+};
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Forward Declarations & Internal Utility Functions                        *
+*                                                                             *
+******************************************************************************/
+void ts_internal_bspline_fill_knots(const tsBSpline *spline,
+	tsBSplineType type, tsReal min, tsReal max, tsBSpline *_result_,
+	jmp_buf buf);
+
+size_t ts_internal_bspline_sof_state(const tsBSpline *spline)
+{
+	return sizeof(struct tsBSplineImpl) +
+	       ts_bspline_sof_control_points(spline) +
+	       ts_bspline_sof_knots(spline);
+}
+
+tsReal * ts_internal_bspline_access_ctrlp(const tsBSpline *spline)
+{
+	return (tsReal *) (& spline->pImpl[1]);
+}
+
+tsReal * ts_internal_bspline_access_knots(const tsBSpline *spline)
+{
+	return ts_internal_bspline_access_ctrlp(spline)
+		+ ts_bspline_len_control_points(spline);
+}
+
+size_t ts_internal_deboornet_sof_state(const tsDeBoorNet *net)
+{
+	return sizeof(struct tsDeBoorNetImpl) +
+	       ts_deboornet_sof_points(net) +
+	       ts_deboornet_sof_result(net);
+}
+
+tsReal * ts_internal_deboornet_access_points(const tsDeBoorNet *net)
+{
+	return (tsReal *) (& net->pImpl[1]);
+}
+
+tsReal * ts_internal_deboornet_access_result(const tsDeBoorNet *net)
+{
+	if (ts_deboornet_num_result(net) == 2) {
+		return ts_internal_deboornet_access_points(net);
+	} else {
+		return ts_internal_deboornet_access_points(net) +
+			/* Last point in `points`. */
+		       (ts_deboornet_len_points(net) -
+			ts_deboornet_dimension(net));
+	}
+}
+
+void ts_internal_bspline_find_u(const tsBSpline *spline, tsReal u, size_t *k,
+	size_t *s, jmp_buf buf)
+{
+	const size_t deg = ts_bspline_degree(spline);
+	const size_t order = ts_bspline_order(spline);
+	const size_t num_knots = ts_bspline_num_knots(spline);
+	const tsReal *knots = ts_internal_bspline_access_knots(spline);
+
+	*k = *s = 0;
+	for (; *k < num_knots; (*k)++) {
+		const tsReal uk = knots[*k];
+		if (ts_fequals(u, uk)) {
+			(*s)++;
+		} else if (u < uk) {
+			break;
+		}
+	}
+
+	/* keep in mind that currently k is k+1 */
+	if (*s > order)
+		longjmp(buf, TS_MULTIPLICITY);
+	if (*k <= deg)                /* u < u_min */
+		longjmp(buf, TS_U_UNDEFINED);
+	if (*k == num_knots && *s == 0) /* u > u_last */
+		longjmp(buf, TS_U_UNDEFINED);
+	if (*k > num_knots-deg + *s-1)  /* u > u_max */
+		longjmp(buf, TS_U_UNDEFINED);
+
+	(*k)--; /* k+1 - 1 will never underflow */
+}
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Field Access Functions                                                   *
+*                                                                             *
+******************************************************************************/
+size_t ts_bspline_degree(const tsBSpline *spline)
+{
+	return spline->pImpl->deg;
+}
+
+tsError ts_bspline_set_degree(tsBSpline *spline, size_t deg)
+{
+	if (deg >= ts_bspline_num_control_points(spline))
+		return TS_DEG_GE_NCTRLP;
+	spline->pImpl->deg = deg;
+	return TS_SUCCESS;
+}
+
+size_t ts_bspline_order(const tsBSpline *spline)
+{
+	return ts_bspline_degree(spline) + 1;
+}
+
+tsError ts_bspline_set_order(tsBSpline *spline, size_t order)
+{
+	return ts_bspline_set_degree(spline, order - 1);
+}
+
+size_t ts_bspline_dimension(const tsBSpline *spline)
+{
+	return spline->pImpl->dim;
+}
+
+tsError ts_bspline_set_dimension(tsBSpline *spline, size_t dim)
+{
+	if (dim == 0)
+		return TS_DIM_ZERO;
+	if (ts_bspline_len_control_points(spline) % dim != 0)
+		return TS_LCTRLP_DIM_MISMATCH;
+	spline->pImpl->dim = dim;
+	return TS_SUCCESS;
+}
+
+size_t ts_bspline_len_control_points(const tsBSpline *spline)
+{
+	return ts_bspline_num_control_points(spline) *
+	       ts_bspline_dimension(spline);
+}
+
+size_t ts_bspline_num_control_points(const tsBSpline *spline)
+{
+	return spline->pImpl->n_ctrlp;
+}
+
+size_t ts_bspline_sof_control_points(const tsBSpline *spline)
+{
+	return ts_bspline_len_control_points(spline) * sizeof(tsReal);
+}
+
+tsError ts_bspline_control_points(const tsBSpline *spline, tsReal **ctrlp)
+{
+	const size_t size = ts_bspline_sof_control_points(spline);
+	*ctrlp = malloc(size);
+	if (!*ctrlp) {
+		return TS_MALLOC;
+	} else {
+		memcpy(*ctrlp,
+		       ts_internal_bspline_access_ctrlp(spline),
+		       size);
+		return TS_SUCCESS;
+	}
+}
+
+tsError ts_bspline_set_control_points(tsBSpline *spline, const tsReal *ctrlp)
+{
+	const size_t size = ts_bspline_sof_control_points(spline);
+	memcpy(ts_internal_bspline_access_ctrlp(spline), ctrlp, size);
+	return TS_SUCCESS;
+}
+
+size_t ts_bspline_num_knots(const tsBSpline *spline)
+{
+	return spline->pImpl->n_knots;
+}
+
+size_t ts_bspline_sof_knots(const tsBSpline *spline)
+{
+	return ts_bspline_num_knots(spline) * sizeof(tsReal);
+}
+
+tsError ts_bspline_knots(const tsBSpline *spline, tsReal **knots)
+{
+	const size_t size = ts_bspline_sof_knots(spline);
+	*knots = malloc(size);
+	if (!*knots) {
+		return TS_MALLOC;
+	} else {
+		memcpy(*knots,
+		       ts_internal_bspline_access_knots(spline),
+		       size);
+		return TS_SUCCESS;
+	}
+}
+
+tsError ts_bspline_set_knots(tsBSpline *spline, const tsReal *knots)
+{
+	size_t order, size, idx, mult;
+	tsReal lst_knot, knot;
+	order = ts_bspline_order(spline);
+	lst_knot = ts_internal_bspline_access_knots(spline)[0];
+	mult = 1;
+	for (idx = 1; idx < ts_bspline_num_knots(spline); idx++)
+	{
+		knot = knots[idx];
+		if (ts_fequals(lst_knot, knot))
+			mult++;
+		else if (lst_knot > knot)
+			return TS_KNOTS_DECR;
+		else
+			mult = 0;
+		if (mult > order)
+			return TS_MULTIPLICITY;
+		lst_knot = knot;
+	}
+	size = ts_bspline_sof_knots(spline);
+	memcpy(ts_internal_bspline_access_knots(spline), knots, size);
+	return TS_SUCCESS;
+}
+
+/* ------------------------------------------------------------------------- */
+
+tsReal ts_deboornet_knot(const tsDeBoorNet *net)
+{
+	return net->pImpl->u;
+}
+
+size_t ts_deboornet_index(const tsDeBoorNet *net)
+{
+	return net->pImpl->k;
+}
+
+size_t ts_deboornet_multiplicity(const tsDeBoorNet *net)
+{
+	return net->pImpl->s;
+}
+
+size_t ts_deboornet_num_insertions(const tsDeBoorNet *net)
+{
+	return net->pImpl->h;
+}
+
+size_t ts_deboornet_dimension(const tsDeBoorNet *net)
+{
+	return net->pImpl->dim;
+}
+
+size_t ts_deboornet_len_points(const tsDeBoorNet *net)
+{
+	return ts_deboornet_num_points(net) * ts_deboornet_dimension(net);
+}
+
+size_t ts_deboornet_num_points(const tsDeBoorNet *net)
+{
+	return net->pImpl->n_points;
+}
+
+size_t ts_deboornet_sof_points(const tsDeBoorNet *net)
+{
+	return ts_deboornet_len_points(net) * sizeof(tsReal);
+}
+
+tsError ts_deboornet_points(const tsDeBoorNet *net, tsReal **points)
+{
+	const size_t size = ts_deboornet_sof_points(net);
+	*points = malloc(size);
+	if (!*points) {
+		return TS_MALLOC;
+	} else {
+		memcpy(*points,
+		       ts_internal_deboornet_access_points(net),
+		       size);
+		return TS_SUCCESS;
+	}
+}
+
+size_t ts_deboornet_len_result(const tsDeBoorNet *net)
+{
+	return ts_deboornet_num_result(net) * ts_deboornet_dimension(net);
+}
+
+size_t ts_deboornet_num_result(const tsDeBoorNet *net)
+{
+	return ts_deboornet_num_points(net) == 2 ? 2 : 1;
+}
+
+size_t ts_deboornet_sof_result(const tsDeBoorNet *net)
+{
+	return ts_deboornet_len_result(net) * sizeof(tsReal);
+}
+
+tsError ts_deboornet_result(const tsDeBoorNet *net, tsReal **result)
+{
+	const size_t size = ts_deboornet_sof_result(net);
+	*result = malloc(size);
+	if (!*result) {
+		return TS_MALLOC;
+	} else {
+		memcpy(*result,
+		       ts_internal_deboornet_access_result(net),
+		       size);
+		return TS_SUCCESS;
+	}
+}
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Constructors, Destructors, Copy, and Move Functions                      *
+*                                                                             *
+******************************************************************************/
+void ts_bspline_default(tsBSpline *_spline_)
+{
+	_spline_->pImpl = NULL;
+}
+
+void ts_internal_bspline_new(size_t n_ctrlp, size_t dim, size_t deg,
+	tsBSplineType type, tsBSpline *_spline_, jmp_buf buf)
+{
+	const size_t order = deg + 1;
+	const size_t num_knots = n_ctrlp + order;
+	const size_t len_ctrlp = n_ctrlp * dim;
+
+	const size_t sof_real = sizeof(tsReal);
+	const size_t sof_impl = sizeof(struct tsBSplineImpl);
+	const size_t sof_ctrlp_vec = len_ctrlp * sof_real;
+	const size_t sof_knots_vec = num_knots * sof_real;
+	const size_t sof_spline = sof_impl + sof_ctrlp_vec + sof_knots_vec;
+
+	tsError e;
+	jmp_buf b;
+
+	if (dim < 1)
+		longjmp(buf, TS_DIM_ZERO);
+	if (deg >= n_ctrlp)
+		longjmp(buf, TS_DEG_GE_NCTRLP);
+
+	_spline_->pImpl = (struct tsBSplineImpl *) malloc(sof_spline);
+	if (!_spline_->pImpl)
+		longjmp(buf, TS_MALLOC);
+
+	_spline_->pImpl->deg = deg;
+	_spline_->pImpl->dim = dim;
+	_spline_->pImpl->n_ctrlp = n_ctrlp;
+	_spline_->pImpl->n_knots = num_knots;
+
+	TRY(b, e)
+		ts_internal_bspline_fill_knots(
+			_spline_, type, 0.f, 1.f, _spline_, b);
+	CATCH
+		ts_bspline_free(_spline_);
+		longjmp(buf, e);
+	ETRY
+}
+
+tsError ts_bspline_new(size_t n_ctrlp, size_t dim, size_t deg,
+	tsBSplineType type, tsBSpline *_spline_)
+{
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_bspline_new(
+			n_ctrlp, dim, deg, type, _spline_, buf);
+	CATCH
+		ts_bspline_default(_spline_);
+	ETRY
+	return err;
+}
+
+void ts_internal_bspline_copy(const tsBSpline *original, tsBSpline *_copy_,
+	jmp_buf buf)
+{
+	size_t size;
+	if (original == _copy_)
+		return;
+	size = ts_internal_bspline_sof_state(original);
+	_copy_->pImpl = malloc(size);
+	if (!_copy_->pImpl)
+		longjmp(buf, TS_MALLOC);
+	memcpy(_copy_->pImpl, original->pImpl, size);
+}
+
+tsError ts_bspline_copy(const tsBSpline *original, tsBSpline *_copy_)
+{
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_bspline_copy(original, _copy_, buf);
+	CATCH
+		if (original != _copy_)
+			ts_bspline_default(_copy_);
+	ETRY
+	return err;
+}
+
+void ts_bspline_move(tsBSpline *from, tsBSpline *_to_)
+{
+	if (from == _to_)
+		return;
+	_to_->pImpl = from->pImpl;
+	ts_bspline_default(from);
+}
+
+void ts_bspline_free(tsBSpline *_spline_)
+{
+	if (_spline_->pImpl)
+		free(_spline_->pImpl);
+	ts_bspline_default(_spline_);
+}
+
+/* ------------------------------------------------------------------------- */
+
+void ts_deboornet_default(tsDeBoorNet *_deBoorNet_)
+{
+	_deBoorNet_->pImpl = NULL;
+}
+
+void ts_internal_deboornet_new(const tsBSpline *spline,
+	tsDeBoorNet *_deBoorNet_, jmp_buf buf)
+{
+	const size_t dim = ts_bspline_dimension(spline);
+	const size_t deg = ts_bspline_degree(spline);
+	const size_t num_points = (size_t)(deg * (deg+1) * 0.5f);
+
+	const size_t sof_real = sizeof(tsReal);
+	const size_t sof_impl = sizeof(struct tsDeBoorNetImpl);
+	const size_t sof_points_vec = num_points * dim * sof_real;
+	const size_t sof_net = sof_impl * sof_points_vec;
+
+	_deBoorNet_->pImpl = (struct tsDeBoorNetImpl *) malloc(sof_net);
+	if (!_deBoorNet_->pImpl)
+		longjmp(buf, TS_MALLOC);
+
+	_deBoorNet_->pImpl->u = 0.f;
+	_deBoorNet_->pImpl->k = 0;
+	_deBoorNet_->pImpl->s = 0;
+	_deBoorNet_->pImpl->h = deg;
+	_deBoorNet_->pImpl->dim = dim;
+	_deBoorNet_->pImpl->n_points = num_points;
+}
+
+void ts_deboornet_free(tsDeBoorNet *_deBoorNet_)
+{
+	if (_deBoorNet_->pImpl)
+		free(_deBoorNet_->pImpl);
+	ts_deboornet_default(_deBoorNet_);
+}
+
+void ts_internal_deboornet_copy(const tsDeBoorNet *original,
+	tsDeBoorNet *_copy, jmp_buf buf)
+{
+	size_t size;
+	if (original == _copy)
+		return;
+	size = ts_internal_deboornet_sof_state(original);
+	_copy->pImpl = malloc(size);
+	if (!_copy->pImpl)
+		longjmp(buf, TS_MALLOC);
+	memcpy(_copy->pImpl, original->pImpl, size);
+}
+
+tsError ts_deboornet_copy(const tsDeBoorNet *original, tsDeBoorNet *_copy_)
+{
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_deboornet_copy(original, _copy_, buf);
+	CATCH
+		if (original != _copy_)
+			ts_deboornet_default(_copy_);
+	ETRY
+	return err;
+}
+
+void ts_deboornet_move(tsDeBoorNet *from, tsDeBoorNet *_to_)
+{
+	if (from == _to_)
+		return;
+	_to_->pImpl = from->pImpl;
+	ts_deboornet_default(from);
+}
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Interpolation and Approximation Functions                                *
+*                                                                             *
+******************************************************************************/
+void ts_internal_bspline_thomas_algorithm(const tsReal *points, size_t n,
+	size_t dim, tsReal *_result_, jmp_buf buf)
+{
+	const size_t sof_real = sizeof(tsReal);
+	const size_t sof_ctrlp = dim * sof_real;
+	tsReal* m;      /* Array of weights. */
+	size_t len_m;   /* Length of m. */
+	size_t lst;     /* Index of the last control point in \p points. */
+	size_t i, d;    /* Used in for loops. */
+	size_t j, k, l; /* Used as temporary indices. */
+
+	/* input validation */
+	if (dim == 0)
+		longjmp(buf, TS_DIM_ZERO);
+	if (n == 0)
+		longjmp(buf, TS_DEG_GE_NCTRLP);
+
+	if (n <= 2) {
+		memcpy(_result_, points, n * sof_ctrlp);
+		return;
+	}
+
+	/* In the following n >= 3 applies... */
+	len_m = n-2; /* ... len_m >= 1 */
+	lst = (n-1)*dim; /* ... lst >= 2*dim */
+
+	/* m_0 = 1/4, m_{k+1} = 1/(4-m_k), for k = 0,...,n-2 */
+	m = (tsReal*) malloc(len_m * sof_real);
+	if (m == NULL)
+		longjmp(buf, TS_MALLOC);
+	m[0] = 0.25f;
+	for (i = 1; i < len_m; i++)
+		m[i] = 1.f/(4 - m[i-1]);
+
+	/* forward sweep */
+	ts_arr_fill(_result_, n*dim, 0.f);
+	memcpy(_result_, points, sof_ctrlp);
+	memcpy(_result_+lst, points+lst, sof_ctrlp);
+	for (d = 0; d < dim; d++) {
+		k = dim+d;
+		_result_[k] = 6*points[k];
+		_result_[k] -= points[d];
+	}
+	for (i = 2; i <= n-2; i++) {
+		for (d = 0; d < dim; d++) {
+			j = (i-1)*dim+d;
+			k = i*dim+d;
+			l = (i+1)*dim+d;
+			_result_[k] = 6*points[k];
+			_result_[k] -= _result_[l];
+			_result_[k] -= m[i-2]*_result_[j]; /* i >= 2 */
+		}
+	}
+
+	/* back substitution */
+	if (n > 3)
+		ts_arr_fill(_result_+lst, dim, 0.f);
+	for (i = n-2; i >= 1; i--) {
+		for (d = 0; d < dim; d++) {
+			k = i*dim+d;
+			l = (i+1)*dim+d;
+			/* The following line is the reason why it's important
+			 * to not fill \p _result_ with 0 if n = 3. On the
+			 * other hand, if n > 3 subtracting 0 is exactly what
+			 * we want. */
+			_result_[k] -= _result_[l];
+			_result_[k] *= m[i-1]; /* i >= 1 */
+		}
+	}
+	if (n > 3)
+		memcpy(_result_+lst, points+lst, sof_ctrlp);
+
+	/* we are done */
+	free(m);
+}
+
+void ts_internal_relaxed_uniform_cubic_bspline(const tsReal *points, size_t n,
+	size_t dim, tsBSpline *_spline_, jmp_buf buf)
+{
+	const size_t order = 4;    /**< Order of spline to interpolate. */
+	const tsReal as = 1.f/6.f; /**< The value 'a sixth'. */
+	const tsReal at = 1.f/3.f; /**< The value 'a third'. */
+	const tsReal tt = 2.f/3.f; /**< The value 'two third'. */
+	size_t sof_ctrlp;          /**< Size of a single control point. */
+	const tsReal* b = points;  /**< Array of the b values. */
+	tsReal* s;                 /**< Array of the s values. */
+	size_t i, d;               /**< Used in for loops */
+	size_t j, k, l;            /**< Used as temporary indices. */
+
+	tsReal *ctrlp; /**< Pointer to the control points of \p _spline_. */
+
+	tsError e_;
+	jmp_buf b_;
+
+	/* input validation */
+	if (dim == 0)
+		longjmp(buf, TS_DIM_ZERO);
+	if (n <= 1)
+		longjmp(buf, TS_DEG_GE_NCTRLP);
+	/* in the following n >= 2 applies */
+
+	sof_ctrlp = dim * sizeof(tsReal); /* dim > 0 implies sof_ctrlp > 0 */
+
+	/* n >= 2 implies n-1 >= 1 implies (n-1)*4 >= 4 */
+	ts_internal_bspline_new(
+		(n-1)*4, dim, order-1, TS_BEZIERS, _spline_, buf);
+	ctrlp = ts_internal_bspline_access_ctrlp(_spline_);
+
+	TRY(b_, e_)
+		s = (tsReal*) malloc(n * sof_ctrlp);
+		if (!s)
+			longjmp(b_, TS_MALLOC);
+	CATCH
+		ts_bspline_free(_spline_);
+		longjmp(buf, e_);
+	ETRY
+
+	/* set s_0 to b_0 and s_n = b_n */
+	memcpy(s, b, sof_ctrlp);
+	memcpy(s + (n-1)*dim, b + (n-1)*dim, sof_ctrlp);
+
+	/* set s_i = 1/6*b_i + 2/3*b_{i-1} + 1/6*b_{i+1}*/
+	for (i = 1; i < n-1; i++) {
+		for (d = 0; d < dim; d++) {
+			j = (i-1)*dim+d;
+			k = i*dim+d;
+			l = (i+1)*dim+d;
+			s[k] = as * b[j];
+			s[k] += tt * b[k];
+			s[k] += as * b[l];
+		}
+	}
+
+	/* create beziers from b and s */
+	for (i = 0; i < n-1; i++) {
+		for (d = 0; d < dim; d++) {
+			j = i*dim+d;
+			k = i*4*dim+d;
+			l = (i+1)*dim+d;
+			ctrlp[k] = s[j];
+			ctrlp[k+dim] = tt*b[j] + at*b[l];
+			ctrlp[k+2*dim] = at*b[j] + tt*b[l];
+			ctrlp[k+3*dim] = s[l];
+		}
+	}
+
+	/* we are done */
+	free(s);
+}
+
+void ts_internal_bspline_interpolate_cubic(const tsReal *points, size_t n,
+	size_t dim, tsBSpline *_spline_, jmp_buf buf)
+{
+	tsError e;
+	jmp_buf b;
+
+	tsReal* thomas = (tsReal*) malloc(n*dim*sizeof(tsReal));
+	if (!thomas)
+		longjmp(buf, TS_MALLOC);
+
+	TRY(b, e)
+		ts_internal_bspline_thomas_algorithm(
+			points, n, dim, thomas, b);
+		ts_internal_relaxed_uniform_cubic_bspline(
+			thomas, n, dim, _spline_, b);
+	ETRY
+
+	free(thomas);
+	if (e < 0)
+		longjmp(buf, e);
+}
+
+tsError ts_bspline_interpolate_cubic(const tsReal *points, size_t n,
+	size_t dim, tsBSpline *_spline_)
+{
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_bspline_interpolate_cubic(
+			points, n, dim, _spline_, buf);
+	CATCH
+		ts_bspline_default(_spline_);
+	ETRY
+	return err;
+}
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Query Functions                                                          *
+*                                                                             *
+******************************************************************************/
+void ts_internal_bspline_eval(const tsBSpline *spline, tsReal u,
+	tsDeBoorNet *_deBoorNet_, jmp_buf buf)
+{
+	const size_t deg = ts_bspline_degree(spline);
+	const size_t order = ts_bspline_order(spline);
+	const size_t dim = ts_bspline_dimension(spline);
+	const size_t num_knots = ts_bspline_num_knots(spline);
+	const size_t sof_ctrlp = dim * sizeof(tsReal);
+
+	const tsReal *ctrlp = ts_internal_bspline_access_ctrlp(spline);
+	const tsReal *knots = ts_internal_bspline_access_knots(spline);
+	tsReal *points;  /**< Pointer to the points of \p _deBoorNet_. */
+
+	size_t k;        /**< Index of \p u. */
+	size_t s;        /**< Multiplicity of \p u. */
+
+	tsReal uk;       /**< The actual used u. */
+	size_t from;     /**< Offset used to copy values. */
+	size_t fst;      /**< First affected control point, inclusive. */
+	size_t lst;      /**< Last affected control point, inclusive. */
+	size_t N;        /**< Number of affected control points. */
+
+	/* The following indices are used to create the DeBoor net. */
+	size_t lidx;     /**< Current left index. */
+	size_t ridx;     /**< Current right index. */
+	size_t tidx;     /**< Current to index. */
+	size_t r, i, d;  /**< Used in for loop. */
+	tsReal ui;       /**< Knot value at index i. */
+	tsReal a, a_hat; /**< Weighting factors of control points. */
+
+	/* Setup the net with its default values. */
+	ts_internal_deboornet_new(spline, _deBoorNet_, buf);
+	points = ts_internal_deboornet_access_points(_deBoorNet_);
+
+	/* 1. Find index k such that u is in between [u_k, u_k+1).
+	 * 2. Setup already known values.
+	 * 3. Decide by multiplicity of u how to calculate point P(u). */
+
+	/* 1. */
+	ts_internal_bspline_find_u(spline, u, &k, &s, buf);
+
+	/* 2. */
+	uk = knots[k];          /* Ensures that with any precision of  */
+	_deBoorNet_->pImpl->u = /* tsReal the knot vector stays valid. */
+		ts_fequals(u, uk) ? uk : u;
+	_deBoorNet_->pImpl->k = k;
+	_deBoorNet_->pImpl->s = s;
+        _deBoorNet_->pImpl->h = deg < s ? 0 : deg-s; /* prevent underflow */
+
+	/* 3. (by 1. s <= order)
+	 *
+	 * 3a) Check for s = order.
+	 *     Take the two points k-s and k-s + 1. If one of
+	 *     them doesn't exist, take only the other.
+	 * 3b) Use de boor algorithm to find point P(u). */
+	if (s == order) {
+		/* only one of the two control points exists */
+		if (k == deg || /* only the first */
+		    k == num_knots - 1) { /* only the last */
+			from = k == deg ? 0 : (k-s) * dim;
+			_deBoorNet_->pImpl->n_points = 1;
+			memcpy(points, ctrlp + from, sof_ctrlp);
+		} else {
+			from = (k-s) * dim;
+			_deBoorNet_->pImpl->n_points = 2;
+			memcpy(points, ctrlp + from, 2 * sof_ctrlp);
+		}
+	} else { /* by 3a) s <= deg (order = deg+1) */
+		fst = k-deg; /* by 1. k >= deg */
+		lst = k-s; /* s <= deg <= k */
+		N = lst-fst + 1; /* lst <= fst implies N >= 1 */
+
+		_deBoorNet_->pImpl->n_points = (size_t)(N * (N+1) * 0.5f);
+
+		/* copy initial values to output */
+		memcpy(points, ctrlp + fst*dim, N * sof_ctrlp);
+
+		lidx = 0;
+		ridx = dim;
+		tidx = N*dim; /* N >= 1 implies tidx > 0 */
+		r = 1;
+		for (;r <= ts_deboornet_num_insertions(_deBoorNet_); r++) {
+			i = fst + r;
+			for (; i <= lst; i++) {
+				ui = knots[i];
+				a = (ts_deboornet_knot(_deBoorNet_) - ui) /
+					(knots[i+deg-r+1] - ui);
+				a_hat = 1.f-a;
+
+				for (d = 0; d < dim; d++) {
+					points[tidx++] =
+						a_hat * points[lidx++] +
+						a     * points[ridx++];
+				}
+			}
+			lidx += dim;
+			ridx += dim;
+		}
+	}
+}
+
+tsError ts_bspline_eval(const tsBSpline *spline, tsReal u,
+	tsDeBoorNet *_deBoorNet_)
+{
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_bspline_eval(spline, u, _deBoorNet_, buf);
+	CATCH
+		ts_deboornet_default(_deBoorNet_);
+	ETRY
+	return err;
+}
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Transformation Functions                                                 *
+*                                                                             *
+******************************************************************************/
+void ts_internal_bspline_derive(const tsBSpline *spline,
+	tsBSpline *_derivative_, jmp_buf buf)
+{
+	const size_t sof_real = sizeof(tsReal);
+	const size_t dim = ts_bspline_dimension(spline);
+	const size_t deg = ts_bspline_degree(spline);
+	const size_t num_ctrlp = ts_bspline_num_control_points(spline);
+	const size_t num_knots = ts_bspline_num_knots(spline);
+
+	tsBSpline tmp;  /**< Temporarily stores the result. */
+	const tsReal* from_ctrlp = ts_internal_bspline_access_ctrlp(spline);
+	const tsReal* from_knots = ts_internal_bspline_access_knots(spline);
+	tsReal* to_ctrlp = NULL; /**< Pointer to the control points of tmp. */
+	tsReal* to_knots = NULL; /**< Pointer to the knots of tmp. */
+
+	size_t i, j, k; /**< Used in for loops. */
+
+	if (deg < 1 || num_ctrlp < 2)
+		longjmp(buf, TS_UNDERIVABLE);
+
+	ts_internal_bspline_new(num_ctrlp-1, dim, deg-1, TS_NONE, &tmp, buf);
+	to_ctrlp = ts_internal_bspline_access_ctrlp(&tmp);
+	to_knots = ts_internal_bspline_access_knots(&tmp);
+
+	for (i = 0; i < num_ctrlp-1; i++) {
+		for (j = 0; j < dim; j++) {
+			if (ts_fequals(from_knots[i+deg+1], from_knots[i+1])) {
+				ts_bspline_free(&tmp);
+				longjmp(buf, TS_UNDERIVABLE);
+			} else {
+				k = i*dim + j;
+				to_ctrlp[k] = from_ctrlp[(i+1)*dim + j] - from_ctrlp[k];
+				to_ctrlp[k] *= deg;
+				to_ctrlp[k] /= from_knots[i+deg+1] - from_knots[i+1];
+			}
+		}
+	}
+	memcpy(to_knots, from_knots+1, (num_knots-2)*sof_real);
+
+	if (spline == _derivative_)
+		ts_bspline_free(_derivative_);
+	ts_bspline_move(&tmp, _derivative_);
+}
+
+tsError ts_bspline_derive(const tsBSpline *spline, tsBSpline *_derivative_)
+{
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_bspline_derive(spline, _derivative_, buf);
+	CATCH
+		if (spline != _derivative_)
+			ts_bspline_default(_derivative_);
+	ETRY
+	return err;
+}
+
+void ts_internal_bspline_fill_knots(const tsBSpline *spline,
+	tsBSplineType type, tsReal min, tsReal max, tsBSpline *_result_,
+	jmp_buf buf)
+{
+	const size_t n_knots = ts_bspline_num_knots(spline);
+	const size_t deg = ts_bspline_degree(spline);
+	const size_t order = deg + 1; /**< ensures order >= 1. */
+	tsReal fac; /**< Factor used to calculate the knot values. */
+	size_t i; /**< Used in for loops. */
+
+	tsReal *knots; /**< Pointer to the knots of \p _result_. */
+
+	/* order >= 1 implies 2*order >= 2 implies n_knots >= 2 */
+	if (n_knots < 2*order)
+		longjmp(buf, TS_DEG_GE_NCTRLP);
+	if (type == TS_BEZIERS && n_knots % order != 0)
+		longjmp(buf, TS_NUM_KNOTS);
+	if (min > max || ts_fequals(min, max))
+		longjmp(buf, TS_KNOTS_DECR);
+
+	/* copy spline even if type is TS_NONE */
+	ts_internal_bspline_copy(spline, _result_, buf);
+	knots = ts_internal_bspline_access_knots(_result_);
+
+	if (type == TS_OPENED) {
+		/* ensures that the first knot value is exactly \min */
+		knots[0] = min; /* n_knots >= 2 */
+
+		fac = (max-min) / (n_knots-1); /* n_knots >= 2 */
+		for (i = 1; i < n_knots-1; i++)
+			knots[i] = min + i*fac;
+
+		/* ensure that the last knot value is exactly \max */
+		knots[i] = max;
+	} else if (type == TS_CLAMPED) {
+		/* n_knots >= 2*order == 2*(deg+1) == 2*deg + 2 > 2*deg - 1 */
+		fac = (max-min) / (n_knots - 2*deg - 1);
+
+		ts_arr_fill(knots, order, min);
+		for (i = order ;i < n_knots-order; i++)
+			knots[i] = min + (i-deg)*fac;
+		ts_arr_fill(knots + i, order, max);
+	} else if (type == TS_BEZIERS) {
+		/* n_knots >= 2*order implies n_knots/order >= 2 */
+		fac = (max-min) / (n_knots/order - 1);
+
+		ts_arr_fill(knots, order, min);
+		for (i = order; i < n_knots-order; i += order)
+			ts_arr_fill(knots + i,
+				    order, min + (i/order)*fac);
+		ts_arr_fill(knots + i, order, max);
+	}
+}
+
+tsError ts_bspline_fill_knots(const tsBSpline *spline, tsBSplineType type,
+	tsReal min, tsReal max, tsBSpline *_result_)
+{
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_bspline_fill_knots(
+			spline, type, min, max, _result_, buf);
+	CATCH
+		if (spline != _result_)
+			ts_bspline_default(_result_);
+	ETRY
+	return err;
+}
+
+void ts_internal_bspline_resize(const tsBSpline *spline, int n, int back,
+	tsBSpline *_resized_, jmp_buf buf)
+{
+	const size_t deg = ts_bspline_degree(spline);
+	const size_t dim = ts_bspline_dimension(spline);
+	const size_t sof_real = sizeof(tsReal);
+
+	const size_t num_ctrlp = ts_bspline_num_control_points(spline);
+	const size_t num_knots = ts_bspline_num_knots(spline);
+	const size_t nnum_ctrlp = num_ctrlp + n; /**< New length of ctrlp. */
+	const size_t nnum_knots = num_knots + n; /**< New length of knots. */
+	const size_t min_num_ctrlp_vec = n < 0 ? nnum_ctrlp : num_ctrlp;
+	const size_t min_num_knots_vec = n < 0 ? nnum_knots : num_knots;
+
+	const size_t sof_min_num_ctrlp = min_num_ctrlp_vec * dim * sof_real;
+	const size_t sof_min_num_knots = min_num_knots_vec * sof_real;
+
+	tsBSpline tmp; /**< Temporarily stores the result. */
+	const tsReal* from_ctrlp = ts_internal_bspline_access_ctrlp(spline);
+	const tsReal* from_knots = ts_internal_bspline_access_knots(spline);
+	tsReal* to_ctrlp = NULL; /**< Pointer to the control points of tmp. */
+	tsReal* to_knots = NULL; /**< Pointer to the knots of tmp. */
+
+	/* If n is 0 the spline must not be resized. */
+	if (n == 0) {
+		ts_internal_bspline_copy(spline, _resized_, buf);
+		return;
+	}
+
+	ts_internal_bspline_new(nnum_ctrlp, dim, deg, TS_NONE, &tmp, buf);
+	to_ctrlp = ts_internal_bspline_access_ctrlp(&tmp);
+	to_knots = ts_internal_bspline_access_knots(&tmp);
+
+	/* Copy control points and knots. */
+	if (!back && n < 0) {
+		memcpy(to_ctrlp, from_ctrlp + n*dim, sof_min_num_ctrlp);
+		memcpy(to_knots, from_knots + n    , sof_min_num_knots);
+	} else if (!back && n > 0) {
+		memcpy(to_ctrlp + n*dim, from_ctrlp, sof_min_num_ctrlp);
+		memcpy(to_knots + n    , from_knots, sof_min_num_knots);
+	} else {
+		/* n != 0 implies back == true */
+		memcpy(to_ctrlp, from_ctrlp, sof_min_num_ctrlp);
+		memcpy(to_knots, from_knots, sof_min_num_knots);
+	}
+
+	if (spline == _resized_)
+		ts_bspline_free(_resized_);
+	ts_bspline_move(&tmp, _resized_);
+}
+
+tsError ts_bspline_resize(const tsBSpline *spline, int n, int back,
+	tsBSpline *_resized_)
+{
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_bspline_resize(spline, n, back, _resized_, buf);
+	CATCH
+		if (spline != _resized_)
+			ts_bspline_default(_resized_);
+	ETRY
+	return err;
+}
+
+void ts_internal_bspline_insert_knot(const tsBSpline *spline,
+	const tsDeBoorNet *deBoorNet, size_t n, tsBSpline *_result_,
+	jmp_buf buf)
+{
+	const size_t deg = ts_bspline_degree(spline);
+	const size_t dim = ts_bspline_dimension(spline);
+	const tsReal *ctrlp_spline = ts_internal_bspline_access_ctrlp(spline);
+	const tsReal *knots_spline = ts_internal_bspline_access_knots(spline);
+	const size_t k = ts_deboornet_index(deBoorNet);
+	const size_t s = ts_deboornet_multiplicity(deBoorNet);
+	const size_t sof_real = sizeof(tsReal);
+	const size_t sof_ctrlp = dim * sof_real;
+
+	size_t N;     /**< Number of affected control points. */
+	tsReal* from; /**< Pointer to copy the values from. */
+	tsReal* to;   /**< Pointer to copy the values to. */
+	int stride;   /**< Stride of the next pointer to copy. */
+	size_t i;     /**< Used in for loops. */
+
+	tsReal *ctrlp_result;
+	tsReal *knots_result;
+	size_t num_ctrlp_result;
+	size_t num_knots_result;
+
+	if (s+n > ts_bspline_order(spline)) {
+		longjmp(buf, TS_MULTIPLICITY);
+	}
+
+	/* Use ::ts_bspline_resize even if \p n is 0 to copy the spline if
+	 * necessary. */
+	ts_internal_bspline_resize(spline, (int)n, 1, _result_, buf);
+	if (n == 0) /* Nothing to insert. */
+		return;
+	ctrlp_result = ts_internal_bspline_access_ctrlp(_result_);
+	knots_result = ts_internal_bspline_access_knots(_result_);
+	num_ctrlp_result = ts_bspline_num_control_points(_result_);
+	num_knots_result = ts_bspline_num_knots(_result_);
+
+	/* n > 0 implies s <= deg implies a regular evaluation implies h+1 is
+	 * valid. */
+	N = ts_deboornet_num_insertions(deBoorNet) + 1;
+
+	/* 1. Copy all necessary control points and knots from
+	 *    the original B-Spline.
+	 * 2. Copy all necessary control points and knots from
+	 *    the de Boor net. */
+
+	/* 1.
+	 *
+	 * a) Copy left hand side control points from original b-spline.
+	 * b) Copy right hand side control points from original b-spline.
+	 * c) Copy left hand side knots from original b-spline.
+	 * d) Copy right hand side knots form original b-spline. */
+	/* copy control points */
+	memmove(ctrlp_result, ctrlp_spline, (k-deg) * sof_ctrlp);      /* a) */
+	from = (tsReal *) ctrlp_spline + dim*(k-deg+N);
+	/* n >= 0 implies to >= from */
+	to = ctrlp_result + dim*(k-deg+N+n);
+	memmove(to, from, (num_ctrlp_result-n-(k-deg+N)) * sof_ctrlp); /* b) */
+	/* copy knots */
+	memmove(knots_result, knots_spline, (k+1) * sof_real);         /* c) */
+	from = (tsReal *) knots_spline + k+1;
+	/* n >= 0 implies to >= from */
+	to = knots_result + k+1+n;
+	memmove(to, from, (num_knots_result-n-(k+1)) * sof_real);      /* d) */
+
+	/* 2.
+	 *
+	 * a) Copy left hand side control points from de boor net.
+	 * b) Copy middle part control points from de boor net.
+	 * c) Copy right hand side control points from de boor net.
+	 * d) Insert knots with u_k. */
+	from = ts_internal_deboornet_access_points(deBoorNet);
+	to = ctrlp_result + (k-deg)*dim;
+	stride = (int)(N*dim);
+
+	/* copy control points */
+	for (i = 0; i < n; i++) {                                      /* a) */
+		memcpy(to, from, sof_ctrlp);
+		from += stride;
+		to += dim;
+		stride -= (int)dim;
+	}
+	memcpy(to, from, (N-n) * sof_ctrlp);                           /* b) */
+
+	from -= dim;
+	to += (N-n)*dim;
+	/* N = h+1 with h = deg-s (ts_internal_bspline_eval) implies
+	 * N = deg-s+1 = order-s. n <= order-s implies
+	 * N-n+1 >= order-s - order-s + 1 = 1. Thus, -(int)(N-n+1) <= -1. */
+	stride = -(int)(N-n+1) * (int)dim;
+
+	for (i = 0; i < n; i++) {                                      /* c) */
+		memcpy(to, from, sof_ctrlp);
+		from += stride;
+		stride -= (int)dim;
+		to += dim;
+	}
+	/* copy knots */
+	to = knots_result + k+1;
+	for (i = 0; i < n; i++) {                                      /* d) */
+		*to = ts_deboornet_knot(deBoorNet);
+		to++;
+	}
+}
+
+tsError ts_bspline_insert_knot(const tsBSpline *spline, tsReal u, size_t n,
+	tsBSpline *_result_, size_t* k)
+{
+	tsDeBoorNet net;
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_bspline_eval(spline, u, &net, buf);
+		ts_internal_bspline_insert_knot(
+			spline, &net, n, _result_, buf);
+		*k = ts_deboornet_index(&net) + n;
+	CATCH
+		if (spline != _result_)
+			ts_bspline_default(_result_);
+		*k = 0;
+	ETRY
+
+	ts_deboornet_free(&net);
+	return err;
+}
+
+void ts_internal_bspline_split(const tsBSpline *spline, tsReal u,
+	tsBSpline *_split_, size_t* k, jmp_buf buf)
+{
+	tsDeBoorNet net;
+	tsError e;
+	jmp_buf b;
+
+	TRY(b, e)
+		ts_internal_bspline_eval(spline, u, &net, b);
+		if (ts_deboornet_multiplicity(&net)
+		    		== ts_bspline_order(spline)) {
+			ts_internal_bspline_copy(spline, _split_, b);
+			*k = ts_deboornet_index(&net);
+		} else {
+			ts_internal_bspline_insert_knot(spline, &net,
+				ts_deboornet_num_insertions(&net) + 1,
+				_split_, b);
+			*k = ts_deboornet_index(&net) +
+				ts_deboornet_num_insertions(&net) + 1;
+		}
+	CATCH
+		*k = 0;
+	ETRY
+
+	ts_deboornet_free(&net);
+	if (e < 0)
+		longjmp(buf, e);
+}
+
+tsError ts_bspline_split(const tsBSpline *spline, tsReal u, tsBSpline *_split_,
+	size_t* k)
+{
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_bspline_split(spline, u, _split_, k, buf);
+	CATCH
+		if (spline != _split_)
+			ts_bspline_default(_split_);
+	ETRY
+	return err;
+}
+
+void ts_internal_bspline_buckle(const tsBSpline *spline, tsReal b,
+	tsBSpline *_buckled_, jmp_buf buf)
+{
+	const tsReal b_hat  = 1.f-b; /**< The straightening factor. */
+	const size_t dim = ts_bspline_dimension(spline);
+	const size_t N = ts_bspline_num_control_points(spline);
+	const tsReal* p0 = ts_internal_bspline_access_ctrlp(spline);
+	const tsReal* pn_1 = p0 + (N-1)*dim;
+
+	tsReal *ctrlp; /**< Pointer to the control points of \p _buckled_. */
+	size_t i, d; /**< Used in for loops. */
+
+	ts_internal_bspline_copy(spline, _buckled_, buf);
+	ctrlp = ts_internal_bspline_access_ctrlp(_buckled_);
+
+	for (i = 0; i < N; i++) {
+		for (d = 0; d < dim; d++) {
+			ctrlp[i*dim + d] =
+				b     * ctrlp[i*dim + d] +
+				b_hat * (p0[d] + ((tsReal)i / (N-1)) * (pn_1[d] - p0[d]));
+		}
+	}
+}
+
+tsError ts_bspline_buckle(const tsBSpline *spline, tsReal b,
+	tsBSpline *_buckled_)
+{
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_bspline_buckle(spline, b, _buckled_, buf);
+	CATCH
+		if (spline != _buckled_)
+			ts_bspline_default(_buckled_);
+	ETRY
+	return err;
+}
+
+void ts_internal_bspline_to_beziers(const tsBSpline *spline,
+	tsBSpline *_beziers_, jmp_buf buf)
+{
+	const size_t deg = ts_bspline_degree(spline);
+	const size_t order = ts_bspline_order(spline);
+
+	int resize;    /**< Number of control points to add/remove. */
+	size_t k;      /**< Index of the split knot value. */
+	tsReal u_min;  /**< Minimum of the knot values. */
+	tsReal u_max;  /**< Maximum of the knot values. */
+
+	tsBSpline tmp;    /**< Temporarily stores the result. */
+	tsReal *knots;    /**< Pointer to the knots of tmp. */
+	size_t num_knots; /**< Number of knots in tmp. */
+
+	tsError e;
+	jmp_buf b;
+
+	ts_internal_bspline_copy(spline, &tmp, buf);
+	knots = ts_internal_bspline_access_knots(&tmp);
+	num_knots = ts_bspline_num_knots(&tmp);
+
+	TRY(b, e)
+		/* DO NOT FORGET TO UPDATE knots AND num_knots AFTER EACH
+		 * TRANSFORMATION OF tmp! */
+
+		/* fix first control point if necessary */
+		u_min = knots[deg];
+		if (!ts_fequals(knots[0], u_min)) {
+			ts_internal_bspline_split(&tmp, u_min, &tmp, &k, b);
+			resize = (int)(-1*deg + (deg*2 - k));
+			ts_internal_bspline_resize(&tmp, resize, 0, &tmp, b);
+			knots = ts_internal_bspline_access_knots(&tmp);
+			num_knots = ts_bspline_num_knots(&tmp);
+		}
+
+		/* fix last control point if necessary */
+		u_max = knots[num_knots - order];
+		if (!ts_fequals(knots[num_knots - 1], u_max)) {
+			ts_internal_bspline_split(&tmp, u_max, &tmp, &k, b);
+			num_knots = ts_bspline_num_knots(&tmp);
+			resize = (int)(-1*deg + (k - (num_knots - order)));
+			ts_internal_bspline_resize(&tmp, resize, 1, &tmp, b);
+			knots = ts_internal_bspline_access_knots(&tmp);
+			num_knots = ts_bspline_num_knots(&tmp);
+		}
+
+		k = order;
+		while (k < num_knots - order) {
+			ts_internal_bspline_split(&tmp, knots[k], &tmp, &k, b);
+			knots = ts_internal_bspline_access_knots(&tmp);
+			num_knots = ts_bspline_num_knots(&tmp);
+			k++;
+		}
+
+		if (spline == _beziers_)
+			ts_bspline_free(_beziers_);
+		ts_bspline_move(&tmp, _beziers_);
+	ETRY
+
+	ts_bspline_free(&tmp);
+	if (e < 0)
+		longjmp(buf, e);
+}
+
+tsError ts_bspline_to_beziers(const tsBSpline *spline, tsBSpline *_beziers_)
+{
+	tsError err;
+	jmp_buf buf;
+	TRY(buf, err)
+		ts_internal_bspline_to_beziers(spline, _beziers_, buf);
+	CATCH
+		if (spline != _beziers_)
+			ts_bspline_default(_beziers_);
+	ETRY
+	return err;
+}
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Utility Functions                                                        *
+*                                                                             *
+******************************************************************************/
+int ts_fequals(tsReal x, tsReal y)
+{
+	if (fabs(x-y) <= FLT_MAX_ABS_ERROR) {
+		return 1;
+	} else {
+		const tsReal r = (tsReal)fabs(x) > (tsReal)fabs(y) ?
+			(tsReal)fabs((x-y) / x) : (tsReal)fabs((x-y) / y);
+		return r <= FLT_MAX_REL_ERROR;
+	}
+}
+
+const char* ts_enum_str(tsError err)
+{
+	if (err == TS_MALLOC)
+		return "malloc failed";
+	else if (err == TS_DIM_ZERO)
+		return "dim == 0";
+	else if (err == TS_DEG_GE_NCTRLP)
+		return "deg >= #ctrlp";
+	else if (err == TS_U_UNDEFINED)
+		return "spline is undefined at given u";
+	else if (err == TS_MULTIPLICITY)
+		return "s > order";
+	else if (err == TS_KNOTS_DECR)
+		return "decreasing knot vector";
+	else if (err == TS_NUM_KNOTS)
+		return "unexpected number of knots";
+	else if (err == TS_UNDERIVABLE)
+		return "spline is not derivable";
+	return "unknown error";
+}
+
+tsError ts_str_enum(const char *str)
+{
+	if (!strcmp(str, ts_enum_str(TS_MALLOC)))
+		return TS_MALLOC;
+	else if (!strcmp(str, ts_enum_str(TS_DIM_ZERO)))
+		return TS_DIM_ZERO;
+	else if (!strcmp(str, ts_enum_str(TS_DEG_GE_NCTRLP)))
+		return TS_DEG_GE_NCTRLP;
+	else if (!strcmp(str, ts_enum_str(TS_U_UNDEFINED)))
+		return TS_U_UNDEFINED;
+	else if (!strcmp(str, ts_enum_str(TS_MULTIPLICITY)))
+		return TS_MULTIPLICITY;
+	else if (!strcmp(str, ts_enum_str(TS_KNOTS_DECR)))
+		return TS_KNOTS_DECR;
+	else if (!strcmp(str, ts_enum_str(TS_NUM_KNOTS)))
+		return TS_NUM_KNOTS;
+	else if (!strcmp(str, ts_enum_str(TS_UNDERIVABLE)))
+		return TS_UNDERIVABLE;
+	return TS_SUCCESS;
+}
+
+void ts_arr_fill(tsReal *arr, size_t num, tsReal val)
+{
+	size_t i;
+	for (i = 0; i < num; i++)
+		arr[i] = val;
+}
+
+tsReal ts_ctrlp_dist2(const tsReal *x, const tsReal *y, size_t dim)
+{
+	tsReal sum = 0;
+	size_t i;
+	for (i = 0; i < dim; i++)
+		sum += (x[i] - y[i]) * (x[i] - y[i]);
+	return (tsReal) sqrt(sum);
+}

+ 1152 - 0
src/decition/decition_brain/decision/tinyspline/tinyspline.h

@@ -0,0 +1,1152 @@
+/** @file */
+
+#ifndef TINYSPLINE_H
+#define	TINYSPLINE_H
+
+#include <stddef.h>
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+/******************************************************************************
+*                                                                             *
+* :: System Dependent Configuration                                           *
+*                                                                             *
+* The following configuration values must be adapted to your system. Some of  *
+* them may be configured with preprocessor definitions. The default values    *
+* should be fine for most modern hardware, such as x86, x86_64, and arm.      *
+*                                                                             *
+******************************************************************************/
+#ifdef TINYSPLINE_FLOAT_PRECISION
+typedef float tsReal;
+#else
+typedef double tsReal;
+#endif
+
+#define FLT_MAX_ABS_ERROR 1e-5
+#define FLT_MAX_REL_ERROR 1e-8
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Data Types                                                               *
+*                                                                             *
+* The following section defines all data types available in TinySpline.       *
+*                                                                             *
+******************************************************************************/
+/**
+ * Defines the error codes used by various functions to indicate different
+ * types of errors. The following code snippet shows how to handle errors:
+ *
+ *      tsError err = ...                  // any function call here
+ *      if (err) {                         // or use err != TS_SUCCESS
+ *          printf("we got an error!");
+ *          return err;                    // you may want to reuse error codes
+ *      }
+ */
+typedef enum
+{
+	/* No error. */
+	TS_SUCCESS = 0,
+
+	/* Unable to allocate memory (using malloc/realloc). */
+	TS_MALLOC = -1,
+
+	/* The dimension of the control points are 0. */
+	TS_DIM_ZERO = -2,
+
+	/* Degree of spline >= number of control points. */
+	TS_DEG_GE_NCTRLP = -3,
+
+	/* Spline is not defined at knot value u. */
+	TS_U_UNDEFINED = -4,
+
+	/* Multiplicity of a knot (s) > order of spline.  */
+	TS_MULTIPLICITY = -5,
+
+	/* Decreasing knot vector. */
+	TS_KNOTS_DECR = -6,
+
+	/* Unexpected number of knots. */
+	TS_NUM_KNOTS = -7,
+
+	/* Spline is not derivable */
+	TS_UNDERIVABLE = -8,
+
+	/* len_control_points % dim != 0 */
+	TS_LCTRLP_DIM_MISMATCH = -10
+} tsError;
+
+/**
+ * Describes the structure of the knot vector of a NURBS/B-Spline. For more
+ * details, see:
+ *
+ *     www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-curve.html
+ */
+typedef enum
+{
+	/* Not available/Undefined. */
+	TS_NONE = 0,
+
+	/* Uniformly spaced knot vector. */
+	TS_OPENED = 1,
+
+	/* Uniformly spaced knot vector with clamped end knots. */
+	TS_CLAMPED = 2,
+
+	/* Uniformly spaced knot vector with s(u) = order of spline. */
+	TS_BEZIERS = 3
+} tsBSplineType;
+
+/**
+ * Represents a B-Spline which may also be used for NURBS, Bezier curves,
+ * lines, and points. NURBS are represented by homogeneous coordinates where
+ * the last component of a control point stores the weight of this control
+ * point. Bezier curves are B-Splines with 'num_control_points == order' and a
+ * clamped knot vector, therefore passing through their first and last control
+ * point (a property which does not necessarily apply to B-Splines and NURBS).
+ * If a Bezier curve consists of two control points only, we call it a line.
+ * Points, ultimately, are just very short lines consisting of a single control
+ * point.
+ *
+ * Two dimensional control points are stored as follows:
+ *
+ *     [x_0, y_0, x_1, y_1, ..., x_n-1, y_n-1]
+ *
+ * Tree dimensional control points are stored as follows:
+ *
+ *     [x_0, y_0, z_0, x_1, y_1, z_1, ..., x_n-1, y_n-1, z_n-1]
+ *
+ * ... and so on. NURBS are represented by homogeneous coordinates. For
+ * example, let's say we have a NURBS in 2D consisting of 11 control points
+ * where 'w_i' is the weight of the i'th control point. Then, the corresponding
+ * control points are stored as follows:
+ *
+ *     [x_0*w_0, y_0*w_0, w_0, x_1*w_1, y_1*w_1, w_1, ..., x_10*w_10, y_10*w_10, w_10]
+ */
+typedef struct
+{
+	struct tsBSplineImpl *pImpl; /**< The actual implementation. */
+} tsBSpline;
+
+/**
+ * Represents the output of De Boor's algorithm. De Boor's algorithm is used to
+ * evaluate a spline at given knot value 'u' by iteratively computing a net of
+ * intermediate values until the result is available:
+ *
+ *     https://en.wikipedia.org/wiki/De_Boor%27s_algorithm
+ *     https://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/de-Boor.html
+ *
+ * All points of a net are stored in 'points'. The resulting point is the last
+ * point in 'points' and, for the sake of convenience, may be accessed with
+ * 'result':
+ *
+ *     tsDeBoorNet net = ...    // evaluate an arbitrary spline and store
+ *                              // the resulting net of points in 'net'
+ *
+ *     ts_deboornet_result(...) // use 'result' to access the resulting point
+ *
+ * Two dimensional points are stored as follows:
+ *
+ *     [x_0, y_0, x_1, y_1, ..., x_n-1, y_n-1]
+ *
+ * Tree dimensional points are stored as follows:
+ *
+ *     [x_0, y_0, z_0, x_1, y_1, z_1, ..., x_n-1, y_n-1, z_n-1]
+ *
+ * ... and so on. The output also supports homogeneous coordinates described
+ * above.
+ *
+ * There is a special case in which the evaluation of a knot value 'u' returns
+ * two results instead of one. It occurs when the multiplicity of 'u' ( s(u) )
+ * is equals to a spline's order, indicating that the spline is discontinuous
+ * at 'u'. This is common practice for B-Splines (and NURBS) consisting of
+ * connected Bezier curves where the endpoint of curve 'c_i' is equals to the
+ * start point of curve 'c_i+1'. The end point of 'c_i' and the start point of
+ * 'c_i+1' may still be completely different though, yielding to a spline
+ * having a (real and visible) gap at 'u'. Consequently, De Boor's algorithm
+ * must return two results if 's(u) == order' in order to give access to the
+ * desired points.  In such case, 'points' stores only the two resulting points
+ * (there is no net to calculate) and 'result' points to the *first* point in
+ * 'points'. Since having (real) gaps in splines is unusual, both points in
+ * 'points' are generally equals, making it easy to handle this special case by
+ * accessing 'result' as already shown above for regular cases:
+ *
+ *     tsDeBoorNet net = ...    // evaluate a spline which is discontinuous at
+ *                              // the given knot value, yielding to a net with
+ *                              // two results
+ *
+ *     ts_deboornet_result(...) // use 'result' to access the resulting point
+ *
+ * However, you can access both points if necessary:
+ *
+ *     tsDeBoorNet net = ...    // evaluate a spline which is discontinuous at
+ *                              // the given knot value, yielding to a net with
+ *                              // two results
+ *
+ *     ts_deboornet_result(...)[0] ...       // stores the first component of
+ *                                           // the first point
+ *
+ *     ts_deboornet_result(...)[dim(spline)] // stores the first component of
+ *                                           // the second point
+ *
+ * As if this wasn't complicated enough, there is an exception for this special
+ * case, yielding to exactly one result (just like the regular case) even if
+ * 's(u) == order'. It occurs when 'u' is the lower or upper bound of a
+ * spline's domain. For instance, if 'b' is a spline with domain [0, 1] and is
+ * evaluated at 'u = 0' or 'u = 1' then 'result' is *always* a single point
+ * regardless of the multiplicity of 'u'. Hence, handling this exception is
+ * straightforward:
+ *
+ *     tsDeBoorNet net = ...    // evaluate a spline at the lower or upper
+ *                              // bound of its domain, for instance, 0 or 1
+ *
+ *     ts_deboornet_result(...) // use 'result' to access the resulting point
+ *
+ * In summary, we have three different types of evaluation. 1) The regular case
+ * returning all points of the net we used to calculate the resulting point. 2)
+ * The special case returning exactly two points which is required for splines
+ * with (real) gaps. 3) The exception of 2) returning exactly one point even if
+ * 's(u) == order'. All in all this looks quite complex (and actually it is)
+ * but for most applications you do not have to deal with it. Just use 'result'
+ * to access the outcome of De Boor's algorithm.
+ */
+typedef struct
+{
+	struct tsDeBoorNetImpl *pImpl; /**< The actual implementation. */
+} tsDeBoorNet;
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Field Access Functions                                                   *
+*                                                                             *
+* The following section contains getter and setter functions for the internal *
+* state of the structs listed above.                                          *
+*                                                                             *
+******************************************************************************/
+/**
+ * Returns the degree of \p spline.
+ *
+ * @param spline
+ * 	The spline whose degree is read.
+ * @return
+ * 	The degree of \p spline.
+ */
+size_t ts_bspline_degree(const tsBSpline *spline);
+
+/**
+ * Sets the degree of \p spline.
+ *
+ * @param spline
+ * 	The spline whose degree is set.
+ * @param deg
+ * 	The degree to be set.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_DEG_GE_NCTRLP
+ * 	If \p degree >= ts_bspline_get_control_points(spline).
+ */
+tsError ts_bspline_set_degree(tsBSpline *spline, size_t deg);
+
+/**
+ * Returns the order (degree + 1) of \p spline.
+ *
+ * @param spline
+ * 	The spline whose order is read.
+ * @return
+ * 	The order of \p spline.
+ */
+size_t ts_bspline_order(const tsBSpline *spline);
+
+/**
+ * Sets the order (degree + 1) of \p spline.
+ *
+ * @param spline
+ * 	The spline whose order is set.
+ * @param order
+ * 	The order to be set.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_DEG_GE_NCTRLP
+ * 	If \p order > ts_bspline_get_control_points(spline) or if \p order == 0
+ * 	( due to the underflow resulting from: order - 1 => 0 - 1 => INT_MAX
+ * 	which always is >= ts_bspline_get_control_points(spline) ).
+ */
+tsError ts_bspline_set_order(tsBSpline *spline, size_t order);
+
+/**
+ * Returns the dimension of \p spline. The dimension of a spline describes the
+ * number of components for each point in ts_bspline_get_control_points(spline).
+ * One-dimensional splines are possible, albeit their benefit might be
+ * questionable.
+ *
+ * @param spline
+ * 	The spline whose dimension is read.
+ * @return
+ * 	The dimension of \p spline.
+ */
+size_t ts_bspline_dimension(const tsBSpline *spline);
+
+/**
+ * Sets the dimension of \p spline. The following conditions must be satisfied:
+ *
+ * 	(1) dim >= 1
+ * 	(2) len_control_points % dim == 0
+ *
+ * with _len_control_points_ being the length of the control point array of \p
+ * spline. The dimension of a spline describes the number of components for
+ * each point in ts_bspline_get_control_points(spline). One-dimensional splines
+ * are possible, albeit their benefit might be questionable.
+ *
+ * @param spline
+ * 	The spline whose dimension is set.
+ * @param dim
+ * 	The dimension to be set.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_DIM_ZERO
+ * 	If \p dimension == 0.
+ * @return TS_LCTRLP_DIM_MISMATCH
+ * 	If len_control_points % \p dim != 0
+ */
+tsError ts_bspline_set_dimension(tsBSpline *spline, size_t dim);
+
+/**
+ * Returns the length of the control point array of \p spline.
+ *
+ * @param spline
+ * 	The spline with its control point array whose length is read.
+ * @return
+ * 	The length of the control point array of \p spline.
+ */
+size_t ts_bspline_len_control_points(const tsBSpline *spline);
+
+/**
+ * Returns the number of control points of \p spline.
+ *
+ * @param spline
+ * 	The spline whose number of control points is read.
+ * @return
+ * 	The number of control points of \p spline.
+ */
+size_t ts_bspline_num_control_points(const tsBSpline *spline);
+
+/**
+ * Returns the size of the control point array of \p spline. This function may
+ * be useful when copying control points using memcpy or memmove.
+ *
+ * @param spline
+ * 	The spline with its control point array whose size is read.
+ * @return
+ * 	The size of the control point array of \p spline.
+ */
+size_t ts_bspline_sof_control_points(const tsBSpline *spline);
+
+/**
+ * Returns a deep copy of the control points of \p spline.
+ *
+ * @param spline
+ * 	The spline whose control points are read.
+ * @param ctrlp
+ * 	The output array.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_MALLOC
+ * 	If allocating memory failed.
+ */
+tsError ts_bspline_control_points(const tsBSpline *spline, tsReal **ctrlp);
+
+/**
+ * Sets the control points of \p spline. Creates a deep copy of \p ctrlp.
+ *
+ * @param spline
+ * 	The spline whose control points are set.
+ * @param ctrlp
+ * 	The values to deep copy.
+ * @return TS_SUCCESS
+ * 	On success.
+ */
+tsError ts_bspline_set_control_points(tsBSpline *spline, const tsReal *ctrlp);
+
+/**
+ * Returns the number of knots of \p spline.
+ *
+ * @param spline
+ * 	The spline whose number of knots is read.
+ * @return
+ * 	The number of knots of \p spline.
+ */
+size_t ts_bspline_num_knots(const tsBSpline *spline);
+
+/**
+ * Returns the size of the knot array of \p spline. This function may be useful
+ * when copying knots using memcpy or memmove.
+ *
+ * @param spline
+ * 	The spline with its knot array whose size is read.
+ * @return TS_SUCCESS
+ * 	The size of the knot array of \p spline.
+ */
+size_t ts_bspline_sof_knots(const tsBSpline *spline);
+
+/**
+ * Returns a deep copy of the knots of \p spline.
+ *
+ * @param spline
+ * 	The spline whose knots are read.
+ * @param knots
+ * 	The output array.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_MALLOC
+ * 	If allocating memory failed.
+ */
+tsError ts_bspline_knots(const tsBSpline *spline, tsReal **knots);
+
+/**
+ * Sets the knots of \p spline. Creates a deep copy of \p knots.
+ *
+ * @param spline
+ * 	The spline whose knots are set.
+ * @param knots
+ * 	The values to deep copy.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_KNOTS_DECR
+ * 	If the knot vector is decreasing.
+ * @return TS_MULTIPLICITY
+ * 	If there is a knot with multiplicity > order
+ */
+tsError ts_bspline_set_knots(tsBSpline *spline, const tsReal *knots);
+
+/* ------------------------------------------------------------------------- */
+
+/**
+ * Returns the knot (sometimes also called 'u' or 't') of \p net.
+ *
+ * @param net
+ * 	The net whose knot is read.
+ * @return
+ * 	The knot of \p net.
+ */
+tsReal ts_deboornet_knot(const tsDeBoorNet *net);
+
+/**
+ * Returns the index [u_k, u_k+1) with u being the knot of \p net.
+ *
+ * @param net
+ * 	The net whose index is read.
+ * @return
+ * 	The index [u_k, u_k+1) with u being the knot of \p net.
+ */
+size_t ts_deboornet_index(const tsDeBoorNet *net);
+
+/**
+ * Returns the multiplicity of the knot of \p net.
+ *
+ * @param net
+ * 	The net whose multiplicity is read.
+ * @return
+ * 	The multiplicity of the knot of \p net.
+ */
+size_t ts_deboornet_multiplicity(const tsDeBoorNet *net);
+
+/**
+ * Returns the number of insertion that were necessary to evaluate the knot of
+ * \p net.
+ *
+ * @param net
+ * 	The net with its knot whose number of insertions is read.
+ * @return
+ * 	The number of insertions that were necessary to evaluate the knot of \p
+ * 	net.
+ */
+size_t ts_deboornet_num_insertions(const tsDeBoorNet *net);
+
+/**
+ * Returns the dimension of \p net. The dimension of a net describes the number
+ * of components for each point in ts_bspline_get_points(spline).
+ * One-dimensional nets are possible, albeit their benefit might be
+ * questionable.
+ *
+ * @param net
+ * 	The net whose dimension is read.
+ * @return
+ * 	The dimension of \p net.
+ */
+size_t ts_deboornet_dimension(const tsDeBoorNet *net);
+
+/**
+ * Returns the length of the point array of \p net.
+ *
+ * @param net
+ * 	The net with its point array whose length is read.
+ * @return
+ * 	The length of the point array of \p net.
+ */
+size_t ts_deboornet_len_points(const tsDeBoorNet *net);
+
+/**
+ * Returns the number of points of \p net.
+ *
+ * @param net
+ * 	The net whose number of points is read.
+ * @return
+ * 	The number of points of \p net.
+ */
+size_t ts_deboornet_num_points(const tsDeBoorNet *net);
+
+/**
+ * Returns the size of the point array of \p net. This function may be useful
+ * when copying points using memcpy or memmove.
+ *
+ * @param net
+ * 	The net with its point array whose size is read.
+ * @return
+ * 	The size of the point array of \p net.
+ */
+size_t ts_deboornet_sof_points(const tsDeBoorNet *net);
+
+/**
+ * Returns a deep copy of the points of \p net.
+ *
+ * @param net
+ * 	The net whose points is read.
+ * @param points
+ * 	The output array.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_MALLOC
+ * 	If allocating memory failed.
+ */
+tsError ts_deboornet_points(const tsDeBoorNet *net, tsReal **points);
+
+/**
+ * Returns the length of the result array of \p net.
+ *
+ * @param net
+ * 	The net with its result array whose length is read.
+ * @return
+ * 	The length of the result array of \p net.
+ */
+size_t ts_deboornet_len_result(const tsDeBoorNet *net);
+
+/**
+ * Returns the number of points in the result array of \p net
+ * (1 <= num_result <= 2).
+ *
+ * @param net
+ * 	The net with its result array whose number of points is read.
+ * @return
+ * 	The number of points in the result array of \p net.
+ */
+size_t ts_deboornet_num_result(const tsDeBoorNet *net);
+
+/**
+ * Returns the size of the result array of \p net. This function may be useful
+ * when copying results using memcpy or memmove.
+ *
+ * @param net
+ * 	The net with its result array whose size is read.
+ * @return TS_SUCCESS
+ * 	The size of the result array of \p net.
+ */
+size_t ts_deboornet_sof_result(const tsDeBoorNet *net);
+
+/**
+ * Returns a deep copy of the result of \p net.
+ *
+ * @param net
+ * 	The net whose result is read.
+ * @param result
+ * 	The output array.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_MALLOC
+ * 	If allocating memory failed.
+ */
+tsError ts_deboornet_result(const tsDeBoorNet *net, tsReal **result);
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Constructors, Destructors, Copy, and Move Functions                      *
+*                                                                             *
+* The following section contains functions to create and delete instances of  *
+* the data types listed above. Additionally, each data type has a copy and    *
+* move function.                                                              *
+*                                                                             *
+******************************************************************************/
+/**
+ * The default constructor of tsBSpline.
+ *
+ * All values of \p \_spline\_ are set to 0/NULL.
+ * 
+ * @param \_spline\_
+ * 	The spline whose values are set 0/NULL.
+ */
+void ts_bspline_default(tsBSpline *_spline_);
+
+/**
+ * A convenient constructor for tsBSpline.
+ *
+ * On error, all values of \p \_spline\_ are set to 0/NULL.
+ *
+ * @param n_ctrlp
+ * 	The number of control points of \p \_spline\_.
+ * @param dim
+ * 	The dimension of each control point in \p \_spline\_.
+ * @param deg
+ * 	The degree of \p \_spline\_.
+ * @param type
+ * 	How to setup the knot vector of \p \_spline\_.
+ * @param \_spline\_
+ * 	The output parameter storing the result of this function.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_DIM_ZERO
+ * 	If \p deg == 0.
+ * @return TS_DEG_GE_NCTRLP
+ * 	If \p deg >= \p n_ctrlp.
+ * @return TS_NUM_KNOTS
+ * 	If \p type == ::TS_BEZIERS and (\p n_ctrlp % \p deg + 1) != 0.
+ * @return TS_MALLOC
+ * 	If allocating memory failed.
+ */
+tsError ts_bspline_new(size_t n_ctrlp, size_t dim, size_t deg,
+	tsBSplineType type, tsBSpline *_spline_);
+
+/**
+ * The copy constructor of tsBSpline.
+ *
+ * Creates a deep copy of \p original and stores the result in \p \_copy\_.
+ *
+ * On error, all values of \p \_copy\_ are set to 0/NULL. Does nothing, if
+ * \p original == \p \_copy\_.
+ *
+ * @param original
+ * 	The spline to deep copy.
+ * @param \_copy\_
+ * 	The output parameter storing the copied values of \p original.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_MALLOC
+ * 	If allocating memory failed.
+ */
+tsError ts_bspline_copy(const tsBSpline *original, tsBSpline *_copy_);
+
+/**
+ * The move constructor of tsBSpline.
+ *
+ * Moves all values from \p from to \p \_to\_ and calls ::ts_bspline_default
+ * on \p from afterwards. Does nothing, if \p from == \p \_to\_.
+ * 
+ * @param from
+ * 	The spline whose values are moved to \p \_to\_.
+ * @param \_to\_
+ * 	The output parameter storing the moved values of \p from.
+ */
+void ts_bspline_move(tsBSpline *from, tsBSpline *_to_);
+
+/**
+ * The destructor of tsBSpline.
+ *
+ * Frees all dynamically allocated memory in \p \_spline\_ and calls
+ * ::ts_bspline_default afterwards.
+ * 
+ * @param \_spline\_
+ * 	The spline to free.
+ */
+void ts_bspline_free(tsBSpline *_spline_);
+
+/* ------------------------------------------------------------------------- */
+
+/**
+ * The default constructor of tsDeBoorNet.
+ *
+ * All values of \p \_deBoorNet\_ are set to 0/NULL.
+ * 
+ * @param \_deBoorNet\_
+ * 	The net whose values are set 0/NULL.
+ */
+void ts_deboornet_default(tsDeBoorNet *_deBoorNet_);
+
+/**
+ * The copy constructor of tsDeBoorNet.
+ *
+ * Creates a deep copy of \p original and stores the result in \p \_copy\_.
+ *
+ * On error, all values of \p _copy_ are set to 0/NULL. Does nothing, if
+ * \p original == \p \_copy\_.
+ *
+ * @param original
+ * 	The net to deep copy.
+ * @param \_copy\_
+ * 	The output parameter storing the copied values of \p original.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_MALLOC
+ * 	If allocating memory failed.
+ */
+tsError ts_deboornet_copy(const tsDeBoorNet *original, tsDeBoorNet *_copy_);
+
+/**
+ * The move constructor of tsDeBoorNet.
+ *
+ * Moves all values from \p from to \p \_to\_ and calls ::ts_deboornet_default
+ * on \p from afterwards. Does nothing, if \p from == \p \_to\_.
+ * 
+ * @param from
+ * 	The net whose values are moved to \p \_to\_.
+ * @param \_to\_
+ * 	The output parameter storing the moved values of \p from.
+ */
+void ts_deboornet_move(tsDeBoorNet *from, tsDeBoorNet *_to_);
+
+/**
+ * The destructor of tsDeBoorNet.
+ *
+ * Frees all dynamically allocated memory in \p \_deBoorNet\_ and calls
+ * ::ts_deboornet_default afterwards.
+ * 
+ * @param \_deBoorNet\_
+ * 	The net to free.
+ */
+void ts_deboornet_free(tsDeBoorNet *_deBoorNet_);
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Interpolation and Approximation Functions                                *
+*                                                                             *
+* The following section contains functions to interpolate and approximate     *
+* arbitrary splines.                                                          *
+*                                                                             *
+******************************************************************************/
+/**
+ * Performs a cubic spline interpolation using the thomas algorithm, see:
+ * 
+ *     https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm
+ *     http://www.math.ucla.edu/~baker/149.1.02w/handouts/dd_splines.pdf
+ *     http://www.bakoma-tex.com/doc/generic/pst-bspline/pst-bspline-doc.pdf
+ *
+ * The resulting spline is a sequence of bezier curves connecting each point
+ * in \p points. Each bezier curve _b_ is of degree 3 with \p dim being the
+ * dimension of the each control point in _b_. The total number of control
+ * points is (\p n - 1) * 4.
+ *
+ * On error, all values of \p \_spline\_ are set to 0/NULL.
+ *
+ * Note: \p n is the number of points in \p points and not the length of
+ * \p points. For instance, the follwing point vector yields to \p n = 4 and
+ * \p dim = 2:
+ * 
+ *     [x0, y0, x1, y1, x2, y2, x3, y3]
+ *
+ * @param points
+ * 	The points to interpolate.
+ * @param n
+ * 	The number of points in \p points.
+ * @param dim
+ * 	The dimension of each control point in \p \_spline\_.
+ * @param \_spline\_
+ * 	The output parameter storing the result of this function.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_DIM_ZERO
+ * 	If \p dim == 0.
+ * @return TS_DEG_GE_NCTRLP
+ * 	If \p n < 2.
+ * @return TS_MALLOC
+ * 	If allocating memory failed.
+ */
+tsError ts_bspline_interpolate_cubic(const tsReal *points, size_t n,
+	size_t dim, tsBSpline *_spline_);
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Query Functions                                                          *
+*                                                                             *
+* The following section contains functions to query splines.                  *
+*                                                                             *
+******************************************************************************/
+/**
+ * Evaluates \p spline at knot value \p u and stores the result in
+ * \p \_deBoorNet\_.
+ *
+ * On error, all values of \p \_deBoorNet\_ are set to 0/NULL.
+ *
+ * @param spline
+ * 	The spline to evaluate.
+ * @param u
+ * 	The knot value to evaluate.
+ * @param \_deBoorNet\_
+ * 	The output parameter storing the evaluation result.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_MULTIPLICITY
+ * 	If multiplicity s(\p u) > order of \p spline.
+ * @return TS_U_UNDEFINED
+ * 	If \p spline is not defined at knot value \p u.
+ * @return TS_MALLOC
+ * 	If allocating memory failed.
+ */
+tsError ts_bspline_eval(const tsBSpline *spline, tsReal u,
+	tsDeBoorNet *_deBoorNet_);
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Transformation functions                                                 *
+*                                                                             *
+* TinySpline is a library focusing on transformations. That is, most          *
+* functions are used to transform splines by modifying their state, e.g.,     *
+* their number of control points, their degree, and so on. Accordingly, each  *
+* transformation functions specifies an input and output parameter (along     *
+* with the other parameters required to calculate the actual transformation). *
+* By passing a different pointer to the output parameter, the transformation  *
+* result is calculated and stored without changing the state of the input.    *
+* This is in particular useful when dealing with errors as the original state *
+* will never be modified. For instance, let's have a look at the following    *
+* code snippet:                                                               *
+*                                                                             *
+*     tsBSpline in = ...    // an arbitrary spline                            *
+*     tsBSpline out;        // result of transformation                       *
+*                                                                             *
+*     // Subdivide 'in' into sequence of bezier curves and store the result   *
+*     // in 'out'. Does not change 'in' in any way.                           *
+*     tsError err = ts_bspline_to_beziers(&in, &out);                         *
+*     if (err != TS_SUCCESS) {                                                *
+*         // fortunately, 'in' has not been changed                           *
+*     }                                                                       *
+*                                                                             *
+* Even if 'ts_bspline_to_beziers' fails, the state of 'in' has not been       *
+* changed allowing you to handle the error properly.                          *
+*                                                                             *
+* Unless stated otherwise, the order of the parameters for transformation     *
+* functions is:                                                               *
+*                                                                             *
+*     function(input, [additional_input], output, [additional_output])        *
+*                                                                             *
+* 'additional_input' are parameters required to calculate the actual          *
+* transformation. 'additional_output' are parameters storing further result.  *
+*                                                                             *
+* Note: None of TinySpline's transformation functions frees the memory of the *
+*       output parameter. Thus, when using the same output parameter multiple *
+*       times, make sure to free memory before each call. Otherwise, you will *
+*       have a bad time with memory leaks:                                    *
+*                                                                             *
+*     tsBSpline in = ...                  // an arbitrary spline              *
+*     tsBSpline out;                      // result of transformations        *
+*                                                                             *
+*     ts_bspline_to_beziers(&in, &out);   // first transformation             *
+*     ...                                 // some code                        *
+*     ts_bspline_free(&out);              // avoid memory leak.               *
+*     ts_bspline_buckle(&in, &out);       // next transformation              *
+*                                                                             *
+* If you want to modify your input directly without having a separate output, *
+* pass it as input and output at once:                                        *
+*                                                                             *
+*     tsBSpline s = ...                       // an arbitrary spline          *
+*     tsReal *knots = ...                     // a knot vector                *
+*                                                                             *
+*     ts_bspline_set_knots(&s, knots, &s);    // copy 'knots' into 's'        *
+*                                                                             *
+* Note: If a transformation function fails *and* input != output, all fields  *
+*       of the output parameter are set to 0/NULL. If input == output, your   *
+*       input may have an invalid state in case of errors.                    *
+*                                                                             *
+******************************************************************************/
+/**
+ * Computes the derivative of \p spline, see:
+ * 
+ *     http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/B-spline/bspline-derv.html
+ *
+ * The derivative of a spline _s_ of degree _d_ with _m_ control points and
+ * _n_ knots is another spline _s'_ of degree _d-1_ with _m-1_ control points
+ * and _n-2_ knots, defined over _s_ as:
+ * 
+ * \f{eqnarray*}{
+ *   s'(u) &=& \sum_{i=0}^{n-1} N_{i+1,p-1}(u) *
+ * 		(P_{i+1} - P_{i}) * p / (u_{i+p+1}-u_{i+1}) \\
+ *         &=& \sum_{i=1}^{n} N_{i,p-1}(u) *
+ * 		(P_{i} - P_{i-1}) * p / (u_{i+p}-u_{i})
+ * \f}
+ * 
+ * If _s_ has a clamped knot vector, it can be shown that:
+ * 
+ * \f{eqnarray*}{
+ *   s'(u) &=& \sum_{i=0}^{n-1} N_{i,p-1}(u) *
+ * 		(P_{i+1} - P_{i}) * p / (u_{i+p+1}-u_{i+1})
+ * \f}
+ * 
+ * where the multiplicity of the first and the last knot value _u_ is _p_
+ * rather than _p+1_.
+ *
+ * On error, (and if \p spline != \p \_derivative\_) all values of
+ * \p \_derivative\_ are set to 0/NULL.
+ *
+ * @param spline
+ * 	The spline to derive.
+ * @param \_derivative\_
+ *	The output parameter storing the derivative of \p spline.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_UNDERIVABLE
+ * 	If \p spline->deg < 1, \p spline->n_ctrlp < 2, or the multiplicity of
+ * 	an internal knot of \p spline is greater than the degree of \p spline.
+ * 	NOTE: This will be fixed in the future.
+ * @return TS_MALLOC
+ * 	If allocating memory failed.
+ */
+tsError ts_bspline_derive(const tsBSpline *spline, tsBSpline *_derivative_);
+
+/**
+ * Fills the knot vector of \p spline according to \p type with minimum knot
+ * value \p min to maximum knot value \p max and stores the result in
+ * \p \_result\_. Creates a deep copy of \p spline, if
+ * \p spline != \p \_result\_.
+ *
+ * On error, (and if \p spline != \p \_result\_) all values of \p \_result\_
+ * are set to 0/NULL.
+ *
+ * @param spline
+ * 	The spline to deep copy (if \p spline != \p \_result\_) and whose knot
+ * 	vector is filled according to \p type with minimum knot value \p min
+ * 	and maximum knot value \p max.
+ * @param type
+ * 	How to fill the knot vector of \p \_result\_.
+ * @param min
+ * 	The minimum knot value of the knot vector of \p \_result\_.
+ * @param max
+ * 	The maximum knot value of the knot vector of \p \_result\_.
+ * @param \_result\_
+ * 	The output parameter storing the result of this function.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_DEG_GE_NCTRLP
+ * 	If \p spline->n_knots < 2*(\p original->deg+1). We can reuse this
+ * 	error code because \p spline->n_knots < 2*(\p spline->deg+1) implies
+ * 	\p spline->deg >= \p spline->n_ctrlp. Furthermore, using
+ * 	TS_DEG_GE_NCTRLP instead of TS_NUM_KNOTS ensures that TS_NUM_KNOTS is
+ * 	not used twice for this function. To be more fail-safe,
+ * 	\p spline->deg+1 instead of \p spline->order is used, to make sure
+ * 	that \p spline->deg+1 >= 1.
+ * @return TS_NUM_KNOTS
+ * 	If \p type == TS_BEZIERS and
+ * 	\p spline->n_knots % \p spline->order != 0.
+ * @return TS_KNOTS_DECR
+ * 	If \p min >= \p max. (::ts_fequals is used to determine whether
+ * 	\p min == \p max).
+ * @return TS_MALLOC
+ * 	If \p spline != \p \_result\_ and allocating memory failed.
+ */
+tsError ts_bspline_fill_knots(const tsBSpline *spline, tsBSplineType type,
+	tsReal min, tsReal max, tsBSpline *_result_);
+
+/**
+ * Inserts the knot value \p u \p n times into \p spline and stores the result
+ * in \p \_result\_. Creates a deep copy of \p spline, if
+ * \p spline != \p \_result\_.
+ * 
+ * On error, (and if \p spline != \p \_result\_) all values of \p \_result\_
+ * are set to 0/NULL.
+ * 
+ * @param spline
+ * 	The spline to deep copy (if \p spline != \p \_result\_) and whose knot
+ * 	vector is extended with \p u \p n times.
+ * @param u
+ * 	The knot value to insert.
+ * @param n
+ * 	How many times \p u should be inserted.
+ * @param \_result\_
+ * 	The output parameter storing the updated knot vector.
+ * @param \_k\_
+ * 	The output parameter storing the last index of \p u in \p \_result\_.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_MALLOC
+ * 	If \p spline != \p \_result\_ and allocating memory failed.
+ */
+tsError ts_bspline_insert_knot(const tsBSpline *spline, tsReal u, size_t n,
+	tsBSpline *_result_, size_t *_k_);
+
+/**
+ * Resizes \p spline by \p n (number of control points) and stores the result
+ * in \p \_resized\_. Creates a deep copy of \p spline, if
+ * \p spline != \p \_result\_. If \p back != 0 \p spline is resized at the
+ * end. If \p back == 0 \p spline is resized at front.
+ *
+ * On error, (and if \p spline != \p \_result\_) all values of \p \_result\_
+ * are set to 0/NULL.
+ *
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_DEG_GE_NCTRLP
+ * 	If the degree of \p \_resized\_ would be >= the number of the control
+ * 	points of \p \_resized\_.
+ * @return TS_DIM_ZERO
+ * 	If \p spline != \p \_result\_ and \p spline->dim == 0.
+ * @return TS_DEG_GE_NCTRLP
+ * 	If \p spline != \p \_result\_ and
+ * 	\p spline->deg >= \p spline->n_ctrlp.
+ * @return TS_MALLOC
+ * 	If \p spline != \p \_result\_ and allocating memory failed.
+ */
+tsError ts_bspline_resize(const tsBSpline *spline, int n, int back,
+	tsBSpline *_resized_);
+
+/**
+ * Splits \p spline at \p u and stores the result in \p \_split\_. That is,
+ * \p u is inserted _n_ times such that s(\p u) == \p \_split\_->order.
+ * Creates a deep copy of \p spline, if \p spline != \p \_split\_.
+ * 
+ * On error, (and if \p spline != \p \_split\_) all values of \p \_split\_
+ * are set to 0/NULL.
+ * 
+ * @param spline
+ * 	The spline to deep copy (if \p spline != \p \_result\_) and split.
+ * @param u
+ * 	The split point.
+ * @param \_split\_
+ * 	The output parameter storing the split spline.
+ * @param \_k\_
+ * 	The output parameter storing the last index of \p u in \p \_split\_.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_MALLOC
+ * 	If \p spline != \p \_split\_ and allocating memory failed.
+ */
+tsError ts_bspline_split(const tsBSpline *spline, tsReal u, tsBSpline *_split_,
+	size_t *_k_);
+
+/**
+ * Buckles \p spline by \p b and stores the result in \p \_buckled\_. Creates
+ * a deep copy of \p spline, if \p spline != \p \_buckled\_.
+ *
+ * This function is based on:
+ * 
+ *      Holten, Danny. "Hierarchical edge bundles: Visualization of adjacency
+ *      relations in hierarchical data." Visualization and Computer Graphics,
+ *      IEEE Transactions on 12.5 (2006): 741-748.
+ * 
+ * Holten calls it "straightening" (page 744, equation 1).
+ *
+ * Usually, the range of \p b is: 0.0 <= \p b <= 1.0 with 0 yielding to a line
+ * connecting the first and the last control point (no buckle) and 1 keeping
+ * the original shape (maximum buckle). If \b < 0 or \b > 1 the behaviour is
+ * undefined, though, it will not result in an error.
+ *
+ * On error, (and if \p spline != \p \_buckled\_) all values of \p \_buckled\_
+ * are set to 0/NULL.
+ *
+ * @param spline
+ * 	The spline to buckle by \p b.
+ * @param b
+ * 	The buckle factor (usually 0.0 <= \p b <= 1.0).
+ * @param \_buckled\_
+ * 	The output parameter storing the buckled spline.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_MALLOC
+ * 	If \p spline != \p \_buckled\_ and allocating memory failed.
+ */
+tsError ts_bspline_buckle(const tsBSpline *spline, tsReal b,
+	tsBSpline *_buckled_);
+
+/**
+ * Subdivides \p spline into a sequence of Bezier curvs by splitting it at
+ * each internal knot value. Creates a deep copy of \p spline, if
+ * \p spline != \p \_beziers\_.
+ * 
+ * On error, (and if \p spline != \p \_beziers\_) all values of \p \_beziers\_
+ * are set to 0/NULL.
+ * 
+ * @param spline
+ * 	The spline to subdivide into a sequence of Bezier curves.
+ * @param \_beziers\_
+ * 	The output parameter storing the sequence of Bezier curves.
+ * @return TS_SUCCESS
+ * 	On success.
+ * @return TS_MALLOC
+ * 	If \p spline != \p \_beizers\_ and allocating memory failed.
+ */
+tsError ts_bspline_to_beziers(const tsBSpline *spline, tsBSpline *_beziers_);
+
+
+
+/******************************************************************************
+*                                                                             *
+* :: Utility Functions                                                        *
+*                                                                             *
+* The following section contains utility functions used by TinySpline which   *
+* also may be helpful when using this library.                                *
+*                                                                             *
+******************************************************************************/
+/**
+ * Compares the tsReal values \p x and \p y using an absolute and relative
+ * epsilon environment.
+ *
+ * @param x
+ * 	The x value to compare.
+ * @param y
+ * 	The y value to compare.
+ * @return 1
+ * 	If \p x is equals to \p y.
+ * @return 0
+ * 	Otherwise.
+ */
+int ts_fequals(tsReal x, tsReal y);
+
+/**
+ * Returns the error message associated to \p err. Returns "unknown error" if
+ * \p err is no associated (indicating a bug) or is TS_SUCCESS (which is not
+ * an actual error).
+ */
+const char* ts_enum_str(tsError err);
+
+/**
+ * Returns the error code associated to \p str or TS_SUCCESS if \p str is not
+ * associated. Keep in mind that by concept "unknown error" is not associated,
+ * though, TS_SUCCESS is returned.
+ */
+tsError ts_str_enum(const char *str);
+
+/**
+ * Fills the given array \p arr with \p val from \p arr+0 to \p arr+ \p num
+ * (exclusive).
+ */
+void ts_arr_fill(tsReal *arr, size_t num, tsReal val);
+
+/**
+ * Returns the euclidean distance of \p x and \p y consisting of \p dim
+ * components, respectively.
+ *
+ * @param x
+ * 	The x value.
+ * @param y
+ * 	The y value.
+ * @param dim
+ * 	The dimension of \p x and \p y.
+ * @return
+ * 	The euclidean distanc of \p x and \p y.
+ */
+tsReal ts_ctrlp_dist2(const tsReal *x, const tsReal *y, size_t dim);
+
+
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* TINYSPLINE_H */
+

+ 7 - 0
src/decition/decition_brain/decision/tinyspline/tinyspline.pri

@@ -0,0 +1,7 @@
+HEADERS += \
+    $$PWD/tinyspline.h \
+    $$PWD/tinysplinecpp.h
+
+SOURCES += \
+    $$PWD/tinyspline.c \
+    $$PWD/tinysplinecpp.cpp

+ 350 - 0
src/decition/decition_brain/decision/tinyspline/tinysplinecpp.cpp

@@ -0,0 +1,350 @@
+#include <tinyspline_ros/tinysplinecpp.h>
+#include <stdexcept>
+#include <cstdio>
+
+// Surpress warning C4996 (sprintf_s).
+#ifdef _MSC_VER
+#pragma warning(disable:4996)
+#endif
+
+/******************************************************************************
+*                                                                             *
+* DeBoorNet                                                                   *
+*                                                                             *
+******************************************************************************/
+tinyspline::DeBoorNet::DeBoorNet()
+{
+	ts_deboornet_default(&net);
+}
+
+tinyspline::DeBoorNet::DeBoorNet(const tinyspline::DeBoorNet &other)
+{
+	tsError err = ts_deboornet_copy(&other.net, &net);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+}
+
+tinyspline::DeBoorNet::~DeBoorNet()
+{
+	ts_deboornet_free(&net);
+}
+
+tinyspline::DeBoorNet & tinyspline::DeBoorNet::operator=(
+	const tinyspline::DeBoorNet &other)
+{
+	if (&other != this) {
+		tsError err = ts_deboornet_copy(&other.net, &net);
+		if (err < 0)
+			throw std::runtime_error(ts_enum_str(err));
+	}
+	return *this;
+}
+
+tinyspline::real tinyspline::DeBoorNet::knot() const
+{
+	return ts_deboornet_knot(&net);
+}
+
+size_t tinyspline::DeBoorNet::index() const
+{
+	return ts_deboornet_index(&net);
+}
+
+size_t tinyspline::DeBoorNet::multiplicity() const
+{
+	return ts_deboornet_multiplicity(&net);
+}
+
+size_t tinyspline::DeBoorNet::numInsertions() const
+{
+	return ts_deboornet_num_insertions(&net);
+}
+
+size_t tinyspline::DeBoorNet::dimension() const
+{
+	return ts_deboornet_dimension(&net);
+}
+
+std::vector<tinyspline::real> tinyspline::DeBoorNet::points() const
+{
+	tsReal *points;
+	tsError err = ts_deboornet_points(&net, &points);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	size_t num_points = ts_deboornet_num_points(&net);
+	tinyspline::real *begin = points;
+	tinyspline::real *end = begin + num_points * dimension();
+	std::vector<tinyspline::real> vec =
+		std::vector<tinyspline::real>(begin, end);
+	delete points;
+	return vec;
+}
+
+std::vector<tinyspline::real> tinyspline::DeBoorNet::result() const
+{
+	tsReal *result;
+	tsError err = ts_deboornet_result(&net, &result);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	size_t num_result = ts_deboornet_num_result(&net);
+	tinyspline::real *begin = result;
+	tinyspline::real *end = begin + num_result * dimension();
+	std::vector<tinyspline::real> vec =
+		std::vector<tinyspline::real>(begin, end);
+	delete result;
+	return vec;
+}
+
+tsDeBoorNet * tinyspline::DeBoorNet::data()
+{
+	return &net;
+}
+
+
+
+/******************************************************************************
+*                                                                             *
+* BSpline                                                                     *
+*                                                                             *
+******************************************************************************/
+tinyspline::BSpline::BSpline()
+{
+	ts_bspline_default(&spline);
+}
+
+tinyspline::BSpline::BSpline(const tinyspline::BSpline &other)
+{
+	tsError err = ts_bspline_copy(&other.spline, &spline);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+}
+
+tinyspline::BSpline::BSpline(size_t nCtrlp, size_t dim, size_t deg,
+	tinyspline::BSpline::type type)
+{
+	tsError err = ts_bspline_new(nCtrlp, dim, deg, type, &spline);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+}
+
+tinyspline::BSpline::~BSpline()
+{
+	ts_bspline_free(&spline);
+}
+
+tinyspline::BSpline & tinyspline::BSpline::operator=(
+	const tinyspline::BSpline &other)
+{
+	if (&other != this) {
+		tsError err = ts_bspline_copy(&other.spline, &spline);
+		if (err < 0)
+			throw std::runtime_error(ts_enum_str(err));
+	}
+	return *this;
+}
+
+tinyspline::DeBoorNet tinyspline::BSpline::operator()(tinyspline::real u) const
+{
+	return eval(u);
+}
+
+size_t tinyspline::BSpline::degree() const
+{
+	return ts_bspline_degree(&spline);
+}
+
+size_t tinyspline::BSpline::order() const
+{
+	return ts_bspline_order(&spline);
+}
+
+size_t tinyspline::BSpline::dimension() const
+{
+	return ts_bspline_dimension(&spline);
+}
+
+std::vector<tinyspline::real> tinyspline::BSpline::controlPoints() const
+{
+	tsReal *ctrlp;
+	tsError err = ts_bspline_control_points(&spline, &ctrlp);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	size_t num_ctrlp = ts_bspline_num_control_points(&spline);
+	tinyspline::real *begin  = ctrlp;
+	tinyspline::real *end = begin + num_ctrlp * dimension();
+	std::vector<tinyspline::real> vec =
+		std::vector<tinyspline::real>(begin, end);
+	delete ctrlp;
+	return vec;
+}
+
+std::vector<tinyspline::real> tinyspline::BSpline::knots() const
+{
+	tsReal *knots;
+	tsError err = ts_bspline_knots(&spline, &knots);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	size_t num_knots = ts_bspline_num_knots(&spline);
+	tinyspline::real *begin = knots;
+	tinyspline::real *end = begin + num_knots;
+	std::vector<tinyspline::real> vec =
+		std::vector<tinyspline::real>(begin, end);
+	delete knots;
+	return vec;
+}
+
+tsBSpline * tinyspline::BSpline::data()
+{
+	return &spline;
+}
+
+tinyspline::DeBoorNet tinyspline::BSpline::eval(tinyspline::real u) const
+{
+	tinyspline::DeBoorNet deBoorNet;
+	tsError err = ts_bspline_eval(&spline, u, deBoorNet.data());
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	return deBoorNet;
+}
+
+void tinyspline::BSpline::setControlPoints(
+	const std::vector<tinyspline::real> &ctrlp)
+{
+	size_t expected = ts_bspline_len_control_points(&spline);
+	size_t actual = ctrlp.size();
+	if (expected != actual) {
+		char expected_str[32];
+		char actual_str[32];
+		sprintf(expected_str, "%zu", expected);
+		sprintf(actual_str, "%zu", actual);
+		throw std::runtime_error(
+			"Expected size: " + std::string(expected_str) +
+			", Actual size: " + std::string(actual_str));
+	}
+	tsError err = ts_bspline_set_control_points(&spline, ctrlp.data());
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+}
+
+void tinyspline::BSpline::setKnots(const std::vector<tinyspline::real> &knots)
+{
+	size_t expected = ts_bspline_num_knots(&spline);
+	size_t actual = knots.size();
+	if (expected != actual) {
+		char expected_str[32];
+		char actual_str[32];
+		sprintf(expected_str, "%zu", expected);
+		sprintf(actual_str, "%zu", actual);
+		throw std::runtime_error(
+			"Expected size: " + std::string(expected_str) +
+			", Actual size: " + std::string(actual_str));
+	}
+	tsError err = ts_bspline_set_knots(&spline, knots.data());
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+}
+
+tinyspline::BSpline tinyspline::BSpline::fillKnots(tsBSplineType type,
+	tinyspline::real min, tinyspline::real max) const
+{
+	tinyspline::BSpline bs;
+	tsError err = ts_bspline_fill_knots(
+		&spline, type, min, max, &bs.spline);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	return bs;
+}
+
+tinyspline::BSpline tinyspline::BSpline::insertKnot(tinyspline::real u,
+	size_t n) const
+{
+	tinyspline::BSpline bs;
+	size_t k;
+	tsError err = ts_bspline_insert_knot(&spline, u, n, &bs.spline, &k);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	return bs;
+}
+
+tinyspline::BSpline tinyspline::BSpline::resize(int n, int back) const
+{
+	tinyspline::BSpline bs;
+	tsError err = ts_bspline_resize(&spline, n, back, &bs.spline);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	return bs;
+}
+
+tinyspline::BSpline tinyspline::BSpline::split(tinyspline::real u) const
+{
+	tinyspline::BSpline bs;
+	size_t k;
+	tsError err = ts_bspline_split(&spline, u, &bs.spline, &k);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	return bs;
+}
+
+tinyspline::BSpline tinyspline::BSpline::buckle(tinyspline::real b) const
+{
+	tinyspline::BSpline bs;
+	tsError err = ts_bspline_buckle(&spline, b, &bs.spline);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	return bs;
+}
+
+tinyspline::BSpline tinyspline::BSpline::toBeziers() const
+{
+	tinyspline::BSpline bs;
+	tsError err = ts_bspline_to_beziers(&spline, &bs.spline);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	return bs;
+}
+
+tinyspline::BSpline tinyspline::BSpline::derive() const
+{
+	tinyspline::BSpline bs;
+	tsError err = ts_bspline_derive(&spline, &bs.spline);
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	return bs;
+}
+
+
+
+/******************************************************************************
+*                                                                             *
+* Utils                                                                       *
+*                                                                             *
+******************************************************************************/
+tinyspline::BSpline tinyspline::Utils::interpolateCubic(
+	const std::vector<tinyspline::real> *points, size_t dim)
+{
+	if (dim == 0)
+		throw std::runtime_error(ts_enum_str(TS_DIM_ZERO));
+	if (points->size() % dim != 0)
+		throw std::runtime_error("#points % dim == 0 failed");
+	tinyspline::BSpline bspline;
+	tsError err = ts_bspline_interpolate_cubic(
+		points->data(), points->size()/dim, dim, bspline.data());
+	if (err < 0)
+		throw std::runtime_error(ts_enum_str(err));
+	return bspline;
+}
+
+bool tinyspline::Utils::fequals(tinyspline::real x, tinyspline::real y)
+{
+	return ts_fequals(x, y) == 1;
+}
+
+std::string tinyspline::Utils::enum_str(tsError err)
+{
+	return std::string(ts_enum_str(err));
+}
+
+tsError tinyspline::Utils::str_enum(std::string str)
+{
+	return ts_str_enum(str.c_str());
+}

+ 90 - 0
src/decition/decition_brain/decision/tinyspline/tinysplinecpp.h

@@ -0,0 +1,90 @@
+#pragma once
+
+#include <tinyspline_ros/tinyspline.h>
+#include <vector>
+#include <string>
+
+namespace tinyspline {
+
+typedef tsReal real;
+
+class DeBoorNet {
+public:
+	/* Constructors & Destructors */
+	DeBoorNet();
+	DeBoorNet(const DeBoorNet &other);
+	~DeBoorNet();
+
+	/* Operators */
+	DeBoorNet& operator=(const DeBoorNet &other);
+
+	/* Getter */
+	real knot() const;
+	size_t index() const;
+	size_t multiplicity() const;
+	size_t numInsertions() const;
+	size_t dimension() const;
+	std::vector<real> points() const;
+	std::vector<real> result() const;
+	tsDeBoorNet * data();
+
+private:
+	tsDeBoorNet net;
+};
+
+class BSpline {
+public:
+	typedef tsBSplineType type;
+
+	/* Constructors & Destructors */
+	BSpline();
+	BSpline(const BSpline &other);
+	explicit BSpline(size_t nCtrlp, size_t dim = 2, size_t deg = 3,
+		tinyspline::BSpline::type type = TS_CLAMPED);
+	~BSpline();
+
+	/* Operators */
+	BSpline & operator=(const BSpline &other);
+	DeBoorNet operator()(real u) const;
+
+	/* Getter */
+	size_t degree() const;
+	size_t order() const;
+	size_t dimension() const;
+	std::vector<real> controlPoints() const;
+	std::vector<real> knots() const;
+	tsBSpline * data();
+
+	/* Query */
+	DeBoorNet eval(real u) const;
+
+	/* Modifications */
+	void setControlPoints(const std::vector<real> &ctrlp);
+	void setKnots(const std::vector<real> &knots);
+
+	/* Transformations */
+	BSpline fillKnots(tsBSplineType type, real min, real max) const;
+	BSpline insertKnot(real u, size_t n) const;
+	BSpline resize(int n, int back) const;
+	BSpline split(real u) const;
+	BSpline buckle(real b) const;
+	BSpline toBeziers() const;
+	BSpline derive() const;
+
+private:
+	tsBSpline spline;
+};
+
+class Utils {
+public:
+	static BSpline interpolateCubic(
+		const std::vector<real> *points, size_t dim);
+	static bool fequals(real x, real y);
+	static std::string enum_str(tsError err);
+	static tsError str_enum(std::string str);
+
+private:
+	Utils() {}
+};
+
+}

+ 0 - 0
src/decition/decition_brain/decition/transfer.cpp → src/decition/decition_brain/decision/transfer.cpp


+ 0 - 0
src/decition/decition_brain/decition/adc_tools/transfer.h → src/decition/decition_brain/decision/transfer.h


+ 1 - 1
src/decition/decition_brain/decition_brain.pro

@@ -32,7 +32,7 @@ SOURCES += $$PWD/../common/main.cpp \
     ../../include/msgtype/ultrasonic.pb.cc
 
 include($$PWD/../common/common/common.pri)
-include($$PWD/decition/decition.pri)
+include($$PWD/decision/decision.pri)
 include($$PWD/../common/perception/perception.pri)
 #include(platform/platform.pri)