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

How to change Trac IK parameters online

asked 2020-11-16 07:22:27 -0500

cv_ros_user gravatar image

updated 2020-11-16 11:11:24 -0500

gvdhoorn gravatar image

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.

edit retag flag offensive close merge delete

Comments

1

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.

gvdhoorn gravatar image gvdhoorn  ( 2020-11-16 11:12:09 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-11-16 11:10:21 -0500

gvdhoorn gravatar image

updated 2020-11-16 11:31:57 -0500

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.

edit flag offensive delete link more

Comments

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?

cv_ros_user gravatar image cv_ros_user  ( 2020-11-16 11:25:10 -0500 )edit

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.

cv_ros_user gravatar image cv_ros_user  ( 2020-11-16 11:49:22 -0500 )edit

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?

cv_ros_user gravatar image cv_ros_user  ( 2020-11-17 05:16:34 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-11-16 07:22:27 -0500

Seen: 236 times

Last updated: Nov 16 '20