}
void moveAxes(const std::vector<int>& positions) {
if (positions.size() != axes_.size()) {
std::cerr << "Error: Number of positions does not match number of axes" << std::endl;
return;
}
for (size_t i = 0; i < axes_.size(); ++i) {
axes_[i]->move(positions[i]);
}
}
private:
std::vector<Axis*> axes_;
};
int main() {
// 创建多轴运动控制器,假设有3个轴
MultiAxisController controller(3);
// 移动轴到指定位置
std::vector<int> positions = {10, 20, 30};
controller.moveAxes(positions);
// 模拟延时
std::this_thread::sleep_for(std::chrono::seconds(1));
// 移动轴到新的位置
positions = {40, 50, 60};
controller.moveAxes(positions);