Found Empty jointstate message
Hi, I am currently working on iiwa lbr arm in ros and using compute_ik service to calculate the inverse kinematics and send the joint state message to /joint_state topic, which unity in windows is subscribe to this topic through rosbridge. I wrote the script to basically publish the joint state part of the IK solution to /joint_state. However, while it does give me a response with error_code 1 which I believe it means it is successful, it keeps giving me Found Empty jointstate message error, what exactly could be causing it? my setup is a robot arm mounted upside down and the values I am giving it to compute IK solution is: [0.2 0.3 0.1 0.0 30.0 0.0], and here is my code to get IK solution in python:
def IK_compute(data):
global JointPub
#Wait for theIK service to become available
rospy.wait_for_service('compute_ik')
#rospy.init_node('service_query')
#Construct the request
request = GetPositionIKRequest()
request.ik_request.group_name = "kuka_iiwa"
request.ik_request.attempts = 20
request.ik_request.pose_stamped.header.frame_id = "base"
#Set the desired orientation for the end effector HERE
request.ik_request.pose_stamped.pose.position.x = data[0]
request.ik_request.pose_stamped.pose.position.y = data[1]
request.ik_request.pose_stamped.pose.position.z = data[2]
q = quaternion_from_euler(np.deg2rad(data[3]), np.deg2rad(data[4]), np.deg2rad(data[5]))
request.ik_request.pose_stamped.pose.orientation = Quaternion(*q)
#Create the function used to call the service
compute_ik = rospy.ServiceProxy('compute_ik', GetPositionIK)
try:
#Send the request to the service
response = compute_ik(request)
#response.solution.joint_state.velocity = [0, 0, 0, 0, 0, 0, 0]
#response.solution.joint_state.effort = [0, 0, 0, 0, 0, 0, 0]
print(response)
JointPub.publish(response.solution.joint_state)
'''
if response.error_code == 1:
print("success")
elif response.error_code == -31:
print("NO IK solution")
'''
except rospy.ServiceException, e:
print "Service callfailed: %s"%e
and my terminal loginfo are:
[INFO] [1613099932.751784]: solution:
joint_state:
header:
seq: 0
stamp:
secs: 0
nsecs: 0
frame_id: "/world"
name: [joint_a1, joint_a2, joint_a3, joint_a4, joint_a5, joint_a6, joint_a7]
position: [-0.1507822277522531, 2.0425807428651455, 1.1103473810090956, -1.9972497454495166, 1.449649742196664, 1.9401822415585879, 1.2651551284903115]
velocity: []
effort: []
multi_dof_joint_state:
header:
seq: 0
stamp:
secs: 0
nsecs: 0
frame_id: "/world"
joint_names: []
transforms: []
twist: []
wrench: []
attached_collision_objects: []
is_diff: False
error_code:
val: 1
for an example IK response and
[ERROR] [1613099932.525326494]: Found empty JointState message
For a sample error message from rviz Any help will be appreciated!
I indented your code because it looked like it wasn't indented properly. Feel free to change it
Please add terminal output, since you're printing the response in your code (consider using
rospy.loginfo
instead, btw)Hi thanks for the reply, I have updated the info you talked about in the post
Is there a reason you need to pass this message through the
/joint_states
topic? That's where the current state of the robots is expected to be published. Would your problem be solved if you just changed the topic name?Hi I have changed the topic name as well and I also tried stop publishing as well but rviz is giving me the same message, it looks like it is not a publishing issue
Is anything else arriving on the
/joint_states
that is or could look like an empty message? Is anything publishing to it that is not a robot driver or simulation?Yes by echoing it gives me teh same information as the loginfo
I can't dig further right now, but the error is displayed here. Make sure no empty message arrives on
/joint_state
(even though you don't publish the result at all?), and isolate when the error occurs (when you call the IK?). Please don't forget to post your findings.