Ask Your Question
0

trac_ik fails on melodic

asked 2019-01-07 04:03:11 -0600

Sietse gravatar image

updated 2019-01-08 04:27:18 -0600

Hello list,

After loading a simple urdf in the parameter server using the following launch file:

<launch>
  <param name="robot_description"
    command="xacro '$(find tf_if_test)/urdf/boot.xacro' " />

  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
    <param name="use_gui" value="true"/>
  </node>

  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find tf_if_test/launch/boot.rviz"/>
</launch>

This works fine, but if I try to use trac_ik_python, but it fails with the following error:

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)

The code:

#!/usr/bin/env python                                                                                                       
import rospy
from trac_ik_python.trac_ik import IK

rospy.init_node('tester', anonymous=True)
ik_solver = IK("l1",               "l3")
print 'done'

I thought that init_node did the ros::start() here. Am I doing something wrong?

EDIT: Or is it a problem that there are only 2DOF in this robot?

2nd EDIT: I tried the patch by adding the ros::Timer::init() in the swig-file. That works. Then I removed that patched version of trac_ik completely and reverted to the official one. Now the problem does NOT return, It is really reverted, I also rebooted the machine. Weird....

Thanks in advance, Sietse

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2019-01-09 04:46:48 -0600

Sietse gravatar image

I will answer my own question.

The error occurs here when the chain does NOT at least have 2 non-fixed joints in it. I'll make a comment on the traclab issue about it.

edit flag offensive delete link more

Comments

I would have no idea how the error message you quoted would be caused by something that has to do with fixed or other types of joints.

gvdhoorn gravatar imagegvdhoorn ( 2019-01-09 06:31:43 -0600 )edit

Track_IK is not designed to be used is less than 2 (controllable) joints. It normally gives an error about that, but is doesn't do that now. My model has 2 joints, only NOT in the chain that I used for IK. So maybe the test on the number of joints is flawed.

Sietse gravatar imageSietse ( 2019-01-09 07:20:53 -0600 )edit
0

answered 2019-01-07 04:52:23 -0600

gvdhoorn gravatar image

updated 2019-01-08 05:28:26 -0600

I believe you're running into traclabs/trac_ik#53, which points to Importing URDF throws ros::TimeNotInitializedException on SO.

In the solution/work-around given, the order of statements is different from what you show (and what I would also expect to work):

import rospy
rospy.init_node("testnode")
...
from trac_ik_python.trac_ik import IK

That should not be necessary though, and would seem to point to something that trac_ik is doing that it shouldn't (or at least not at module import time).

If this works for you, then perhaps a comment on traclabs/trac_ik#53 (which was closed as wontfix) would be good.


Edit:

2nd EDIT: I tried the patch by adding the ros::Timer::init() in the swig-file. That works. Then I removed that patched version of trac_ik completely and reverted to the official one. Now the problem does NOT return, It is really reverted, I also rebooted the machine. Weird....

My suggestion was actually to just change the order of statements in your Python script. So to first import rospy; rospy.init_node(..) and then import trac_ik.

edit flag offensive delete link more

Comments

Btw: you specifically mention "on Melodic". Did this work for you on Kinetic?

gvdhoorn gravatar imagegvdhoorn ( 2019-01-07 04:57:49 -0600 )edit

I only tested on Melodic. Probably shouldn't have mentioned it. The problem now seems to have gone away, weird. See my edit above.

Sietse gravatar imageSietse ( 2019-01-08 04:23:16 -0600 )edit

Yes, I tried that, but it had no influence at all.

Sietse gravatar imageSietse ( 2019-01-08 05:39:08 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-01-07 04:03:11 -0600

Seen: 111 times

Last updated: Jan 09 '19