ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Problem with MoveGroupInterface::getRobotModel() providing only const version [closed]

asked 2019-01-15 05:21:49 -0500

aPonza gravatar image

updated 2019-01-15 05:53:35 -0500

I'm trying to get my own instance of JointModelGroup from code equivalent to this:

auto move_group = moveit::planning_interface::MoveGroupInterface {"panda_arm"};
auto robot_model_constptr = move_group.getRobotModel();
auto joint_model_group = std::unique_ptr<moveit::core::JointModelGroup> {robot_model_constptr->getJointModelGroup("panda_arm")};

However this doesn't compile (long error omitted for brevity):

error: no matching function for call to ‘std::unique_ptr<moveit::core::JointModelGroup>::unique_ptr(<brace-enclosed initializer list>)’
   auto joint_model_group = std::unique_ptr<moveit::core::JointModelGroup> {robot_model_constptr->getJointModelGroup("panda_arm")};

which ultimately boils down to

error: invalid conversion from ‘const moveit::core::JointModelGroup*’ to ‘std::unique_ptr<moveit::core::JointModelGroup>::pointer {aka moveit::core::JointModelGroup*}’ [-fpermissive]
   auto joint_model_group = std::unique_ptr<moveit::core::JointModelGroup> {robot_model_constptr->getJointModelGroup("panda_arm")};

This stems apparently from getRobotModel either being a const function or returning a ConstPtr (likely the first), as that leads to calling the const version of getJointModelGroup (instead of the existing non-const) which makes it impossible to get the unique_ptr.

I have found however that this does compile:

auto move_group = moveit::planning_interface::MoveGroupInterface {"panda_arm"};
auto robot_model_constptr = move_group.getRobotModel();
auto robot_model = * robot_model_constptr;
auto joint_model_group = std::unique_ptr<moveit::core::JointModelGroup> {robot_model.getJointModelGroup("panda_arm")};

and I'm therefore left wondering if I'm doing something I shouldn't or if there is a better way to get joint_model_group without declaring things I don't necessarily need myself.

EDIT: from what I can gather e.g. here I get the const version of getJointModelGroup because getRobotModel is const, is what I'm trying to say.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by aPonza
close date 2019-01-16 08:27:31.504606

1 Answer

Sort by » oldest newest most voted
0

answered 2019-01-16 08:26:31 -0500

aPonza gravatar image

I don't remember how or why but I remember having tried and having it not work. Regardless, this does work:

auto joint_model_group = std::make_unique<moveit::core::JointModelGroup>(*robot_model_constptr->getJointModelGroup("panda_arm"));

(Source)

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-01-15 05:21:49 -0500

Seen: 152 times

Last updated: Jan 16 '19