cmvr-es/cmvr-es/devices/motor/motor_protocol_interface.h

52 lines
1.8 KiB
C++

//
// Created by lgv on 2025/8/1.
//
#pragma once
#include <cstdint>
#include "cmvr/msgs/canopen.pb.h"
#include "cmvr/msgs/motor.pb.h"
namespace cmvr {
namespace device {
class MotorProtocolInterface {
public:
enum class CommProto : uint8_t {
CANOPEN = 1,
CUSTOM = 2
};
virtual ~MotorProtocolInterface() = default;
/**
* @brief 用于初始化与通讯协议相关的设置
* @param node_id 电机Id
* @return
*/
virtual bool initNode(uint8_t node_id) = 0;
virtual void setQ(uint8_t node_id, double angle_rad) = 0;
virtual void setTarget(uint8_t node_id, double angle_rad,double vel) = 0;
virtual void setMode(uint8_t node_id,msgs::RunMode mode ) = 0;
virtual msgs::RunMode getMode(uint8_t node_id) = 0;
virtual void setLimitQdd(uint8_t node_id, double u_qdd,double l_qdd) = 0;
virtual void setLimitQd(uint8_t node_id,double qd) = 0;
virtual void setLimitQ(uint8_t node_id, double ub, double lb) = 0;
virtual bool calibrateZeroQ(uint8_t node_id) = 0;
virtual bool reachedTargetQ(uint8_t node_id) = 0;
virtual void setQd(uint8_t node_id, double qd) = 0;
virtual void setQdd(uint8_t node_id,double qdd) = 0;
// virtual void setVelocity(uint8_t node_id, double velocity) = 0;
// virtual void clearError(uint8_t node_id) = 0;
virtual void brake(uint8_t node_id) = 0;
virtual void torqueOff(uint8_t node_id) = 0;
virtual double getQ(uint8_t node_id) = 0;
virtual double getQd(uint8_t node_id) = 0;
CommProto comm_proto{CommProto::CANOPEN};
protected:
};
}
}