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

track_ik's IK function fails and doesn't go into exception

asked 2019-03-13 05:29:43 -0600

jpurg gravatar image

updated 2019-03-13 05:50:17 -0600


If I call IK function in a program with wrong frame name as argument (for example tol_changer not tool_changer) I want back error, and not that whole program is terminated..


#!/usr/bin/env python

import rospy
from trac_ik_python.trac_ik import IK


    urdf = rospy.get_param("/ur10_2/robot_description")
    ik_solver = IK("base",

This code never goes to except because it's always terminated by IK:

Couldn't find chain base to tol_changer
terminate called after throwing an instance of 'ros::TimeNotInitializedException'
  what():  Cannot use ros::Time::now() before the first NodeHandle has been created or ros::start() has been called.  If this is a standalone app or test that just uses ros::Time and does not communicate over ROS, you may also call ros::Time::init()
Aborted (core dumped)

I have already tried first initializing node and then importing IK as recommended here (altho I'm using ROS Kinetic) but it didn't work.

It works perfectly if tip frame name is correct. It also goes into exception if I put in wrong URDF name (as expected). Any ideas how I would fix that?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-03-20 06:00:33 -0600

jpurg gravatar image

updated 2019-04-01 07:42:13 -0600

I found solution:

As stated here, I added ros::Time::init(); before urdf::Model robot_model; (in TRAC_IK function) in trac_ik_wrap.i, then I added return 0; to

if(!tree.getChain(base_link, tip_link, chain))

If I wouldn't add that return, it would still run without termination and ros time error, but it would go to try (so success) not except.

Now just recompile package in workspace with catkin_make or catkin build or whatever you use.

edit flag offensive delete link more


As this is at best a work-around, I would suggest opening an issue on the trac_ik tracker about this and reporting what you experienced.

gvdhoorn gravatar image gvdhoorn  ( 2019-03-20 06:04:30 -0600 )edit

Question Tools



Asked: 2019-03-13 05:29:43 -0600

Seen: 337 times

Last updated: Apr 01 '19