ros2/moveit2 报错IKConstraintSampler received dirty robot state

问题

当以ros-humle-moveit应用双臂规划时,给定两个笛卡尔目标规划运行如:

move_group.setPoseTarget(another_pose_L, "L_panda_link8");
move_group.setPoseTarget(another_pose_R, "R_panda_link8");
bool success = (move_group.plan(my_plan) == moveit::core::MoveItErrorCode::SUCCESS);

会大量重复报错,如:

[ERROR] [1646681894.535920515, 851.070000000]: IKConstraintSampler received dirty robot state, but valid transforms are required. Failing.

解决

首先我的报错为ros-humle-moveit(2.5.5版本),再此之前的moveit2可能都有此问题。幸运的是此问题已在2.6.0及以后版本修复,所以可以对比ros-jazzy-moveit(2.10.0版本)发现UnionConstraintSampler::sample的实现有变化。其他版本同理,故针对我的版本提取cpp所在的moveit_core:

cd /your/ws/path/src
git clone https://github.com/moveit/moveit2.git -b 2.5.5 
mv moveit2/moveit_core moveit_core
rm -rf moveit2
cd ..

修改moveit2/moveit_core/constraint_samplers/src/union_constraint_sampler.cpp中的UnionConstraintSampler::sample的实现为以下,其他保持不变

bool UnionConstraintSampler::sample(moveit::core::RobotState& state, const moveit::core::RobotState& reference_state,
                                    unsigned int max_attempts)
{
  state = reference_state;
  for (ConstraintSamplerPtr& sampler : samplers_)
  {
    // ConstraintSampler::sample returns states with dirty link transforms (because it only writes values)
    // but requires a state with clean link transforms as input. This means that we need to clean the link
    // transforms between calls to ConstraintSampler::sample.
    state.updateLinkTransforms();
    if (!sampler->sample(state, max_attempts))
      return false;
  }
  return true;
}

最后重新编译记得再. install/setup.bash一下运行即可。

  • 9
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值