cmvr-es/src/devices/controller/abstractcontroller.h
2025-11-17 13:48:22 +08:00

45 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// Created by linbo on 2025/10/23.
//
#pragma once
#include <curl/curl.h>
#include "rapidxml/xml_parser.h"
#include "jsoncpp/json/json.h"
namespace cmvr::device
{
enum ControllerState
{
ControllerState_Idle, //默认
ControllerState_Executing, //正在执行命令
ControllerState_Switching //命令被中断,正在切换
};
class AbstractController
{
public:
explicit AbstractController(const XmlNode& cfg){}
virtual ~AbstractController(){}
[[nodiscard]] ControllerState getState() const {return state_;}
//此处的Json中应该包含目标电机信息电机idcanGroupId等其他必要参数用以确定是调用哪个can实例发送消息
// 还要包含操作内容,比如要执行的是直接控制每个电机位置,还是指定末端关节位置
/*
"params":{“canGroupId”:"",motors:[{"joint_name":"","id":""},{"joint_name":"","id":""}]},
"operate":{}
**/
virtual void call(const Json::Value& json) = 0;
virtual void interrupt() = 0;
virtual void stop() = 0;
protected:
ControllerState state_;
double defaultSpeed_;
double defaultAcc_;
};
}