Robotics StackExchange | Archived questions

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"

Asked by HassanM on 2018-02-24 10:31:02 UTC

Comments

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

Asked by Wolf on 2018-02-25 11:06:00 UTC

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.

Asked by gvdhoorn on 2018-02-25 11:10:09 UTC

Answers