如何使用逆运动学在多体工厂上求解 IK?
How to use InverseKinematics to solve IK on MultibodyPlant?
我试图使用InverseKinematics来解决MultibodyPlant的IK。我试图向它添加一些位置约束,然后做求解器。
drake::multibody::InverseKinematics kinsol(plant);
auto world = plant.world_frame();
Eigen::Ref<const Eigen::Vector3d> p_BQ;
Eigen::Ref<const Eigen::Vector3d> p_AQ_lower;
Eigen::Ref<const Eigen::Vector3d> p_AQ_upper;
auto COM = plant.GetFrameByName("hip_mass");
p_BQ << ...
p_AQ_lower << ...
p_AQ_upper << ...
auto pos1 = kinsol.AddPositionConstraint(COM, p_BQ, world, p_AQ_lower, p_AQ_upper);
drake::solvers::MathematicalProgramResult result = drake::solvers::Solve(kinsol.prog());
auto result_vec = result.GetSolution();
但是编译器给出了错误
error: call to deleted constructor of 'drake::multibody::BodyFrame<double>'
auto world = plant.world_frame();
^ ~~~~~~~~~~~~~~~~~
bazel-out/k8-py2-opt/bin/multibody/tree/_virtual_includes/multibody_tree_core/drake/multibody/tree/body.h:68:35: note: 'BodyFrame' has been explicitly marked deleted here
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(BodyFrame)
error: no matching constructor for initialization of 'Eigen::Ref<const Eigen::Vector3d>' (aka 'Ref<const Matrix<double, 3, 1> >')
Eigen::Ref<const Eigen::Vector3d> p_BQ;
error: variable type 'drake::multibody::Frame<double>' is an abstract class
auto COM = plant.GetFrameByName("hip_mass");
我不确定我是否正确使用了反向运动学。有人对此有解决方案吗?或者也许还有其他方法可以为RigidbodyTree做IK?
您是否尝试过将该行auto world = plant.world_frame()
更改为
const auto& world = plant.world_frame();
当你使用auto
时,编译器可能会尝试推断类型为BodyFrame
,但我们没有BodyFrame
的复制构造函数。如果将其更改为const auto&
,则world
的类型为const BodyFrame&
,构造此 const 引用不需要调用复制构造函数。
同样,对于行auto COM = plant.GetFrameByName("hip_mass");
,此行应更改为
const auto& COM = plant.GetFrameByName("hip_mass");
顺便说一句,臀部质量框架很可能不完全是质心 (COM( 的位置。
当你调用Solve(kinsol.prog())
时,我建议给它一个初步猜测,否则德雷克将使用零向量作为默认的初始猜测。机器人很可能处于零向量的奇异配置中(雅可比的某些行变为零(。对于许多基于梯度的非线性优化求解器来说,这不是一个好的初始开始。我建议将其更改为
const Eigen::VectorXd q_guess = Eigen::VectorXd::Constant(plant.num_positions(), 0.1);
const auto result = Solve(kinsol.prog(), q_guess);
您使用非零向量q_guess
作为初始猜测。
相关文章:
- 派生类是否可以在抽象工厂设计模式中具有数据成员
- 使用Unique_ptr确保工厂中的对象唯一
- 带有继承的C++工厂
- 如何在工厂方法中返回指向基于基础操作系统的派生类的有效指针
- 工厂方法:分配和strcpy_s的差异
- C++库和自注册类:客户端应用程序中的工厂映射为空
- 这个工厂类在这个C++视频中的意义何在?
- 此工厂功能有什么问题?
- 注册对对象工厂的调用会导致段错误
- 工厂设计模式优化
- 在 C++ 中返回新的构造函数(*this)工厂
- 确保在编译期间仅同时使用来自同一工厂的对象
- 在工厂或C++类中包含数据库 .h 文件
- 如何使用逆运动学在多体工厂上求解 IK?
- 在基类中编写工厂方法
- WIC 工厂将始终在 Windows7 上为 nullptr("What's a Creel?"教程中使用)
- 抽象工厂结构的差异
- 编写可测试的代码 - lambda 函数和unique_ptr中的basic_istream工厂
- 下面抽象工厂设计模式的实现是正确的吗
- 没有用于初始化模拟工厂的匹配构造函数