2024-02-16 07:43:43 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <thread>
|
|
|
|
|
2024-03-12 08:55:41 +08:00
|
|
|
// #include "CommunicationManager.hpp"
|
2024-02-16 07:43:43 +08:00
|
|
|
#include "Controller/DistributedIDC.hpp"
|
2024-03-12 08:55:41 +08:00
|
|
|
// #include "Controller/RobustDIDC.hpp"
|
2024-02-16 07:43:43 +08:00
|
|
|
#include "Estimator/QuadEstimator.hpp"
|
|
|
|
#include "Planner/ReactivePlanner.hpp"
|
|
|
|
|
2024-03-12 08:55:41 +08:00
|
|
|
#if defined(USE_ROS_COMM)
|
|
|
|
#include "QuadROSComm.hpp"
|
|
|
|
#elif defined(USE_DDS_COMM)
|
|
|
|
#include "QuadDDSComm.hpp"
|
|
|
|
#else
|
|
|
|
#include "SHM.hpp"
|
|
|
|
#endif
|
|
|
|
|
2024-02-16 07:43:43 +08:00
|
|
|
class Executor {
|
|
|
|
public:
|
|
|
|
Executor();
|
|
|
|
Executor(const std::string& name);
|
|
|
|
~Executor();
|
|
|
|
|
|
|
|
void setUpdateRate(const float& rate);
|
|
|
|
|
|
|
|
void step();
|
|
|
|
|
|
|
|
void run();
|
|
|
|
private:
|
|
|
|
std::string m_name;
|
2024-03-12 08:55:41 +08:00
|
|
|
float m_rate = 1000;
|
|
|
|
float m_dt = 0.001;
|
2024-03-19 03:51:40 +08:00
|
|
|
double t_curr = 0;
|
2024-03-12 08:55:41 +08:00
|
|
|
float t_last = 0;
|
|
|
|
int delay_ms = 1;
|
|
|
|
int exec_time_ms = 0;
|
|
|
|
|
|
|
|
bool m_gait_switch = true;
|
2024-02-16 07:43:43 +08:00
|
|
|
|
2024-03-12 08:55:41 +08:00
|
|
|
void initClass();
|
|
|
|
|
|
|
|
double updateTimer();
|
|
|
|
|
|
|
|
// void switchGait(const Gait& gait);
|
2024-02-16 07:43:43 +08:00
|
|
|
|
|
|
|
// SHM m_plant_data;
|
2024-03-12 08:55:41 +08:00
|
|
|
#if defined(USE_ROS_COMM)
|
2024-02-16 07:43:43 +08:00
|
|
|
std::shared_ptr<QuadROSComm> m_plant_data_ptr;
|
2024-03-12 08:55:41 +08:00
|
|
|
#elif defined(USE_DDS_COMM)
|
|
|
|
std::shared_ptr<QuadDDSComm> m_plant_data_ptr;
|
|
|
|
#else
|
|
|
|
std::shared_ptr<SHM> m_plant_data_ptr;
|
|
|
|
#endif
|
2024-02-16 07:43:43 +08:00
|
|
|
|
|
|
|
Quadruped m_robot;
|
|
|
|
|
|
|
|
// Controller m_controller;
|
|
|
|
DistributedIDC m_controller;
|
2024-03-12 08:55:41 +08:00
|
|
|
// RobustDIDC m_controller;
|
2024-02-16 07:43:43 +08:00
|
|
|
QuadEstimator m_estimator;
|
|
|
|
ReactivePlanner m_planner;
|
2024-03-12 08:55:41 +08:00
|
|
|
// Planner m_planner;
|
|
|
|
|
|
|
|
Gait stance;
|
|
|
|
Gait trot;
|
2024-03-19 03:51:40 +08:00
|
|
|
Gait walk;
|
2024-02-16 07:43:43 +08:00
|
|
|
|
|
|
|
QuadrupedSensorData m_sensor_data;
|
|
|
|
QuadrupedCommandData m_cmd_data;
|
|
|
|
QuadrupedEstimationData m_est_data;
|
|
|
|
QuadrupedPlannerData m_planner_data;
|
2024-03-12 08:55:41 +08:00
|
|
|
QuadrupedMeasurementData m_measurement_data;
|
|
|
|
QuadrupedJoystickData m_joystick_data;
|
2024-02-16 07:43:43 +08:00
|
|
|
|
2024-03-12 08:55:41 +08:00
|
|
|
std::chrono::time_point<std::chrono::high_resolution_clock> m_startTimePoint;
|
|
|
|
std::chrono::time_point<std::chrono::high_resolution_clock> m_currentTimePoint;
|
|
|
|
std::chrono::time_point<std::chrono::high_resolution_clock> m_lastTimePoint;
|
2024-02-16 07:43:43 +08:00
|
|
|
std::thread m_comm_thread;
|
2024-03-19 03:51:40 +08:00
|
|
|
|
|
|
|
bool use_plant_time = false;
|
2024-02-16 07:43:43 +08:00
|
|
|
};
|