yy1717
2020-04-03 7ad5b81283c39e66ba2ca84314e283f277fc77e0
坐标
8个文件已修改
2个文件已添加
117 ■■■■ 已修改文件
lib/src/main/aidl/com/anyun/exam/lib/IListenerInterface.aidl 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/CMakeLists.txt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/Geometry.cpp 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/Geometry.h 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items/area_exam.cpp 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items/area_exam.h 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items/park_bottom.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items/park_edge.cpp 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items/stop_and_start.cpp 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/cpp/test_items2/drive_straight.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
lib/src/main/aidl/com/anyun/exam/lib/IListenerInterface.aidl
@@ -5,7 +5,7 @@
interface IListenerInterface {
    /**
    * 远程服务给SDK的回调消息,不对外提供给APP客户端
    *
     * Demonstrates some basic types that you can use as parameters
     * and return values in AIDL.
     */
lib/src/main/cpp/CMakeLists.txt
@@ -35,6 +35,7 @@
        test_items/stop_and_start.cpp
        test_items/driving_curve.cpp
        test_items/turn_a90.cpp
        test_items/area_exam.cpp
        test_items2/common_check.cpp
        test_items2/dummy_light.cpp
lib/src/main/cpp/Geometry.cpp
@@ -10,6 +10,7 @@
#include <jni.h>
#include <malloc.h>
#include <initializer_list>
#include <cctype>
#include "jni_log.h"
@@ -474,3 +475,70 @@
    return p4;
}
/****************************************************************
 *                      p3
 *                      |  'L'
 *                      |
 * p1------------------>p2
 *                      |
 *                      |   'R'
 *                      p3
 * @param p1
 * @param p2
 * @param L
 * @param dir
 * @return
 */
PointF Calc3Point(PointF p1, PointF p2, double L, char dir)
{
    PointF p3;
    dir = toupper(dir);
    if (dir != 'L' && dir != 'R')
        dir = 'L';
    if (isEqual(p1.X, p2.X)) {
        p3.Y = p2.Y;
        if (p2.Y > p1.Y) {
            p3.X = p2.X + ((dir == 'L')? -L:L);
        } else {
            p3.X = p2.X + ((dir=='L')?L:-L);
        }
        return p3;
    }
    if (isEqual(p1.Y, p2.Y)) {
        p3.X = p2.X;
        if (p2.X > p1.X) {
            p3.Y = p2.Y + ((dir == 'L')? L:-L);
        } else {
            p3.Y = p2.Y + ((dir == 'L')? -L:L);
        }
        return p3;
    }
    double k = (p2.Y - p1.Y) / (p2.X - p1.X);
    double b = p1.Y - k*p1.X;
    double A = 1 + pow(k, 2);
    double B = 2*k*(b - p2.Y) - 2*p2.X;
    double C = pow(b - p2.Y, 2) + pow(p2.X, 2) - pow(L,2);
    double x3, y3;
    if (p1.X < p2.X) {
        x3 = (- B - sqrt(pow(B, 2) - 4*A*C))/(2*A);
    } else {
        x3 = (- B + sqrt(pow(B, 2) - 4*A*C))/(2*A);
    }
    y3 = k * x3 + b;
    p3.X = x3;
    p3.Y = y3;
    p3 = rotatePoint(p3, p2, (dir == 'L') ? 270 : 90);
    return p3;
}
lib/src/main/cpp/Geometry.h
@@ -58,5 +58,6 @@
bool OutsidePolygon(const Polygon *t1, const Polygon *t2);
int IntersectionOfLine(PointF p1, PointF p2, PointF p3);
PointF GetVerticalPoint(PointF p1, PointF p2, PointF p3);
PointF Calc3Point(PointF p1, PointF p2, double L, char dir);
#endif //GUI_GEOMETRY_H
lib/src/main/cpp/test_items/area_exam.cpp
New file
@@ -0,0 +1,5 @@
//
// Created by YY on 2020/4/3.
//
#include "area_exam.h"
lib/src/main/cpp/test_items/area_exam.h
New file
@@ -0,0 +1,8 @@
//
// Created by YY on 2020/4/3.
//
#ifndef MYAPPLICATION2_AREA_EXAM_H
#define MYAPPLICATION2_AREA_EXAM_H
#endif //MYAPPLICATION2_AREA_EXAM_H
lib/src/main/cpp/test_items/park_bottom.cpp
@@ -90,7 +90,7 @@
    if (CrashRedLine(map, car, who)) {
        if (!occurCrashRedLine) {
        if (!occurCrashRedLine && reverseCar) {
            occurCrashRedLine = true;
            // 车身出线,不合格
            AddExamFault(7, rtkTime);
@@ -157,7 +157,7 @@
            if (moveDirect == storeMoveDirectBeforeStop) {
                // 同方向再启动,继续判断是否停车超时
                if (tp - stopTimepoint >= STOP_CAR_TIME) {
                if (tp - stopTimepoint >= STOP_CAR_TIME && reverseCar) {
                    // 停车超2秒,每次扣5分
                    AddExamFault(11, rtkTime);
                    DEBUG("中途停车");
lib/src/main/cpp/test_items/park_edge.cpp
@@ -54,6 +54,8 @@
    parkSuccess = false;
    parkStatus = 0;
    occurMoveBack = false;
    // 仅当发生倒车,才意味着项目开始
    if (moveStatus == -1) {
        occurMoveBack = true;
        moveBackTimePoint = TimeMakeComposite(rtkTime->hh, rtkTime->mm, rtkTime->ss, rtkTime->mss*10);
@@ -63,23 +65,23 @@
int TestParkEdge(const Polygon *map, const car_model *car, const car_model *carPrev, double speed, int moveStatus, const struct RtkTime *rtkTime)
{
    if (CrashRedLine1(map, car)) {
        if (!occurCrashRedLine1) {
        if (!occurCrashRedLine1 && occurMoveBack) {
            // 车轮压边线,每次扣10分
            AddExamFault(23, rtkTime);
            DEBUG("车轮压边线");
            occurCrashRedLine1 = true;
        }
        occurCrashRedLine1 = true;
    } else {
        occurCrashRedLine1 = false;
    }
    if (CrashRedLine2(map, car)) {
        if (!occurCrashRedLine2) {
        if (!occurCrashRedLine2 && occurMoveBack) {
            // 车身压库位线,每次扣10分
            AddExamFault(24, rtkTime);
            DEBUG("车身压库位线");
            occurCrashRedLine2 = true;
        }
        occurCrashRedLine2 = true;
    } else {
        occurCrashRedLine2 = false;
    }
@@ -121,7 +123,7 @@
            if (moveStatus == storeMoveStatusBeforeStop) {
                // 同方向再启动,继续判断是否停车超时
                if (tp - stopTimepoint >= STOP_CAR_TIME) {
                if (tp - stopTimepoint >= STOP_CAR_TIME && occurMoveBack) {
                    // 停车超2秒,每次扣5分
                    AddExamFault(26, rtkTime);
                    DEBUG("停车超时");
lib/src/main/cpp/test_items/stop_and_start.cpp
@@ -90,7 +90,7 @@
    {
        double dis2 = DistanceOfTire2Edge(map, car);
        MA_SendDistance(-1, dis2);
        MA_SendDistance(DistanceOf(map->point[8], map->point[7]) - dis2, dis2);
    }
    if (prevMoveDirect != moveDirect) {
@@ -262,7 +262,13 @@
    // 全车都需不在地图中
    bool ret = false;
    Polygon carBody;
    Polygon carBody, map2;
    PointF vPoint = Calc3Point(map->point[8], map->point[0], DistanceOf(map->point[8], map->point[7]), 'R');
    map2.num = 4;
    map2.point = (PointF *)malloc(map2.num * sizeof(PointF));
    MakePolygon(&map2, {vPoint, map->point[0], map->point[7], map->point[8]});
    carBody.num = car->bodyNum;
    carBody.point = (PointF *)malloc(carBody.num * sizeof(PointF));
@@ -270,11 +276,11 @@
        carBody.point[i] = car->carXY[car->body[i]];
    }
    if (IntersectionOf(&carBody, map) == GM_None) {
    if (IntersectionOf(&carBody, &map2) == GM_None) {
        ret = true;
    }
    free(carBody.point);
    free(map2.point);
    return ret;
}
lib/src/main/cpp/test_items2/drive_straight.cpp
@@ -49,7 +49,7 @@
        double l2 = DistanceOf(car->carXY[car->right_rear_tire[TIRE_OUTSIDE]], road_edge);
        MA_SendDistance(-1, (l1+l2)/2.0);
        MA_SendDistance(6 - (l1+l2)/2.0, (l1+l2)/2.0);
    }
    if (!crossStartLine) {