You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.4 KiB
C++

// AutoPathRunner.h
#ifndef _AUTOPATHRUNNER_h
#define _AUTOPATHRUNNER_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "OpenMVOpt.h"
#include <Ultrasonic.h>
#include "AccurateMotor.h"
namespace AutoPathRunner
{
enum class TurnDirection
{
Null,
Left,
Right
};
enum class CarHeadPosition
{
X_Positive,
Y_Positive,
X_Negitive,
Y_Negitive
};
class MapPoint
{
private:
int x, y;
public:
MapPoint();
MapPoint(int x, int y);
public:
int GetX();
int GetY();
void SetX(int x);
void SetY(int y);
bool NeedTurn(MapPoint next, CarHeadPosition pos);
TurnDirection CalcTurnDirection(MapPoint next, CarHeadPosition pos);
public:
MapPoint operator=(const MapPoint& obj);
bool operator==(const MapPoint& obj);
};
struct PointMapper
{
char name[3] = { 0 };
MapPoint point;
PointMapper();
PointMapper(const char* n, const MapPoint& p);
};
MapPoint Mapping(const char* name);
const char* ReverseMapping(MapPoint point);
void ChangePositon(CarHeadPosition& pos, TurnDirection turn);
CarHeadPosition Int2Position(int pos);
bool TrackCallback();
//解析路线
MapPoint* DecodeRoute(const char* route, int& point_cnt);
//执行路径指令
void DoRun(MapPoint* points, int point_cnt, CarHeadPosition pos);
//区分RFID卡和特殊地形标志物
bool IsSpecTerrainItem();
};
#endif