统一跨平台时间函数接口。

This commit is contained in:
xinyang
2019-07-31 14:51:01 +08:00
parent 01882b97c6
commit 98bc5ef95b
23 changed files with 87 additions and 95 deletions

View File

@@ -1,20 +1,20 @@
//
// Created by xixiliadorabarry on 1/24/19.
//
#ifndef CONSTANT_H
#define CONSTANT_H
#include "additions/additions.h"
const int BIG = 1;
const int SMALL = 0;
const int SRC_WIDTH = 320;
const int SRC_HEIGHT = 240;
const int CLOCKWISE = 1;
const int ANTICLOCKWISE = -1;
//const float ATTACK_DISTANCE = 718.0;//cm
const float ATTACK_DISTANCE = 750.0;//cm
const double ARMOR_CENTER_TO_CYCLE_CENTER = 75.0;//cm
#endif //CONSTANT_H
//
// Created by xixiliadorabarry on 1/24/19.
//
#ifndef CONSTANT_H
#define CONSTANT_H
#include "additions.h"
const int BIG = 1;
const int SMALL = 0;
const int SRC_WIDTH = 320;
const int SRC_HEIGHT = 240;
const int CLOCKWISE = 1;
const int ANTICLOCKWISE = -1;
//const float ATTACK_DISTANCE = 718.0;//cm
const float ATTACK_DISTANCE = 750.0;//cm
const double ARMOR_CENTER_TO_CYCLE_CENTER = 75.0;//cm
#endif //CONSTANT_H

View File

@@ -13,12 +13,12 @@
#include <constants.h>
#include <stdio.h>
#include <time.h>
#include <sys/timeb.h>
#include <systime.h>
#include "energy/constant.h"
#include "energy/param_struct_define.h"
#include "serial/serial.h"
#include "additions/additions.h"
#include "options/options.h"
#include "serial.h"
#include "additions.h"
#include "options.h"
using std::vector;
@@ -87,7 +87,7 @@ private:
float shoot;//若为2则要求主控板发弹
float sum_yaw, sum_pitch;//yaw和pitch的累计误差即PID中积分项
timeval time_start_guess;
systime time_start_guess;
cv::RotatedRect centerR;//风车中心字母R的可能候选区
cv::RotatedRect flow_strip;//图像中所有流动条(理论上只有一个)

View File

@@ -19,7 +19,7 @@ void Energy::judgeShootInWorld() {
// is_predicting = false;
// is_guessing = true;
// start_guess = true;
// gettimeofday(&time_start_guess, NULL);
// getsystime(time_start_guess);
LOGM(STR_CTR(WORD_LIGHT_RED, "Start Guessing!"));
} else
shoot = 2;
@@ -35,7 +35,7 @@ void Energy::judgeShootInGimbal() {
// is_predicting = false;
// is_guessing = true;
// start_guess = true;
// gettimeofday(&time_start_guess, NULL);
// getsystime(time_start_guess);
// LOGM(STR_CTR(WORD_LIGHT_RED, "Start Guessing!"));
} else
shoot = 2;

View File

@@ -14,8 +14,7 @@ using namespace cv;
// 此函数用于判断guess模式是否超时
// ---------------------------------------------------------------------------------------------------------------------
bool Energy::isGuessingTimeout() {
timeval cur_time;
gettimeofday(&cur_time, NULL);
return (cur_time.tv_sec - time_start_guess.tv_sec) * 1000.0 +
(cur_time.tv_usec - time_start_guess.tv_usec) / 1000.0 > 1000;
systime cur_time;
getsystime(cur_time);
return getTimeIntervalms(cur_time, time_start_guess) > 1000;
};

View File

@@ -4,8 +4,7 @@
#include "energy/energy.h"
#include "log.h"
#include "config/setconfig.h"
#include "options/options.h"
#include <sys/time.h>
#include "options.h"
using namespace std;
using namespace cv;