//
|
// Created by YY on 2019/10/21.
|
//
|
|
#ifndef RTKDRIVERTEST_DRIVER_TEST_H
|
#define RTKDRIVERTEST_DRIVER_TEST_H
|
|
#include "test_common/Geometry.h"
|
#include "rtk_module/rtk.h"
|
#include "test_items2/dummy_light.h"
|
|
#include <vector>
|
#include <string>
|
#include <list>
|
|
#define EXAM_AREA_NONE 0
|
#define EXAM_AREA_START 1
|
#define EXAM_AREA_RUN 2
|
#define EXAM_AREA_END 3
|
|
#define TIRE_OUTSIDE 0
|
#define TIRE_INSIDE 1
|
#define AXIAL_FRONT 0
|
#define AXIAL_REAR 1
|
|
#define MAP_TYPE_PARK_BUTTOM 1
|
#define MAP_TYPE_STOP_START 2
|
#define MAP_TYPE_PART_EDGE 3
|
#define MAP_TYPE_CURVE 4
|
#define MAP_TYPE_TURN_90 5
|
|
using namespace std;
|
|
struct car_desc_ {
|
double distance; // 距离主天线的距离
|
double angle; // 从中轴线逆时针形成的角度
|
};
|
|
struct RtkTime {
|
int YY; // 2位数
|
int MM;
|
int DD;
|
int hh;
|
int mm;
|
int ss;
|
int mss;
|
};
|
|
typedef struct {
|
struct RtkTime tm;
|
PointF basePoint; // 现场测量的主天线坐标
|
int axial[2];
|
int left_front_tire[2];
|
int right_front_tire[2];
|
int left_rear_tire[2];
|
int right_rear_tire[2];
|
int bodyNum;
|
int *body;
|
int pointNum;
|
double antPitch; // 前后天线因安装位置之固有pitch角
|
double antHeight; // 车顶天线高程
|
double groundHeight; // 大地高程
|
double yaw;
|
double pitch;
|
struct car_desc_ *carDesc; // 经现场测量点计算后的值
|
PointF *carXY; // 计算后的车身各点坐标
|
} car_model;
|
|
// 总数
|
// 中轴线前点,id 0,中轴线后点id
|
// 左包围, 右包围
|
// 左前轮,外内
|
typedef struct {
|
int body_num;
|
int body[64];
|
int front_left_tire[2];
|
int front_right_tire[2];
|
int rear_left_tire[2];
|
int rear_right_tire[2];
|
} carModelDesc_t;
|
|
typedef struct {
|
uint32_t uptime;
|
int point_num;
|
PointF *points;
|
carModelDesc_t *desc;
|
} car_model_cache_t;
|
|
struct ExamFault {
|
int sn;
|
char utc[32];
|
int wrong_id;
|
};
|
|
#define LINE_DOTTED 0
|
#define LINE_SOLID 1
|
#define LINE_HALF_SOLID_LEFT 2
|
#define LINE_HALF_SOLID_RIGHT 3
|
#define LINE_BOUNDARY 4
|
|
//车道方向(按位组合),如果为0,则表无车道方向说明;
|
#define LANE_FORWARD 0x01
|
#define LANE_LEFT 0x02
|
#define LANE_RIGHT 0x04
|
#define LANE_BACKWARD 0x08
|
|
#define ZEBRA_CROSSING 0
|
#define SCHOOL_AREA 1
|
#define BUS_STATION_AREA 2
|
#define GRID_AREA 3
|
|
#define ROAD_ACTIVE_FORWARD LANE_FORWARD
|
#define ROAD_ACTIVE_TURN_LEFT LANE_LEFT
|
#define ROAD_ACTIVE_TURN_RIGHT LANE_RIGHT
|
#define ROAD_ACTIVE_TURN_BACKWARD LANE_BACKWARD
|
|
typedef struct {
|
int character; // 属性(实线、虚线,有些可以掉头的路段)
|
std::vector<PointF> points; //
|
} edge_t;
|
|
typedef struct {
|
int character; // 属性《实线、虚线、半实半虚线》
|
std::vector<PointF> points;
|
} segment_t;
|
|
typedef struct {
|
PointF start;
|
PointF end;
|
std::vector<int> direct;
|
} lane_direct_t;
|
|
// 一组平行的分道线
|
typedef struct {
|
std::vector<lane_direct_t> lane_direct; // 一组导向线的配置
|
std::vector<std::vector<segment_t>> lines; // 每段域下的平行的一组线
|
} separate_t;
|
|
typedef struct {
|
bool stopFlag;
|
Line line;
|
bool centrePointValid;
|
PointF centrePoint;
|
} stop_line_t;
|
|
typedef struct {
|
int id;
|
// Line stopLine;
|
// int active; // 到达路口尾部的行进方向
|
bool activeBreak; // 路口刹车减速
|
bool activeStop; // 路口停车瞭望
|
bool errorLane; // 错误车道
|
int targetRoad;
|
// int stopFlag;
|
// string tts;
|
// bool arrivedTail;
|
Polygon area; // 整个道路区域
|
|
std::vector<stop_line_t> stopLine;
|
std::vector<edge_t> leftEdge;
|
std::vector<edge_t> rightEdge;
|
std::vector<separate_t> separate;
|
} road_t;
|
|
typedef struct {
|
int id;
|
int road;
|
int type;
|
bool activeBreak;
|
bool overSpeed;
|
std::vector<PointF> area; // 人行道等右侧2点,网格线4点
|
std::vector<PointF> leftPoints; // 对应到道路左侧的点
|
} special_area_t;
|
|
typedef struct {
|
int road;
|
int active;
|
std::vector<PointF> points;
|
} trigger_line_t;
|
|
typedef struct {
|
int id;
|
int type;
|
std::vector<PointF> points;
|
} forbid_line_t;
|
|
typedef struct {
|
int road_id;
|
int index;
|
int active;
|
} crossing_active_t;
|
|
typedef struct {
|
std::string name;
|
std::vector<crossing_active_t> crossingActive;
|
std::vector<trigger_line_t> triggerLines;
|
} scheme_t;
|
|
struct road_exam_map {
|
int calibrate;
|
std::vector<road_t> roads;
|
std::vector<special_area_t> specialAreas;
|
// std::vector<trigger_line_t> triggerLines;
|
std::vector<forbid_line_t> forbidLines;
|
std::vector<scheme_t> examScheme;
|
};
|
|
struct area_exam_map {
|
int id;
|
int type;
|
Polygon map;
|
Polygon map2;
|
};
|
|
typedef struct {
|
int hold_start_key_limit_time; // 点火保持,毫秒
|
|
int curve_pause_criteria; // 停车断定,豪秒
|
|
int park_bottom_pause_criteria; // 豪秒
|
int park_bottom_limit_time; // 秒
|
|
int park_edge_pause_criteria; // MSec
|
int park_edge_limit_time; // Sec
|
|
int turn_a90_pause_criteria; // MSec
|
|
double ramp_stoppoint_red_distance; // 米
|
double ramp_edge_yellow_distance;
|
double ramp_edge_red_distance;
|
double ramp_slide_yellow_distance;
|
double ramp_slide_red_distance;
|
int ramp_start_car_limit_time; // Sec
|
|
double road_slide_yellow_distance;
|
double road_slide_red_distance;
|
int road_total_distance;
|
int road_max_speed; // Km per hour
|
vector<vector<int>> gear_speed_table;
|
int gear_n_allow_time; // Sec
|
int same_gear_min_time; // Sec, x秒内,不允许N->X->N->X置同一挡位
|
int gear_speed_error_cumulative_time; // Sec
|
int road_pause_criteria; // MSec
|
int continuous_change_lane_min_time; // Sec
|
int crash_dotted_line_cumulative_time; // Sec
|
int turn_signal_min_advance; // Sec
|
int start_car_max_rpm;
|
int start_car_limit_distance;
|
double open_door_drive_allow_distance;
|
|
string prepare_tts;
|
string touch_leftfront_tts;
|
string touch_leftrear_tts;
|
string touch_rightfront_tts;
|
string touch_rightrear_tts;
|
string start_engine_tts;
|
|
string start_car_begin_tts;
|
string start_car_end_tts;
|
|
int change_lane_limit_distance;
|
string change_lane_begin_tts;
|
string change_lane_end_tts;
|
|
int shift_limit_distance;
|
int shift_hold_time; // Sec
|
string shift_begin_tts;
|
string shift_end_tts;
|
string shift_up_tts;
|
string shift_down_tts;
|
|
string straight_begin_tts;
|
string straight_end_tts;
|
int straight_limit_distance;
|
double straight_max_offset;
|
|
int overtake_limit_distance;
|
string overtake_begin_tts;
|
string overtake_end_tts;
|
|
int stop_car_limit_distance;
|
int stop_car_open_door_allow_time;
|
double stop_car_edge_red_distance;
|
double stop_car_edge_yellow_distance;
|
string stop_car_begin_tts;
|
string stop_car_end_tts;
|
double crossing_stop_valid_distance;
|
int cross_school_max_speed;
|
int crossing_break_valid_distance;
|
|
string crossing_go_straight_tts;
|
string crossing_turn_left_tts;
|
string crossing_turn_right_tts;
|
string crossing_turn_back_tts;
|
string crossing_turn_unknown_tts;
|
} exam_param_t;
|
|
extern exam_param_t examParam;
|
|
typedef vector<struct area_exam_map> LIST_AREA_MAP;
|
|
typedef list<car_model *> LIST_CAR_MODEL;
|
|
void DriverTestInit(void);
|
void ReadDriverExamPrimer(void);
|
|
void ClearAreaMap(void);
|
void AddAreaMap(int id, int type, const double (*map)[2], int pointNum, const double (*map2)[2], int pointNum2);
|
|
|
void CleanRoadMap(void);
|
void SetRoadMap(road_exam_map &map, vector<scheme_t> &scheme);
|
void SetRoadExamScheme(vector<scheme_t> &scheme);
|
|
void SetCarMeasurePoint(double *basePoint, int *axial, int *left_front_tire,
|
int *right_front_tire, int *left_rear_tire, int *right_rear_tire,
|
int *body, int bodyNum, double (*point)[2], int pointNum, double antPitch, double antHeight, double groundHeight);
|
|
void StartDriverExam(int start, int type);
|
|
void UpdateRTKInfo(const rtk_info *s);
|
void AddExamFault(int wrong, const struct RtkTime *rtkTime);
|
void RoadChange(int road, int status);
|
void CrossingChange(int road, int crossing, int status);
|
|
void SystemShutdown(int event, int timeout);
|
|
void SetDummyLightExam(int n, struct dummy_light_exam *cfg);
|
|
uint32_t TimeGetDiff(const struct RtkTime *rtkTime1, const struct RtkTime *rtkTime2);
|
|
void MasterInqRoadStatus(void);
|
|
int CorrectPauseCriteria(int src);
|
|
void SensorXChanged(uint16_t id, int value);
|
|
#endif //RTKDRIVERTEST_DRIVER_TEST_H
|