cmvr-es/src/devices/solver/solver_interface.h

42 lines
1.2 KiB
C
Raw Normal View History

2025-11-17 13:48:22 +08:00
//
// Created by linbo on 2025/11/11.
//
#ifndef CMVR_ES_SOVLER_INTERFACE_H
#define CMVR_ES_SOVLER_INTERFACE_H
#include <mutex>
#include "rapidxml/xml_parser.h"
#include "utils/solver/qp_solver.h"
#include "utils/base/os.h"
#include "utils/base/timer.h"
#include "utils/base/ring_buffer.h"
namespace cmvr::device
{
template<int DOF>
class SolverInterface
{
public:
SolverInterface(const SolverInterface&) = delete;
SolverInterface& operator=(const SolverInterface&) = delete;
static SolverInterface& getInstance(const XmlNode& cfg);
static SolverInterface& getInstance();
static void destroyInstance();
private:
explicit SolverInterface(const XmlNode &cfg);
private:
XmlNode cfg_;
static std::once_flag init_flag_;
static std::shared_ptr<SolverInterface> instance_;
std::vector<std::string> joint_names_;
std::vector<std::string> link_names_;
std::shared_ptr<cmvr::dyn::State<DOF>> m_state_;
std::shared_ptr<cmvr::dyn::Robot<DOF>> m_robot_;
std::shared_ptr<cmvr::ctrl::QPSolver<DOF>> m_cctrl_;
};
}
#endif //CMVR_ES_SOVLER_INTERFACE_H