// AutoPathRunner.h #ifndef _AUTOPATHRUNNER_h #define _AUTOPATHRUNNER_h #if defined(ARDUINO) && ARDUINO >= 100 #include "arduino.h" #else #include "WProgram.h" #endif #include #include #include #include "OpenMVOpt.h" #include #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(); 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(); //倒车入库 //a_b_select:车库标志物选择,true -> A, false -> B void ReversingIntoGarage(bool a_b_select, uint8_t target_floor); }; #endif