Retrieving goal from RVIZ through python script
I am trying to retrieve goal and initial position of robot (given through rviz by clicking on 2D nav goal and 2D pose estimate ) in python script. I have written
rospy.wait_for_message('/initialpose', PoseWithCovarianceStamped)
rospy.Subscriber('/initialpose', PoseWithCovarianceStamped, self.update_initial_pose)
def update_initial_pose(self,msg):
self.x=msg.pose.pose.position.x
But it doesn't get anything.
Note: I want to use this for A* implementation "Collision free"
rospy.spin() is called somewhere? A more complete code sample would be helpful for inspecting your problem...
Also note:
rospy.wait_for_message(..)
is not analogous towait_for_service(..)
: the former will actually return the message it received immediately. There's no need to usewait_for_message(..)
to check whether the topic exists.