0
$\begingroup$

Rosanswers logo

Hi,

I would like to know how to change the IK parameters in C++. The kinematics.yaml contains default parameters and I would like to change for certain planning operations the solve_type parameters.

So how to retrieve the IK solver pointer in order to change some parameters, and so that it is updated for the MoveGroupInterface?

I am using the TRAC-IK plugin if it matters.


Originally posted by cv_ros_user on ROS Answers with karma: 17 on 2020-11-16

Post score: 0


Original comments

Comment by gvdhoorn on 2020-11-16:\

I am using the TRAC-IK plugin if it matters.

Yes, this matters, as only Trac IK uses the solve_type parameter.

I've updated the title of your question to mention your use of Trac IK.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The kinematics.yaml contains default parameters and I would like to change for certain planning operations the solve_type parameters.

I don't believe this will work. That file is only read once, during startup (of roslaunch actually).

MoveIt instantiates the IK solver then once (well: depending on how many groups you have configured of course), which reads the parameters, once, and those get used until a new Trac IK instance is created.

This is the only time TRAC_IKKinematicsPlugin (ie: the plugin class) reads that parameter: link.

So how to retrieve the IK solver pointer in order to change some parameters, and so that it is updated for the MoveGroupInterface?

Internally, Trac IK stores the value of that parameter in a private member variable called solve_type_ (here). There doesn't appear to be any setter (nor a getter) for that member variable.

So even with a reference to the IK solver's instance, you would not be able to change the value of that member variable.


Having written that: the plugin does check how it's been configured before solving a query (here).

So theoretically, you could add dynamic_reconfigure support to the MoveIt plugin, expose that solve_type_ member as a dynamic_reconfigure variable, and then use dynamic_reconfigure's service API to update the solve type dynamically. Note: you'd still need to add a setter though.

It would not be linked to any particular query though, as it wouldn't be part of the IK request. But it would allow you to change the solve type after the MoveIt IK plugin has been instantiated.


Edit:

I want to change this parameters in the code and without user intervention.

dynamic_reconfigure has a service interface which is non-user-facing. It's exactly there to be used "from code". It does not require any user interaction.

Any advices about how could I maybe dynamically cast it to a "TRAC-IK solver" in oder to set this parameter?

Without creating that setter you'll not be able to change anything.

But if you're willing to do all sorts of nasty things, then:

  • add the setter
  • downcast the reference to the specific TRAC_IKKinematicsPlugin
  • use the setter

It would be very brittle though, as you'd have to be sure what you have is actually an instance of TRAC_IKKinematicsPlugin.

And using dynamic_cast this way is not what most people consider proper use.


Originally posted by gvdhoorn with karma: 86574 on 2020-11-16

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by cv_ros_user on 2020-11-16:
Thanks for your answer.

I don't think dynamic_reconfigure is an option for me. I want to change this parameters in the code and without user intervention. I would like to try something like move to a specific pose that should maximize the manipulability index and then use Cartesian plan with distance criterion for the IK solver.

I am already building MoveIt and TRAC-IK from sources. I have seen this line: const kinematics::KinematicsBaseConstPtr& solver = jmg->getSolverInstance(); (here). Any advices about how could I maybe dynamically cast it to a "TRAC-IK solver" in oder to set this parameter?

Comment by cv_ros_user on 2020-11-16:
Thanks again.

I have almost no experience with dynamic_reconfigure so I didn't know it was possible to use it with services. I will try to expose this parameter. The concept of plugin in MoveIt is a little bit hard to grasp for me. So I tend to avoid this path.

Comment by cv_ros_user on 2020-11-17:
So I have added a trac_ik/trac_ik_kinematics_plugin/cfg/TRACIKDynamicReconfigure.cfg file. I have added a dynamic_reconfigure_server_ in trac_ik/trac_ik_kinematics_plugin/src/trac_ik_kinematics_plugin.cpp.

When using rosrun rqt_reconfigure rqt_reconfigure, change is correctly printed in TRAC_IKKinematicsPlugin::dynamicReconfigureCallback.

But I have this kind of errors Tried to advertise a service that is already advertised in this node [/ik/trac_ik/set_parameters] at initialisation. So in which files should I put the cfg and the dynamic_reconfigure_server_ in order to update correctly the TRAC_IKKinematicsPlugin?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.