I have a custom ros node, that subscribes data from robot-joints. in order to access the joint data, I have a None variable to which the joint positions are being assigned during function callback. Now, the problem is , i can only access that variable when the subscriber is running, once its stopped, the variable is being reset to None. If the ros node keeps running, my program can not skip to the next line unless this loop is stopped. So i am either struck with this loop where I get all this data printed through loginfo or if i remove the line rospy.spin(), in the next lines where I am using that position stored data, its returning None as the node is stopped. Can anyone please suggest me a work around for this ?
def callback(data):
Position = data.position
I am using this callback in the subscriber
I want to access the position values of the robot when I call position, as I have assigned data.position to position. but its returning None
, I believe its because, since position is None
type, it only gets the data.position values assigned to it as long as the node is spinning or running, once its stopped it might be getting reset to None
. but if i let it keep spinning using rospy.spin()
, my program does not move forward to the next step as it gets stuck in the infinite loop of rospy.spin