5c6b48143d592432d896fa8de8c5d01c02589cb1..a4d90ebc6a31b9948ecee74189fe1423589e1f4c
2020-09-17 wangzhengquan
udpate
a4d90e 对比 | 目录
2020-09-17 wangzhengquan
minditance
f6d7db 对比 | 目录
9个文件已修改
52 ■■■■■ 已修改文件
Makefile 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
algorithm/IndirectAlg.c 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
algorithm/include/IndirectAlg.h 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
algorithm/include/graph.h 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
test/Makefile 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
test/test_right_walk 补丁 | 查看 | 原始文档 | blame | 历史
test/test_right_walk.c 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
test/test_right_walk3 补丁 | 查看 | 原始文档 | blame | 历史
test/test_right_walk3.c 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Makefile
@@ -34,3 +34,4 @@
    cp README.md basic_pack
    cp test/test_right_walk2.c basic_pack
    tar -czvf $(tarname) basic_pack
    rm -rf basic_pack
algorithm/IndirectAlg.c
@@ -1,6 +1,7 @@
#include "usg_common.h"
#include "IndirectAlg.h"
#include "graph.h"
 
#define PI 3.14159265
 
@@ -32,15 +33,15 @@
IndirectAlg::IndirectAlg() {}
IndirectAlg::IndirectAlg(const initializer_list<Edge> & edges, const time_t & _keepTime, const Vector2 & _direction):
    frame(edges), keepTime(_keepTime), direction(_direction), mterminate(false) {
IndirectAlg::IndirectAlg(const initializer_list<Edge> & edges,const Vector2 & _direction, const time_t & _keepTime, const double _minDistance):
    frame(edges), keepTime(_keepTime), minDistance(_minDistance), direction(_direction), mterminate(false) {
    mthread = std::thread(std::bind(&IndirectAlg::threadRoutine, this));
}
IndirectAlg::IndirectAlg(const initializer_list<Point> & points, const time_t & _keepTime, const Vector2 & _direction):
    keepTime(_keepTime), direction(_direction), mterminate(false) {
IndirectAlg::IndirectAlg(const initializer_list<Point> & points, const Vector2 & _direction, const time_t & _keepTime, const double _minDistance):
    keepTime(_keepTime), minDistance(_minDistance), direction(_direction), mterminate(false) {
    if (points.size() > 0) {
        std::vector<Edge> edges;
        initializer_list<Point>::iterator iter;
@@ -151,7 +152,8 @@
        status->lastCoordinate = record.coordinate;
    }
    if (currentDirection.x == 0 && currentDirection.y == 0) {
    if (getVecor2Len(currentDirection) <= minDistance) {
        //没动
        printRecord(3, record);
        return false;
algorithm/include/IndirectAlg.h
@@ -15,8 +15,11 @@
    Figure frame;
    //逆行持续时间,要超过这个时间才算逆行
    // 逆行持续时间,要超过这个时间才算逆行
    time_t keepTime;
    // 最小移动距离,要超过这个距离才算移动
    double minDistance;
    // 代表正确行走方向的向量
    Vector2 direction;
    // 状态缓存
@@ -29,13 +32,14 @@
public:
    
    IndirectAlg();
    IndirectAlg(const std::initializer_list<Edge> & edges, const time_t & _keepTime, const Vector2 & _direction);
    IndirectAlg(const std::initializer_list<Edge> & edges, const Vector2 & _directionconst , const time_t & _keepTime, const double _minDistance);
    /**
     * @points  组成观测区域的彼此相邻的点
     * @_keepTime 保持时间
     * @_direction 正确行进的方向方向
     * @_keepTime 保持时间
     * @minDistance 最小移动距离,要超过这个距离才算移动
     */
    IndirectAlg(const std::initializer_list<Point> & points, const time_t & _keepTime, const Vector2 & _direction);
    IndirectAlg(const std::initializer_list<Point> & points, const Vector2 & _direction, const time_t & _keepTime, const double _minDistance);
    ~IndirectAlg();
algorithm/include/graph.h
@@ -2,6 +2,7 @@
#define __USG_GRAPH_H__
#include "usg_common.h"
#include <cmath>
struct Point { 
//public:
@@ -62,4 +63,10 @@
    return {b.x - a.x, b.y - a.y};
}
static inline double getVecor2Len(Vector2& v) {
    return sqrt(v.x * v.x + v.y * v.y);
}
#endif
test/Makefile
@@ -8,7 +8,7 @@
include $(ROOT)/Make.defines.$(PLATFORM)
PROGS =    test_right_walk test_right_walk3
PROGS = test_right_walk test_right_walk3
    
test/test_right_walk
Binary files differ
test/test_right_walk.c
@@ -6,7 +6,8 @@
int test2() {
    // IndirectAlg indirectAlg({  {{0.0, 0.0}, {1000.0, 0.0}}, {{1000.0, 0.0}, {1000.0, 1000.0}}, {{1000.0, 1000.0}, {0.0, 1000.0}}, {{0.0, 1000.0}, {0.0, 0.0}} }, 5, {1, 1});
    
    IndirectAlg indirectAlg((std::initializer_list<Point>){{0.0, 0.0}, {1000.0, 0.0},  {1000.0, 1000.0}, {0.0, 1000.0} }, 5, {1, 1});
    IndirectAlg indirectAlg((std::initializer_list<Point>){{0.0, 0.0}, {1000.0, 0.0},  {1000.0, 1000.0}, {0.0, 1000.0} },
      {1, 1}, 5, 2);
    
    int i = 0;
    time_t start_time;
test/test_right_walk3
Binary files differ
test/test_right_walk3.c
@@ -45,11 +45,13 @@
int test2() {
    // IndirectAlg indirectAlg({  {{0.0, 0.0}, {1000.0, 0.0}}, {{1000.0, 0.0}, {1000.0, 1000.0}}, {{1000.0, 1000.0}, {0.0, 1000.0}}, {{0.0, 1000.0}, {0.0, 0.0}} }, 5, {1, 1});
    /**
     * 第一个参数@points  组成观测区域的彼此相邻的点
     * 第二个参数@_keepTime 保持时间
     * 第三个参数@_direction 正确行进的方向方向
     * @points  组成观测区域的彼此相邻的点
     * @_direction 正确行进的方向方向
     * @_keepTime 保持时间
     * @ minDistance 最小移动距离
     */
    IndirectAlg indirectAlg((std::initializer_list<Point>){{0.0, 0.0}, {1000.0, 0.0},  {1000.0, 1000.0}, {0.0, 1000.0} }, 5, {1, 1});
    IndirectAlg indirectAlg((std::initializer_list<Point>){{0.0, 0.0}, {1000.0, 0.0},  {1000.0, 1000.0}, {0.0, 1000.0} },
        {1, 1}, 5, 1);
    
    int i = 0;
    // time_t start_time;
@@ -94,7 +96,7 @@
void test3() {
    std::ifstream fin("test3.txt");
    std::ifstream fin("test.txt");
    char line[1024];
    //std::string line;
    char *targetIdStr;
@@ -107,7 +109,7 @@
//{"x":148,"y":45},{"x":148,"y":539},{"x":769,"y":539},{"x":769,"y":45}
    //{148, 45}, {148, 539},  {769, 539}, {769, 45}
    Record record;
    IndirectAlg indirectAlg((std::initializer_list<Point>){}, 3, {621, 0});
    IndirectAlg indirectAlg((std::initializer_list<Point>){}, {621, 0}, 3, 0);
    
    // const char *delim = " ";
    while(fin.getline(line, 1024)) {
@@ -152,7 +154,6 @@
        // printf("key = %s, value=%s\n", key, value);
    }
    fin.close();
    sleep(30);
}