Ver código fonte

feat: 开始解耦

lujw2 1 mês atrás
pai
commit
ef9a027ab8

+ 81 - 0
saturn_controller/include/data_interface/data_interface.hpp

@@ -0,0 +1,81 @@
+#ifndef DATA_INTERFACE_HPP__
+#define DATA_INTERFACE_HPP__
+
+#include "common.h"
+#include "data_struct.hpp"
+
+namespace saturn_ros2 {
+namespace data_interface {
+
+// 状态获取接口
+class StatusInterface {
+public:
+  virtual ~StatusInterface() = default;
+  virtual bool
+  getCommonStatus(robot_control::common::ROBOT_COMMON_STATUS *status) = 0;
+  virtual bool getJointsStatus(
+      robot_control::common::ROBOT_JOINTS_STATUS *joints_status) = 0;
+};
+
+// IMU数据接口
+class ImuInterface {
+public:
+  virtual ~ImuInterface() = default;
+  virtual bool
+  getImuData(robot_control::common::MC_MOTION_IMU_DATA *imu_data) = 0;
+};
+
+// 运动控制接口
+class MotionControlInterface {
+public:
+  virtual ~MotionControlInterface() = default;
+  virtual bool
+  setDirectionMovement(robot_control::common::CONTROL_SOURCE_MODE mode,
+                       const robot_control::common::ROBOT_TWIST &twist,
+                       long heartbeat) = 0;
+  virtual bool setScene(robot_control::common::CONTROL_SOURCE_MODE mode,
+                        robot_control::common::SCENE_TYPE scene) = 0;
+};
+
+// 守护模式接口
+class GuardianInterface {
+public:
+  virtual ~GuardianInterface() = default;
+  virtual bool setGuardian(robot_control::common::CONTROL_SOURCE_MODE mode,
+                           float velocity_decay_ratio,
+                           const std::string &trigger_source) = 0;
+};
+
+// 充电控制接口
+class ChargeControlInterface {
+public:
+  virtual ~ChargeControlInterface() = default;
+  virtual bool
+  enterOrExitCharge(robot_control::common::CONTROL_SOURCE_MODE mode,
+                    bool is_on_dock) = 0;
+  enterOrExitCharge(robot_control::common::CONTROL_SOURCE_MODE mode,
+                    bool is_on_dock) = 0;
+};
+
+// 高度调整接口
+class HeightAdjustInterface {
+public:
+  virtual ~HeightAdjustInterface() = default;
+  virtual bool setBodyHeight(int height) = 0;
+  // virtual bool bodyHighAdjust(robot_control::common::CONTROL_SOURCE_MODE
+  // mode,
+  //                             int height) = 0;
+};
+
+// 控制模式接口
+class ControlModeInterface {
+public:
+  virtual ~ControlModeInterface() = default;
+  virtual bool setControlMode(CONTROL_SOURCE_MODE mode) = 0;
+  // setNavOrJoyControl(robot_control::common::CONTROL_SOURCE_MODE mode) = 0;
+};
+
+} // namespace data_interface
+} // namespace saturn_ros2
+
+#endif // !DATA_INTERFACE_HPP__

+ 17 - 0
saturn_controller/include/data_interface/data_struct.hpp

@@ -0,0 +1,17 @@
+#ifndef DATA_STRUCT_HPP
+#define DATA_STRUCT_HPP
+
+namespace saturn_ros2 {
+namespace data_interface {
+
+enum class CONTROL_SOURCE_MODE {
+  null_control = 0,
+  nav_control = 1,
+  joy_control = 2,
+  uwb_control = 3
+};
+}
+
+} // namespace saturn_ros2
+
+#endif // !DATA_STRUCT_HPP

+ 4 - 0
saturn_controller/include/saturn_controller/saturn_controller.hpp

@@ -1,3 +1,6 @@
+#ifndef SATURN_CONTROLLER_HPP__
+#define SATURN_CONTROLLER_HPP__
+
 #include <spdlog/spdlog.h>
 
 #include <geometry_msgs/msg/pose_stamped.hpp>
@@ -221,3 +224,4 @@ class SaturnController {
   void publishJointState();
 };
 }  // namespace saturn_ros2
+#endif // !SATURN_CONTROLLER_HPP__