ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Setting Specific Turn Angle on the PR2

asked 2012-04-09 08:36:00 -0500

jker gravatar image

updated 2014-11-22 17:05:24 -0500

ngrennan gravatar image

I have been working with the PR2 robot for a few weeks and I've found the need to have the robot rotate in place 90 to 180 degrees clockwise and counterclockwise. I'm working in Python and looked at the teleop package, and found a Python example here. The only problem, however, is that all of these systems only set the robot's velocity, whereas I just need the robot to turn to a specific angle while it is operating (and I haven't found any guides to this end). I could implement my own listener that takes in a desired angle then uses the teleop commands along with a PID control to turn to that angle, but I was hoping there was already a method for what I'm trying to do (preferably in Python) since it seems like a basic operation most users would probably find useful.

EDIT: I also found that geometry_msgs already has a message for pose which makes me think that there is an implementation for this somewhere (or perhaps this is just how the PR2 advertises it's current pose?)
tl;dr - How do I make the robot turn to a specific angle (in the global frame) in Python?

EDIT: I've gotten the package at and tried out the SLAM application in an empty world, and the robot goes to a random point when I set the pose to [0 0 0 0 03.14159 0]. Using the local version/however, the program gets stuck waiting for the action client to start.

move_base_client_ = actionlib.SimpleActionClient('move_base', MoveBaseAction)
move_base_client_.wait_for_server() # Gets stuck at this line using local

target = Pose(Point(0.0, 0.0, 0.0), Quaternion(0.000, 0.000, 3.14159, 0.0))
goal = MoveBaseGoal()
goal.target_pose.header.frame_id = '/map' # For local I use '/base_link'
goal.target_pose.pose = target

before these I run roslaunch pr2_gazebo pr2_empty_world.launch and then either roslaunch pr2_2dnav_slam pr2_2dnav.launch or roslaunch pr2_2dnav_local pr2_2dnav.launch

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-04-09 13:29:29 -0500

If you have the nav stack running, you can send it a navigation goal with zero offset for x,y,z, and a rotation of 90 degrees in the z axis. Otherwise, you'll have to write your own controller, which should only be about 3 lines of python.

edit flag offensive delete link more


Knowing about the navigation stack was useful, but could you perhaps be more specific (provide/link to an example in Python?). I got the stack partially working, but I added my errors to the original post.

jker gravatar image jker  ( 2012-04-10 11:35:28 -0500 )edit

Question Tools


Asked: 2012-04-09 08:36:00 -0500

Seen: 1,077 times

Last updated: Apr 10 '12