添加新的Monitor类,用于订阅并打印SportModeState和Odometry消息数据 移除custom_robot.cpp中冗余的日志信息 更新CMakeLists.txt以包含新的监控模块
28 lines
707 B
C++
28 lines
707 B
C++
#ifndef MONITOR_HPP
|
|
#define MONITOR_HPP
|
|
|
|
#include <unitree/idl/go2/SportModeState_.hpp>
|
|
#include <unitree/idl/ros2/Odometry_.hpp>
|
|
#include <unitree/robot/channel/channel_subscriber.hpp>
|
|
#include <memory>
|
|
|
|
namespace custom {
|
|
|
|
class Monitor {
|
|
public:
|
|
Monitor();
|
|
~Monitor();
|
|
|
|
void initialize();
|
|
|
|
private:
|
|
void sportModeStateCallback(const void* message);
|
|
void odometryCallback(const void* message);
|
|
|
|
std::unique_ptr<unitree::robot::ChannelSubscriber<unitree_go::msg::dds_::SportModeState_>> sport_mode_state_subscriber_;
|
|
std::unique_ptr<unitree::robot::ChannelSubscriber<nav_msgs::msg::dds_::Odometry_>> odometry_subscriber_;
|
|
};
|
|
|
|
} // namespace custom
|
|
|
|
#endif // MONITOR_HPP
|