Retrieving goal from RVIZ through python script

asked 2018-02-24 09:31:02 -0500

HassanM gravatar image

updated 2018-02-25 10:03:45 -0500

Wolf gravatar image

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):

But it doesn't get anything.

Note: I want to use this for A* implementation "Collision free"

edit retag flag offensive close merge delete


rospy.spin() is called somewhere? A more complete code sample would be helpful for inspecting your problem...

Wolf gravatar image Wolf  ( 2018-02-25 10:06:00 -0500 )edit

Also note: rospy.wait_for_message(..) is not analogous to wait_for_service(..): the former will actually return the message it received immediately. There's no need to use wait_for_message(..) to check whether the topic exists.

gvdhoorn gravatar image gvdhoorn  ( 2018-02-25 10:10:09 -0500 )edit