track_ik's IK function fails and doesn't go into exception
Hi,
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..
Code:
#!/usr/bin/env python
import rospy
from trac_ik_python.trac_ik import IK
rospy.init_node('test_script')
try:
urdf = rospy.get_param("/ur10_2/robot_description")
ik_solver = IK("base",
"tol_changer",
urdf_string=urdf)
rospy.loginfo("Sucess")
except:
rospy.logerr("Fail")
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?
Asked by jpurg on 2019-03-13 05:29:43 UTC
Answers
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.
Asked by jpurg on 2019-03-20 06:00:33 UTC
Comments
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.
Asked by gvdhoorn on 2019-03-20 06:04:30 UTC
Comments