| | |
| | | |
| | | 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) |
| | | int *body, int bodyNum, double (*point)[2], int pointNum, double antPitch, double antHeight, double groundHeight) |
| | | { |
| | | DEBUG("å å
¥è½¦è¾ä¿¡æ¯ pointNum %d", pointNum); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | CarModel->antPitch = -0.6;//antPitch;///////////////////////////////////// |
| | | CarModel->antPitch = antPitch; |
| | | CarModel->antHeight = antHeight; |
| | | CarModel->groundHeight = groundHeight; |
| | | |
| | | CarModel->pointNum = pointNum; |
| | | CarModel->carDesc = (struct car_desc_ *)malloc(sizeof(struct car_desc_) * pointNum); |
| | |
| | | |
| | | static void ExecuteExam(const struct RtkTime* rtkTime) |
| | | { |
| | | // DEBUG("ExecuteExam 111111111"); |
| | | { |
| | | static const char *NAME[] = {"OBD_SPEED", |
| | | "ENGINE_RPM", |
| | |
| | | "CAR_STATUS_END"}; |
| | | |
| | | static const char *VALUE[] = { |
| | | "0", |
| | | "INACTIVE", |
| | | "HAZARD_LIGHTS", |
| | | "LEFT_TURN_LIGHT", |
| | | "RIGHT_TURN_LIGHT", |
| | |
| | | } |
| | | |
| | | } |
| | | //DEBUG("-------------- 1111111111"); |
| | | |
| | | if (ReadCarStatus(ENGINE_RPM) < ENGINE_MIN_ROTATE) { |
| | | if (engineRuning) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | // DEBUG("ExecuteExam 1111111111 ----------------------"); |
| | | } |
| | | |
| | | static void ExecuteExam(double speed, int move, double azimuth, const struct RtkTime* rtkTime) |
| | | { |
| | | // DEBUG("ExecuteExam 2222222"); |
| | | if (move != 0) { |
| | | if (ReadCarStatus(SEATBELT) == EJECT_SEATBELT && !reportSeatbeltEject) { |
| | | DEBUG("ä¸ç³»å®å
¨å¸¦"); |
| | |
| | | CurrExamMapIndex = -1; |
| | | } |
| | | } |
| | | // DEBUG("ExecuteExam 2222222 -----------------------"); |
| | | } |
| | | |
| | | static void EngineStartHold(union sigval sig) { |
| | |
| | | Line carAxial; |
| | | |
| | | MakeLine(&startLine, &mapList[i].map.point[0], &mapList[i].map2.point[0]); |
| | | MakeLine(&carAxial, &car->carXY[car->axial[AXIAL_FRONT]], &car->carXY[car->axial[AXIAL_REAR]]); |
| | | MakeLine(&carAxial, &car->carXY[car->left_front_tire[TIRE_OUTSIDE]], &car->carXY[car->left_rear_tire[TIRE_OUTSIDE]]); |
| | | |
| | | if (IntersectionOf(startLine, carAxial) == GM_Intersection) { |
| | | if (DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], startLine) > 0.1) |
| | | if (DistanceOf(car->carXY[car->left_front_tire[TIRE_OUTSIDE]], startLine) > 0.1) |
| | | return i; |
| | | } |
| | | } |
| | |
| | | */ |
| | | static void UpdateCarBodyCoord(struct RtkTime *rtkTime, double azimuth, double pitch, double roll, PointF main_ant, car_model *carModel) |
| | | { |
| | | carModel->basePoint = main_ant; |
| | | |
| | | |
| | | // 俯仰è§ä¿®æ£ |
| | | // DEBUG("ä¿¯ä»°è§ %f", pitch); |
| | | carModel->yaw = azimuth; |
| | | carModel->pitch = pitch; |
| | | carModel->tm = *rtkTime; |
| | | |
| | | pitch = pitch - carModel->antPitch; |
| | | // DEBUG("yaw = %f ä¿®æ£ä¿¯ä»°è§ %f", azimuth, pitch); |
| | | |
| | | // DEBUG("xzä¿¯ä»°è§ %f", pitch); |
| | | // 主天线æå½±ä¿®æ£ |
| | | carModel->basePoint.X = main_ant.X + fabs(carModel->antHeight - carModel->groundHeight) * sin(toRadians(pitch)) * sin(toRadians(azimuth)); |
| | | carModel->basePoint.Y = main_ant.Y + fabs(carModel->antHeight - carModel->groundHeight) * sin(toRadians(pitch)) * cos(toRadians(azimuth)); |
| | | |
| | | for (int i = 0; i < carModel->pointNum; ++i) { |
| | | double qrx = carModel->carDesc[i].distance * sin(toRadians(carModel->carDesc[i].angle)); |
| | | double qry = |
| | | carModel->carDesc[i].distance * cos(toRadians(carModel->carDesc[i].angle)) / |
| | | carModel->carDesc[i].distance * cos(toRadians(carModel->carDesc[i].angle)) * |
| | | cos(toRadians(pitch)); |
| | | |
| | | double projectDistance = sqrt(pow(qrx, 2) + pow(qry, 2)); |
| | |
| | | carModel->carXY[i].X = |
| | | projectDistance * sin(toRadians(azimuth)) * cos(toRadians(projectAngle)) - |
| | | projectDistance * cos(toRadians(azimuth)) * sin(toRadians(projectAngle)) + |
| | | main_ant.X; |
| | | carModel->basePoint.X; |
| | | carModel->carXY[i].Y = |
| | | projectDistance * sin(toRadians(azimuth)) * sin(toRadians(projectAngle)) + |
| | | projectDistance * cos(toRadians(azimuth)) * cos(toRadians(projectAngle)) + |
| | | main_ant.Y; |
| | | carModel->basePoint.Y; |
| | | |
| | | // DEBUG("<%d>. æ è· %f æ è§ %f X = %f Y = %f", i, carModel->carDesc[i].distance, carModel->carDesc[i].angle, |
| | | // carModel->carXY[i].X, carModel->carXY[i].Y); |
| | | } |
| | | } |
| | | |
| | |
| | | int *body; |
| | | int pointNum; |
| | | double antPitch; // åå天线å å®è£
ä½ç½®ä¹åºæpitchè§ |
| | | double antHeight; // 车顶天线é«ç¨ |
| | | double groundHeight; // 大å°é«ç¨ |
| | | double yaw; |
| | | double pitch; |
| | | struct car_desc_ *carDesc; // ç»ç°åºæµéç¹è®¡ç®åçå¼ |
| | |
| | | |
| | | 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); |
| | | int *body, int bodyNum, double (*point)[2], int pointNum, double antPitch, double antHeight, double groundHeight); |
| | | |
| | | void StartDriverExam(int start, int type); |
| | | void StartMapExam(int map_id, int exam); |
| | |
| | | #include <string> |
| | | #include <iostream> |
| | | #include <vector> |
| | | #include <list> |
| | | #include <semaphore.h> |
| | | |
| | | #define DEBUG(fmt, args...) LOGD("<comm_if> <%s>: " fmt, __func__, ##args) |
| | | |
| | |
| | | |
| | | static int OnOff = 0;//0xFFFF; |
| | | |
| | | struct msg_2_main_t { |
| | | int cmd; |
| | | string value; |
| | | }; |
| | | |
| | | static list<struct msg_2_main_t> MessageBuffer; |
| | | |
| | | static sem_t sem_msg_income; |
| | | static pthread_mutex_t msg_mutex = PTHREAD_MUTEX_INITIALIZER; |
| | | |
| | | static void SendMsgToMainProcIndep(int cmd, const char *value); |
| | | static void *SendMsgToMainProcThread(void *p); |
| | | |
| | | static void SendMsgToMainProcIndep(int cmd, const char *value) |
| | | { |
| | | struct msg_2_main_t msg; |
| | | |
| | | msg.cmd = cmd; |
| | | |
| | | if (value != NULL) { |
| | | msg.value = value; |
| | | } else { |
| | | msg.value.clear(); |
| | | } |
| | | |
| | | pthread_mutex_lock(&msg_mutex); |
| | | MessageBuffer.push_front(msg); |
| | | pthread_mutex_unlock(&msg_mutex); |
| | | |
| | | sem_post(&sem_msg_income); |
| | | } |
| | | |
| | | static void *SendMsgToMainProcThread(void *p) { |
| | | while (true) { |
| | | sem_wait(&sem_msg_income); |
| | | |
| | | if (MessageBuffer.size() > 0) { |
| | | struct msg_2_main_t msg; |
| | | |
| | | pthread_mutex_lock(&msg_mutex); |
| | | msg = MessageBuffer.back(); |
| | | MessageBuffer.pop_back(); |
| | | pthread_mutex_unlock(&msg_mutex); |
| | | |
| | | if (msg.value.length() > 0) |
| | | SendMsgToMainProc(msg.cmd, msg.value.c_str()); |
| | | else |
| | | SendMsgToMainProc(msg.cmd, NULL); |
| | | } |
| | | } |
| | | } |
| | | |
| | | void MA_Init(void) |
| | | { |
| | | sem_init(&sem_msg_income, 0, 0); |
| | | MessageBuffer.clear(); |
| | | |
| | | pthread_mutex_init(&msg_mutex, NULL); |
| | | |
| | | pthread_t pid; |
| | | pthread_attr_t attr; |
| | | pthread_attr_init(&attr); |
| | | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
| | | pthread_create(&pid, &attr, SendMsgToMainProcThread, NULL); |
| | | } |
| | | |
| | | void MA_NdkStart(void) |
| | | { |
| | | SendMsgToMainProc(ID_SM_NDK_START, NULL); |
| | | SendMsgToMainProcIndep(ID_SM_NDK_START, NULL); |
| | | } |
| | | |
| | | void MA_ReqRtkPlatformConfig(void) |
| | | { |
| | | SendMsgToMainProc(ID_SM_REQ_RTK_PLAT_CFG, NULL); |
| | | SendMsgToMainProcIndep(ID_SM_REQ_RTK_PLAT_CFG, NULL); |
| | | } |
| | | |
| | | void MA_RtkPlatformConnect(int conn, const char *ip, int port) |
| | |
| | | |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_RTK_PLAT_CONN, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_RTK_PLAT_CONN, sb.GetString()); |
| | | } |
| | | |
| | | void MA_RtkPlatformRegister(int reg, const uint8_t *pwd, int length) |
| | |
| | | |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_RTK_PLAT_REG, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_RTK_PLAT_REG, sb.GetString()); |
| | | } |
| | | |
| | | void MA_RtkPlatformLogin(int login) |
| | |
| | | |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_RTK_PLAT_LOGIN, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_RTK_PLAT_LOGIN, sb.GetString()); |
| | | } |
| | | |
| | | void MA_ReadMap(void) |
| | | { |
| | | SendMsgToMainProc(ID_SM_READ_MAP, NULL); |
| | | SendMsgToMainProcIndep(ID_SM_READ_MAP, NULL); |
| | | } |
| | | |
| | | void MA_ReadCar(void) |
| | | { |
| | | SendMsgToMainProc(ID_SM_READ_CAR, NULL); |
| | | SendMsgToMainProcIndep(ID_SM_READ_CAR, NULL); |
| | | } |
| | | |
| | | void MA_ReadSensor(void) |
| | |
| | | |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_EXAM_STATUS, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_EXAM_STATUS, sb.GetString()); |
| | | } |
| | | |
| | | void MA_SendCardBrief(const struct cardBrief *brief) |
| | |
| | | writer.String(brief->card); |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_PUT_CARD, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_PUT_CARD, sb.GetString()); |
| | | } |
| | | |
| | | void MA_SendMcuBrief(const struct mcuBrief *brief) |
| | |
| | | |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_MCU_BRIEF, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_MCU_BRIEF, sb.GetString()); |
| | | } |
| | | |
| | | void MA_SendGpsBrief(const struct gpsBrief *brief) |
| | |
| | | |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_GPS_BRIEF, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_GPS_BRIEF, sb.GetString()); |
| | | } |
| | | |
| | | void MA_SendRtkBrief(const struct rtkBrief *brief) |
| | |
| | | |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_RTK_BRIEF, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_RTK_BRIEF, sb.GetString()); |
| | | } |
| | | |
| | | void MA_SendExamWrong(vector<ExamFault> &ExamFaultList) |
| | |
| | | |
| | | writer.EndArray(); |
| | | |
| | | SendMsgToMainProc(ID_SM_EXAM_BRIEF, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_EXAM_BRIEF, sb.GetString()); |
| | | } |
| | | |
| | | void MA_SendCarPosition(const struct carBrief *brief) |
| | |
| | | writer.EndArray(); |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_CAR, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_CAR, sb.GetString()); |
| | | } |
| | | |
| | | void MA_SendRtcmInd(int length) |
| | |
| | | writer.Int(length); |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_RTCM_IND, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_RTCM_IND, sb.GetString()); |
| | | } |
| | | |
| | | void MA_SendDebugInfo(const char *str, ...) |
| | |
| | | writer.String(buffer); |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_DEBUG_INFO, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_DEBUG_INFO, sb.GetString()); |
| | | } |
| | | |
| | | void MA_MainProcMsgEntry(int cmd, const char *value) |
| | |
| | | int *body = NULL; |
| | | int pointNum = 0; |
| | | double antPitch = 0; |
| | | double antHeight = 0; |
| | | double groundHeight = 0; |
| | | |
| | | double (*point)[2] = NULL; |
| | | |
| | |
| | | antPitch = s.GetDouble(); |
| | | } |
| | | |
| | | if (doc.HasMember("ant_height")) { |
| | | const Value& s = doc["ant_height"]; |
| | | antHeight = s.GetDouble(); |
| | | } |
| | | |
| | | if (doc.HasMember("ground_height")) { |
| | | const Value& s = doc["ground_height"]; |
| | | groundHeight = s.GetDouble(); |
| | | } |
| | | |
| | | SetCarMeasurePoint(basePoint, axial, left_front_tire, right_front_tire, |
| | | left_rear_tire, right_rear_tire, body, bodyNum, point, pointNum, antPitch); |
| | | left_rear_tire, right_rear_tire, body, bodyNum, point, pointNum, antPitch, antHeight, groundHeight); |
| | | |
| | | if (body != NULL) delete []body; |
| | | if (point != NULL) delete []point; |
| | |
| | | writer.Int(enter); |
| | | writer.EndObject(); |
| | | |
| | | SendMsgToMainProc(ID_SM_ENTER_MAP, sb.GetString()); |
| | | SendMsgToMainProcIndep(ID_SM_ENTER_MAP, sb.GetString()); |
| | | } |
| | | |
| | | void MA_ExamLight(void) |
| | | { |
| | | SendMsgToMainProc(ID_SM_LIGHT_EXAM_REQ, NULL); |
| | | SendMsgToMainProcIndep(ID_SM_LIGHT_EXAM_REQ, NULL); |
| | | } |
| | |
| | | void MA_MainProcMsgEntry(int cmd, const char *value); |
| | | void MA_MainProcBinMsgEntry(int cmd, const uint8_t *value, int length); |
| | | |
| | | void MA_Init(void); |
| | | void MA_NdkStart(void); |
| | | void MA_ReqRtkPlatformConfig(void); |
| | | void MA_RtkPlatformConnect(int conn, const char *ip, int port); |
| | |
| | | const int RTK_PLATFORM_PORT = 12125; |
| | | const uint8_t phone[] = {0x20,0x19,0x10,0x15,0x00,0x00,0x00,0x01}; |
| | | |
| | | const char *VIRTUAL_RTK_IP = "192.168.3.52"; |
| | | const char *VIRTUAL_RTK_IP = "192.168.16.100"; |
| | | const int VIRTUAL_RTK_PORT = 9001; |
| | | |
| | | static pthread_mutex_t tts_mutex = PTHREAD_MUTEX_INITIALIZER; |
| | |
| | | ConfigMCU(); |
| | | DriverTestInit(); |
| | | ConfigRTKModule(); |
| | | |
| | | MA_Init(); |
| | | InitPlatform(phone, RTK_PLATFORM_IP, RTK_PLATFORM_PORT); |
| | | AppTimer_add(SendBootIndicate, 500); |
| | | |
| | |
| | | }*/ |
| | | |
| | | if (RxBufLen > 0) { |
| | | #if 1 |
| | | #if 0 |
| | | const uint8_t *ptr = parseGPS(RxBuf, RxBuf + RxBufLen); |
| | | if(ptr != RxBuf) { |
| | | memcpy(RxBuf, ptr, RxBufLen - (ptr - RxBuf)); |
| | |
| | | void DummyLightTTSDone(int id) |
| | | { |
| | | // çè¯é³ææ¥å®æ¯åè®¡æ¶ |
| | | if (id == examTtsSeq) { |
| | | if (id == examTtsSeq && testing) { |
| | | DEBUG("DummyLightTTSDone %d", id); |
| | | for (int i = 0; i < contentNum; ++i) { |
| | | if (content[i].itemStatus == TTS_DOING) { |
| | |
| | | |
| | | void TerminateDummyLightExam(void) |
| | | { |
| | | testing = false; |
| | | AppTimer_delete(DummyLightCheckActive); |
| | | AppTimer_delete(ExamDummyLight); |
| | | } |