2025-10-24 09:51:14 +08:00
|
|
|
//
|
|
|
|
|
// Created by linbo on 2025/10/23.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "controller_manager.h"
|
|
|
|
|
|
2025-10-24 14:37:17 +08:00
|
|
|
#include "jointpositioncontroller.h"
|
|
|
|
|
#include "cartesiancontroller.h"
|
2025-10-24 09:51:14 +08:00
|
|
|
using namespace std;
|
2025-10-24 14:37:17 +08:00
|
|
|
using namespace cmvr::device;
|
|
|
|
|
|
|
|
|
|
ControllerManager::ControllerManager(const XmlNode& cfg):state_(ControlManagerState_Idle)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ControllerManager::clearError()
|
|
|
|
|
{
|
|
|
|
|
state_ = ControlManagerState_Idle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ControllerManager::create(const XmlNode& cfg)
|
|
|
|
|
{
|
|
|
|
|
auto children = cfg.getChildren();
|
|
|
|
|
for (auto& child : children)
|
|
|
|
|
{
|
|
|
|
|
if (child.getNodeName() == "ComponentGroup")
|
|
|
|
|
{
|
|
|
|
|
ComponentGroup group;
|
|
|
|
|
group.id = child.getAttrString("id");
|
2025-10-24 17:06:17 +08:00
|
|
|
// CanGroupID可能记录了多个canGroupID
|
|
|
|
|
std::string canGroupIDs = child.getAttrString("CanGroupID");
|
|
|
|
|
std::istringstream iss(canGroupIDs);
|
2025-10-24 14:37:17 +08:00
|
|
|
std::string id;
|
|
|
|
|
while (std::getline(iss, id, ',')) {
|
|
|
|
|
group.CanGroupIDs.push_back(id);
|
|
|
|
|
}
|
|
|
|
|
auto controller_nodes = child.getChildren();
|
|
|
|
|
for (auto& controller_node : controller_nodes)
|
|
|
|
|
{
|
|
|
|
|
if (controller_node.getNodeName() == "JointPositionCtrl")
|
|
|
|
|
{
|
|
|
|
|
group.controllers_["JointPositionCtrl"] = std::make_shared<JointPositionController>(controller_node);
|
|
|
|
|
}
|
|
|
|
|
else if (controller_node.getNodeName() == "CartesianController")
|
|
|
|
|
{
|
|
|
|
|
group.controllers_["CartesianController"] = std::make_shared<CartesianController>(controller_node);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-24 17:06:17 +08:00
|
|
|
//
|
2025-10-24 14:37:17 +08:00
|
|
|
|
|
|
|
|
componentGroups_[group.id] = group;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|