Files
lzwc-terminal-unitreeGo2/include/low_controller.hpp
Sucan126 5247295521 refactor(low_controller): 移动UT_CPU_ID_NONE定义并更新引用
将UT_CPU_ID_NONE宏定义移动到头文件顶部常量定义区域
在cpp文件中使用新的宏定义位置替代完整命名空间引用
2025-09-22 19:29:17 +08:00

43 lines
1.0 KiB
C++

#ifndef LOW_CONTROLLER_HPP
#define LOW_CONTROLLER_HPP
#include <unitree/robot/channel/channel_publisher.hpp>
#include <unitree/idl/go2/LowCmd_.hpp>
#include <unitree/common/thread/thread.hpp>
#include <atomic>
#define TOPIC_LOWCMD "rt/lowcmd"
#define UT_CPU_ID_NONE -1
constexpr double PosStopF = (2.146E+9f);
constexpr double VelStopF = (16000.0f);
namespace custom {
class LowController {
public:
LowController();
~LowController();
bool initialize();
bool start();
bool stop();
void shutdown() { stop(); }
bool isRunning() const { return running_; }
void requestAutoCharge(bool enable);
void powerOff();
private:
void publishLoop();
void initLowCmd();
static uint32_t crc32_core(uint32_t* ptr, uint32_t len);
unitree::robot::ChannelPublisherPtr<unitree_go::msg::dds_::LowCmd_> lowcmd_publisher_;
unitree_go::msg::dds_::LowCmd_ low_cmd_{};
unitree::common::ThreadPtr publish_thread_;
std::atomic<bool> running_{false};
};
} // namespace custom
#endif // LOW_CONTROLLER_HPP