/** * space_server 机器人管理。 * * © 2020 成都河狸智能科技有限责任公司。保留所有权利。 * * 作者: zhq1229 */ #ifndef __ROBOT_H__ #define __ROBOT_H__ #include #include "task/task.h" using RobotId = unsigned int; namespace robot { enum RobotState { INIT = 0, PROTCET, IDLE, WORKING, FAULT, LOW_POWER, SCANNING, __ROBOT_STATE_SIZE, }; enum LocateMode { QUIT = 0, FAST, EXACT, CALIBRATION }; struct BatteryInfo { BatteryInfo(): soc(0.0f), voltage(0.0f), current(0.0f), is_charging(false) {} float soc; float voltage; float current; bool is_charging; }; struct PositionInfo { PositionInfo(): map_id(0), locate_map_id(0), x(0.0f), y(0.0f), yaw(0.0f), is_located(false), p_ts(0) {} MapId map_id; MapId locate_map_id; float x; float y; float yaw; bool is_located; unsigned long long p_ts; }; struct BasicInfo { BasicInfo(): max_x(0.0f), max_y(0.0f), max_yaw(0.0f) {} float max_x; float max_y; float max_yaw; }; struct ScanInfo { ScanInfo(): map_id(0), is_scaning(false), name(""), floor(0), width(0), height(0), x_origin(0.0f), y_origin(0.0f), resolution(0.0f), occupied_thresh(0.65f), free_thresh(0.196f), map_resolution("0.05") {} MapId map_id; bool is_scaning; std::string name; int floor; int width; int height; float x_origin; float y_origin; float resolution; float occupied_thresh; float free_thresh; std::string map_resolution; }; struct RobotInfo { RobotInfo(): id(0), name("null"), addr("null"), info("null"), state(IDLE), emcy(0) {} RobotId id; std::string name; std::string addr; std::string info; RobotState state; unsigned int emcy; // [0:0]-急停 [1:1]-调度急停 [2:2]-通信中断急停 [8:15]-客户急停 BatteryInfo battery; PositionInfo position; BasicInfo basic; ScanInfo scan; Json::Value additional; }; struct Pose { Pose(float xi, float yi, float thetai) : x(xi),y(yi),theta(thetai) {} Pose() = default; float x; float y; float theta; }; int setVel(float x, float y, float yaw); int setEmcy(unsigned int emcy); int quitEmcy(unsigned int emcy); int setLocate(MapId map_id, int mode, float x, float y, float yaw); int quitLocate(); int setScan(std::string name, int floor); int quitScan(); int setAdditional(std::string key, Json::Value &value); RobotInfo robotInfo(); RobotId robotId(); RobotState robotState(); MapId robotMapId(); MapId scanId(); PositionInfo positionInfo(); bool isCharging(); Json::Value additionalInfo(); int init(Json::Value &conf); int shutdown(); Pose globalTransLocal(Pose a, Pose b); Pose localTransGlobal(Pose a, Pose b); Pose clcTrans(Pose a, Pose b); Pose trans(); } // namespace robot #endif // __ROBOT_H__