|
|
// 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"
|
|
|
#include "GarageCommand.h"
|
|
|
#include "CommandDecoder.h"
|
|
|
#include "ZigBeeOperator.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() const;
|
|
|
int GetY() const;
|
|
|
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);
|
|
|
};
|
|
|
|
|
|
typedef void(*MCRCallback)(String point, CarHeadPosition pos);
|
|
|
|
|
|
MapPoint Mapping(const char* name);
|
|
|
String ReverseMapping(const 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, MCRCallback cb = nullptr);
|
|
|
//区分RFID卡和特殊地形标志物
|
|
|
bool IsSpecTerrainItem();
|
|
|
//倒车入库
|
|
|
//a_b_select:车库标志物选择,true -> A, false -> B
|
|
|
void ReversingIntoGarage(bool a_b_select, uint8_t target_floor);
|
|
|
};
|
|
|
|
|
|
#endif
|
|
|
|