yy1717
2020-08-25 0701276b4fec856d5427e4776eec3cc7c56ec065
坐标
9个文件已修改
126 ■■■■ 已修改文件
lib/src/main/cpp/native-lib.cpp 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/native-lib.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/rtk_module/virtual_rtk.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/rtk_platform/platform.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_common/Geometry.cpp 41 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_common/Geometry.h 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/drive_straight.cpp 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/road_exam.cpp 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/through_something.cpp 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/native-lib.cpp
@@ -251,6 +251,35 @@
    return id;
}
void PlayRing(void)
{
    JNIEnv *env;
    bool ready_in_java_env = false;
    if (sg_jvm->GetEnv((void **)&env, JNI_VERSION_1_6) != JNI_OK) {
        // Attach主线程
        if (sg_jvm->AttachCurrentThread(&env, NULL) != JNI_OK) {
            LOGE("%s: AttachCurrentThread() failed", __FUNCTION__);
            return;
        }
    } else {
        ready_in_java_env = true;
    }
    jclass cls = env->GetObjectClass(sg_obj);
    jmethodID fun = env->GetMethodID(cls, "PlayBreakRing", "()V");
    env->CallVoidMethod(sg_obj, fun);
    env->DeleteLocalRef(cls);
    if (!ready_in_java_env) {
        //Detach主线程
        if (sg_jvm->DetachCurrentThread() != JNI_OK) {
            LOGE("%s: DetachCurrentThread() failed", __FUNCTION__);
        }
    }
}
extern "C"
JNIEXPORT void JNICALL
Java_com_anyun_exam_lib_RemoteService_startNative(JNIEnv *env, jobject thiz) {
lib/src/main/cpp/native-lib.h
@@ -24,5 +24,6 @@
void DrawScreen(const Polygon *map, const Polygon *car);
void SendMsgToMainProc(int cmd, const char *value);
int PlayTTS(const char *string, void (*callback)(int));
void PlayRing(void);
#endif //RTKBASESTATION_NATIVE_LIB_H
lib/src/main/cpp/rtk_module/virtual_rtk.cpp
@@ -57,6 +57,7 @@
    if (fd > 0) {
        DEBUG("虚拟平台连接成功");
        PlayTTS("模拟器连接", NULL);
    } else {
        DEBUG("虚拟平台连接失败");
    }
@@ -97,5 +98,8 @@
    }
    free(vs);
    PlayTTS("模拟器断开", NULL);
    pthread_exit(NULL);
}
lib/src/main/cpp/rtk_platform/platform.cpp
@@ -310,6 +310,8 @@
        AppTimer_delete(TriggerHeartbeat);
        AppTimer_delete(RegisterPlatformTimeout);
        AppTimer_delete(LoginPlatformTimeout);
        PlayTTS("基准源断开", NULL);
    }
    if (events & PLATFORM_REGISTER_EVT) {
        DEBUG("PLATFORM_REGISTER_EVT");
@@ -333,6 +335,8 @@
            requestPlatformSendRtk = true;
            AppTimer_delete(TriggerHeartbeat);
            AppTimer_add(TriggerHeartbeat, D_SEC(30));
            PlayTTS("基准源建立", NULL);
        } else {
            platformStatus.login = 0;
        }
lib/src/main/cpp/test_common/Geometry.cpp
@@ -14,6 +14,7 @@
#include <iosfwd>
#include <iomanip>
#include <sstream>
#include <vector>
#include "../jni_log.h"
@@ -626,3 +627,43 @@
{
    return isEqual(p1.X, p2.X) && isEqual(p1.Y, p2.Y);
}
double AvgYaw(std::vector<double> &angles)
{
    double x = 0, y = 0;
    double deg = 0;
    for (int i = 0; i < angles.size(); ++i) {
        x += sin(toRadians(angles[i]));
        y += cos(toRadians(angles[i]));
    }
    if (fabs(y) <= EPSILON) {
        if (x > EPSILON) {
            deg = 90;
        } else {
            deg = 270;
        }
    }
    else if (fabs(x) <= EPSILON) {
        if (y > EPSILON) {
            deg = 0;
        } else {
            deg = 180;
        }
    } else {
        deg = toDegree(atan(fabs(x / y)));
        if (x < -EPSILON &&    y > EPSILON) {
            deg = 360 - deg;
        }
        else if (x < -EPSILON && y < -EPSILON) {
            deg = 180 + deg;
        }
        else if (x > EPSILON && y < -EPSILON) {
            deg = 180 - deg;
        }
    }
    return deg;
}
lib/src/main/cpp/test_common/Geometry.h
@@ -7,6 +7,7 @@
#include <stdint.h>
#include <initializer_list>
#include <vector>
enum Relation
{
@@ -64,5 +65,6 @@
PointF Calc3Point(PointF p1, PointF p2, double L, char dir);
PointF PointExtend(PointF ori, double length, double yaw);
bool IsSamePoint(PointF p1, PointF p2);
double AvgYaw(std::vector<double> &angles);
#endif //GUI_GEOMETRY_H
lib/src/main/cpp/test_items2/drive_straight.cpp
@@ -39,17 +39,18 @@
    if (setup == 1) {
        // 偏航角平均值
        static vector<double> yaws;
        if (yaw_stat == 0) {
            yaw = car->yaw;
        } else {
            yaw += car->yaw;
            yaws.clear();
        }
        yaws.push_back(car->yaw);
        yaw_stat++;
        DEBUG("角度矫正 car %f yaw %f", car->yaw, yaw);
        if (yaw_stat == 5) {
            yaw = fmod(yaw, 360) / 5;
            yaw = AvgYaw(yaws);
            vector<double>().swap(yaws);
            DEBUG("创建基线 yaw %f", yaw);
            PointF extPoint = PointExtend(car->basePoint, 100, yaw);
            MakeLine(&baseLine, &car->basePoint, &extPoint);
lib/src/main/cpp/test_items2/road_exam.cpp
@@ -411,7 +411,7 @@
        index = 0;
    }
    while (n++ < RoadMap.roads.size()) {
    while (n < RoadMap.roads.size()) {
        bool changeSegment = false;
        vector<PointF> roadOutLine;
        Polygon area;
@@ -453,6 +453,7 @@
        free(area.point);
        index = (index + 1) % RoadMap.roads.size();
        n++;
    }
    if (n >= RoadMap.roads.size()) {
@@ -924,12 +925,13 @@
        if (newLane.road == Lane.road && newLane.sep == Lane.sep) {
            gain = newLane.no - Lane.no;
        } else {
            DEBUG("车道分段切换");
            ChangeLane.gain = 0;
        }
        // 检查转向灯
        if (gain != 0) {
            DEBUG("变道 gain %d", gain);
            DEBUG("变道 new lane %d, gain %d", newLane.no, gain);
            car_sensor_value_t lamp = ReadCarSensorValue(TURN_SIGNAL_LAMP);
            if (lamp.name == TURN_SIGNAL_LAMP) {
                if (gain < 0) {
@@ -1209,6 +1211,19 @@
    return guide;
}
static void RingBreak(void)
{
    static int oldValue = BREAK_INACTIVE;
    car_sensor_value_t brk = ReadCarSensorValue(BREAK);
    if (brk.name == BREAK) {
        if (brk.value == BREAK_ACTIVE && oldValue != BREAK_ACTIVE) {
            PlayRing();
        }
        oldValue = brk.value;
    }
}
void TestRoadGeneral(road_exam_map &RoadMap, const car_model *car, LIST_CAR_MODEL &CarModelList, double speed, int moveDirect, const struct RtkTime *rtkTime)
{
    double BigStraightRoadFree = 0, RoadCrossingFree = 0, TargetFree = 0;
@@ -1216,6 +1231,9 @@
    UpdateCarSensor(rtkTime);
    UpdataOdo(speed, moveDirect, rtkTime);
    // 刹车提示音
    RingBreak();
    // 超速检测
    if (speed > MAX_SPEED) {
@@ -1536,7 +1554,7 @@
            if (RoadExamStatus == ROAD_EXAM_ITEM_CAR_START) {
                freeRunExceptDistance = 60.0;
            } else {
                freeRunExceptDistance = 200.0;
                freeRunExceptDistance = 250.0;
            }
            RoadExamStatus = ROAD_EXAM_FREE_RUN;
lib/src/main/cpp/test_items2/through_something.cpp
@@ -226,18 +226,18 @@
            }
            PointF point2 = CalcProjectionWithRoadEdge(RoadMap.roads[roadIndex].leftEdge,
                                                       RoadMap.specialAreas[x].area[1]);
            MakeLine(&line, &RoadMap.specialAreas[x].area[1], &point2);
                                                       RoadMap.specialAreas[x].area[0]);
            MakeLine(&line, &RoadMap.specialAreas[x].area[0], &point2);
            if (CrashTheLine(line, car, CarModelList)) {
                if (RoadMap.specialAreas[x].type == ZEBRA_CROSSING &&
                    !(it->second & REDUCE_SPEED)) {
                    DEBUG("不按规定减速");
                    DEBUG("人行道 不按规定减速");
                    AddExamFault(48, rtkTime);
                }
                if (RoadMap.specialAreas[x].type == BUS_STATION_AREA &&
                    !(it->second & REDUCE_SPEED)) {
                    DEBUG("不按规定减速");
                    DEBUG("公交站 不按规定减速");
                    AddExamFault(50, rtkTime);
                }
                RemoveTargetReduceRec(TargetReduceRec2, it->first);