How to get the data from Subscribers message with python
Hello, In my program, I try to get the Pose msg data which publish from other topic.
But when I print the variable which to read the Subscribers message, I will get the all values are 0.
Here is my code:
import sys
import rospy
import geometry_msgs.msg
from geometry_msgs.msg import Pose
grasp_goal = Pose()
def callback(msg):
global grasp_goal
grasp_goal = msg.grasp_goal
# Create a ROS node.
rospy.init_node('move_to_grasp', anonymous=True)
rospy.loginfo('Start to grasp the object...')
# Subscribe to the ROS topic that contains the grasp data.
sub = rospy.Subscriber('/grasp_pose', Pose, callback)
rospy.loginfo("x:%f y:%f z:%f w:%f x:%f y:%f z:%f", grasp_goal.position.x, grasp_goal.position.y, grasp_goal.position.z, grasp_goal.orientation.w, grasp_goal.orientation.x, grasp_goal.orientation.y, grasp_goal.orientation.z)
This is echo /grasp_pose topic:
This is result, all value are zero:
Thanks for your help !
Please don't use images to display text. Images are not searchable and the text cannot be copied and pasted. Please update your question with a copy and paste of the text instead of using images. See the support page
sorry for mistake, I will edit it.