RobotHardware-UESTC/Hardware/银星机器人底盘/PiRobot-YH_Firmware v1.0/STM32/Lib/Transport/dataframe.h

50 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef PIBOT_DATA_FRAME_H_
#define PIBOT_DATA_FRAME_H_
// 协议接口类
//消息id定义
enum MESSAGE_ID
{
ID_GET_VERSION = 0, // 获取version信息
ID_SET_ROBOT_PARAMTER = 1, // 设置机器人参数
ID_GET_ROBOT_PARAMTER = 2, // 获取机器人参数
ID_CLEAR_ODOM = 3, // 清除里程计
ID_SET_VELOCITY = 4, // 下发速度值
ID_GET_ODOM = 5, // 获取里程计值
ID_GET_PID_DATA = 6, // 获取PID值的输入和反馈用于PID参数调节)
ID_GET_IMU_DATA = 7, // 获取imu值
ID_GET_ENCODER_COUNT = 8,
ID_SET_MOTOR_PWM = 9,
ID_MESSGAE_MAX
};
// 通知接口
class Notify
{
public:
virtual void update(const MESSAGE_ID id, void* data) = 0;
};
// 协议接口, 继承改接口实现一种协议
class Dataframe
{
public:
//初始化
virtual bool init()=0;
// 注册notify 对需要关注的id添加关注
virtual void RegisterNotify(const MESSAGE_ID id, Notify* _nf)=0;
// 数据接收接口
virtual bool dataRecv(unsigned char c)=0;
// 解析协议
virtual bool dataParse()=0;
// 用于主动交互信息 预留
virtual bool interact(const MESSAGE_ID id)=0;
};
#endif