From: Erik Andresen Date: Sun, 19 Jul 2015 18:27:20 +0000 (+0200) Subject: added waypoint script X-Git-Url: https://defiant.homedns.org/gitweb/?a=commitdiff_plain;h=b59f8ce49da71575d76c2da8f8bb5ba3e4c7977f;p=ros_wild_thumper.git added waypoint script --- diff --git a/launch/move_base.launch b/launch/move_base.launch index 47c2369..b6924bd 100644 --- a/launch/move_base.launch +++ b/launch/move_base.launch @@ -23,7 +23,7 @@ - + diff --git a/scripts/waypoint.py b/scripts/waypoint.py new file mode 100755 index 0000000..ac82b36 --- /dev/null +++ b/scripts/waypoint.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +# -*- coding: iso-8859-15 -*- + +import rospy +import actionlib +from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal +from actionlib_msgs.msg import GoalStatus + +class Waypoint: + def __init__(self): + rospy.init_node('waypoint') + self.move_base = actionlib.SimpleActionClient("move_base", MoveBaseAction) + while not self.move_base.wait_for_server(rospy.Duration(5)): + rospy.loginfo("Waiting for the move_base action server to come up") + + def send_goal(self): + goal = MoveBaseGoal() + + # we'll send a goal to the robot to move 1 meter forward + goal.target_pose.header.frame_id = "base_footprint" + goal.target_pose.header.stamp = rospy.Time.now() + + goal.target_pose.pose.position.x = 1.0; + goal.target_pose.pose.orientation.w = 1.0; + + self.move_base.send_goal(goal) + + self.move_base.wait_for_result() + + if self.move_base.get_state() == GoalStatus.SUCCEEDED: + rospy.loginfo("The base moved 1 meter forward") + else: + rospy.logerr("The base failed to move forward 1 meter") + +if __name__ == "__main__": + p = Waypoint() + p.send_goal()