// // Created by linbo on 2025/10/22. // #ifndef CMVR_ES_MOTORPROTOCOLMANAGER_H #define CMVR_ES_MOTORPROTOCOLMANAGER_H #include #include #include "abstractmotorprotocol.h" #include "devices/abstract_canbus.h" #include "canbus/can_comm/can_sender.h" #include "canbus/can_comm/can_receiver.h" #include "canbus/can_comm/message_manager.h" #include "cmvr/msgs/robot_detail.pb.h" namespace cmvr::hardware { class MotorProtocolManager { public: struct MotorInfo { uint8_t node_id; //电机ID std::string jointName; //关节名称 double limitQLb; //逆时针限位 double limitQUb; //顺时针限位 double limitQd; //加速度限制 std::shared_ptr motorProtocol; }; public: explicit MotorProtocolManager(const XmlNode &cfg,std::shared_ptr> sender, std::shared_ptr> manager); ~MotorProtocolManager() = default; uint8_t getNodeId(const std::string& joint_name); //根据协议类型获取协议实例对象 std::shared_ptr getMotorProtocol(const std::string &protocolType); const MotorInfo& getMotorInfo(const std::string& joint_name); private: std::shared_ptr > can_sender_{nullptr}; std::shared_ptr > message_manager_{nullptr}; std::shared_ptr ti5Protocol_{nullptr}; //协议类型,协议实例对象 std::unordered_map> motor_protocols_; //协议类型,电机参数 std::unordered_map> motors_; }; } #endif //CMVR_ES_MOTORPROTOCOLMANAGER_H