purepursuit_client.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('purepursuit_planner')
00004 import rospy
00005 import time
00006 # Brings in the SimpleActionClient
00007 import actionlib
00008 from geometry_msgs.msg import Pose2D
00009 from purepursuit_planner.msg import goal, GoToGoal
00010 
00011 # Brings in the messages used by the purepursuit action, including the
00012 # goal message and the result message.
00013 import purepursuit_planner.msg
00014 
00015 def purepursuit_client():
00016         # Creates the SimpleActionClient, passing the type of the action
00017         # (GoTo) to the constructor.
00018         client = actionlib.SimpleActionClient('purepursuit_planner', purepursuit_planner.msg.GoToAction)
00019 
00020         # Waits until the action server has started up and started
00021         # listening for goals.
00022         client.wait_for_server()
00023         #g = GoToGoal(target = [goal(pose = Pose2D(0.0, 0.0, 0.0), speed = 0.2), goal(pose = Pose2D(2.0, 0.0, 0.0), speed = 0.2), goal(pose = Pose2D(3.0, -1.0, 0.0), speed = 0.2), goal(pose = Pose2D(4.0, -1.0, 0.0), speed = 0.2)])
00024         g = GoToGoal(target = [goal(pose = Pose2D(-2.0, 0.86, 0.0), speed = 0.2), goal(pose = Pose2D(-1.0, 0.46, 0.0), speed = 0.2), 
00025         goal(pose = Pose2D(0.0, 0.0, 0.0), speed = 0.2), goal(pose = Pose2D(1.0, 0.0, 0.0), speed = 0.2), goal(pose = Pose2D(2.54, 1.0, 0.0), speed = 0.2),
00026         goal(pose = Pose2D(4.96, 2.18, 0.0), speed = 0.2), goal(pose = Pose2D(8.54, 2.22, 0.0), speed = 0.2)])
00027         # Creates a goal to send to the action server.
00028         #goal = purepursuit_planner.msg.GoToGoal(target=g)
00029         print 'Sending goal'
00030         # Sends the goal to the action server.
00031         client.send_goal(g)
00032         #print 'Sleeping'
00033         #time.sleep(4)
00034         #print 'Canceling goal'
00035         #client.cancel_goal()
00036         # Waits for the server to finish performing the action.
00037         client.wait_for_result()
00038 
00039         # Prints out the result of executing the action
00040         return client.get_result()  # A FibonacciResult
00041 
00042 if __name__ == '__main__':
00043         try:
00044                 # Initializes a rospy node so that the SimpleActionClient can
00045                 # publish and subscribe over ROS.
00046                 rospy.init_node('purepursuit_client_py')
00047                 result = purepursuit_client()
00048                 print 'Result: %d'%(result.route_result)
00049         except rospy.ROSInterruptException:
00050                 print "program interrupted before completion"


purepursuit_planner
Author(s): Román Navarro
autogenerated on Thu Aug 27 2015 12:08:42