0

I am trying to work with NAO (V50) with trac_ik inverse kinematic solver. I need to use modified limits, because NAO has skin added onto him, which changed the limits. Tried to use pre-genrated nao.urdf without modification, but that throws the same error. When I looked up this error, I found it could be related to tf library. Their included trac_ik example code for pr2 works just fine. When I thought it was bug from trac_ik, they responded that it is ROS usage error.

from naoqi import ALProxy
from trac_ik_python.trac_ik import IK
import rospy

with open('data.urdf', 'r') as file:
    urdf=file.read()

Solver = IK("Torso", "LShoulderPitch", urdf_string=urdf)

Ends with: 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() Neúspěšně ukončen (SIGABRT) (core dumped [obraz paměti uložen])

Also tried to have rospy.init_node("text") in the beginning, but that also did not work. Using ROS Melodic. How do I find what is causing this/what is the correct ROS usage?

Edit: Why the downvote?

rojikada
  • 347
  • 1
  • 3
  • 9

1 Answers1

1

Make sure you initialize ROS time before doing anything else, since some stuff you importing might need it.

import rospy
rospy.init_node("testnode")

from naoqi import ALProxy
from trac_ik_python.trac_ik import IK

with open('data.urdf', 'r') as file:
    urdf=file.read()

Solver = IK("Torso", "LShoulderPitch", urdf_string=urdf)

Update: It seems this is a tf related issue as you said. Can you try these steps:
1- Find track_ik_wrap.i file in track_ik_python package.
2- add line "ros::Time::init();" to TRAC_IK constructor. (I added it before urdf::Model robot_model; line)
3- Recompile package with catkin_make --pkg track_ik_python
4- Run your example script again.

unlut
  • 3,525
  • 2
  • 14
  • 23
  • Thanks, also tried that, but that still gives me the same response. – rojikada Aug 14 '18 at 19:55
  • Okay, I tried to run same packages as you, can you try this: 1- Find track_ik_wrap.i file in track_ik_python package. 2- add line "ros::Time::init();" to TRAC_IK constructor. (I added it before urdf::Model robot_model; line) 3- Recompile package with catkin_make --pkg track_ik_python 4- Run your example script again. – unlut Aug 14 '18 at 20:53