#ifndef KINEMATICS_WEBAPI_H #define KINEMATICS_WEBAPI_H #include "utils.h" #include "RobotManager.h" #include "spc_core.h" #include #include #include #include using json = nlohmann::json; class KinematicsWebAPI { private: std::atomic running_{false}; int m_port; std::function onLog; // 按功能域分发请求 json dispatchCommand(const std::string &req_cmd, const json &req_param); // 机器人运动学与机器人管理接口 json handleRobotCommand(const std::string &req_cmd, const json &req_param); // SPC 接口 json handleSpcCommand(const std::string &req_cmd, const json &req_param); // 连杆机构接口 json handleFourBarCommand(const std::string &req_cmd, const json &req_param); // 四足机器人接口 json handleQuadrupedCommand(const std::string &req_cmd, const json &req_param); // 未知命令的默认响应 json createUnknownCommandResponse(const std::string &req_cmd, const json &req_param) const; public: KinematicsWebAPI(); // 日志函数 void log(const std::string &message); // 获取当前时间戳 std::string getCurrentTimestamp(); // 处理API请求的主函数 std::string func(std::string sanitized_body); // 初始化函数 std::string init_func(); // 运行状态检查 bool is_running() const; }; #endif // KINEMATICS_WEBAPI_H