Ask Your Question
0

python sending goals to the navigation stack

asked 2013-09-18 04:04:34 -0500

Massbuilder gravatar image

updated 2014-01-28 17:17:59 -0500

ngrennan gravatar image

Is there any good examples on how to send goals to the navigation stack in python? I been looking around and yet to find the equivalent of the example shown in the navigation tutorial.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
0

answered 2013-09-18 07:32:44 -0500

It's just a matter of making a action call. There is an actionlib tutorial showing how to make an action call with python. For navigation, all you have to do is substitute the appropriate goal type.

edit flag offensive delete link more

Comments

The link is really helpful. Thank you!

VickyD gravatar image VickyD  ( 2018-01-09 10:14:32 -0500 )edit
2

answered 2018-02-05 01:24:14 -0500

fiorellasibona gravatar image

updated 2019-01-15 10:50:37 -0500

Hi! Hoping it can be helpful to someone, I have wrote two posts about sending goals to the navigation stack with a Python node (with example code):

  • Sending a single goal (equivalent to the C++ tutorial), here.

  • Sending a sequence of goals (complete of simulation with a turtlebot robot), here.

Cheers!

edit flag offensive delete link more

Comments

3

Can you please update your answer with more information including code examples that way it will be self-contained? If those pages move or disappear then this answer will be useless.

jayess gravatar image jayess  ( 2018-05-26 01:30:38 -0500 )edit

thanks for the code. When I run the code I get the error: AttributeError: 'module' object has no attribute 'SimpleActionClient' I also tried import SimpleActionClient from actionlib -> doesn't work either. Does anybody have an idea?

LeGer gravatar image LeGer  ( 2019-02-01 08:27:39 -0500 )edit

Hi @jayess, I have updated my answer, thank you!

fiorellasibona gravatar image fiorellasibona  ( 2019-03-04 08:55:17 -0500 )edit

Hi @LeGer, due to changes to the turtlebot launch files names the code started returning the error you have reported. The code has been updated and now should work fine. Don't hesitate to contact me for any further issue!

fiorellasibona gravatar image fiorellasibona  ( 2019-03-04 08:57:46 -0500 )edit

@fiorellasibona sorry for the confusion, but I meant putting the examples in the answer. The reason is to keep answers self-contained because files/pages can and do disappear from other sites making the answers not helpful

jayess gravatar image jayess  ( 2019-03-04 12:54:14 -0500 )edit
0

answered 2021-03-09 22:43:29 -0500

hskramer gravatar image

updated 2021-03-10 09:58:11 -0500

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:

  1. 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.
  2. 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.

edit flag offensive delete link more

Comments

@hskramer It helps readability to format code snippets. Use the 101010 button to do so. I've updated your answer with this suggestion. Thanks!

jarvisschultz gravatar image jarvisschultz  ( 2021-03-10 09:59:16 -0500 )edit

Thank you, I was in a rush and just wanted to put something out their that people might find helpful. I will take more time with my next post.

hskramer gravatar image hskramer  ( 2021-03-18 19:31:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-09-18 04:04:34 -0500

Seen: 5,576 times

Last updated: Mar 10