The key is the imports from the move_base_msgs.msg
A simple example
import actionlib
import rospy
from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal, MoveBaseFeedback, MoveBaseResult
rospy.init_node('send_client_goal')
client = actionlib.SimpleActionClient('/move_base', MoveBaseAction)
rospy.loginfo("Waiting for move base server")
client.wait_for_server()
goal = MoveBaseGoal()
goal.target_pose.header.frame_id = 'map'
goal.target_pose.pose.position.x = -0.063
goal.target_pose.pose.position.y = -9.035
goal.target_pose.pose.orientation.z = 0.727
goal.target_pose.pose.orientation.w = 0.686
client.send_goal(goal)
client.wait_for_result()
goal.target_pose.header.frame_id = 'map'
goal.target_pose.pose.position.x = new value
goal.target_pose.pose.position.y = new value
goal.target_pose.pose.orientation.z = new value
goal.target_pose.pose.orientation.w = new value
client.send_goal(goal)
client.wait_for_result()
and so on you can use a loop to make it move from goal to goal also.
There are two simple ways to get valid positions and orientations for the environment you're robots in:
- Use RViz and set the 2D pose followed the the 2D goal go back to where you launched RViz and the goal position should print out.
- This is the simple method use: rosrun tf tf_echo /map /base_link and this will print position/orientation the entire time the robot is moving.
You can also create a feedback callback and get the result with:
client.wait_for_result()
result = client.get_result()
You can send any number of goals without creating multiple goals:
just place the client.wait_for_result()
between calls
Hope this helps.