test_putdown_feasibility.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('tidyup_tools')
00004 import rospy
00005 import sys, traceback
00006 from tidyup_msgs import msg
00007 from tidyup_msgs import srv
00008 from pr2_python.planning_scene_interface import *
00009 from arm_navigation_msgs.msg import CollisionObject, Shape, RobotState
00010 from geometry_msgs.msg import Point, Pose, PoseStamped
00011 from pr2_tasks.pickplace import PickPlace
00012 from pr2_tasks.pickplace_definitions import PlaceGoal, PlaceResult
00013 from visualization_msgs.msg import Marker, MarkerArray
00014 from pr2_python import visualization_tools as vt
00015 from pr2_python.exceptions import ManipulationError
00016 import numpy as np
00017 
00018 if __name__ == '__main__':
00019   try:
00020     rospy.init_node('test_putdown_feasablity', anonymous=True)
00021     vispub = rospy.Publisher('/tidyup/visualization', MarkerArray)
00022     rospy.loginfo('setting up planning scene...')
00023     psi = get_planning_scene_interface()
00024     
00025     # create cup
00026 #    object = CollisionObject()
00027 #    object.id = 'cup_test'
00028 #    shape = Shape()
00029 #    shape.type = shape.BOX
00030 #    shape.dimensions.append(0.05)
00031 #    shape.dimensions.append(0.05)
00032 #    shape.dimensions.append(0.12)
00033 #    object.shapes.append(shape)
00034 #    pose = Pose()
00035 #    pose.position.x = 0.032
00036 #    pose.position.y = 0.015
00037 #    pose.position.z = 0.0
00038 #    pose.orientation.x = 0.707
00039 #    pose.orientation.y = -0.106
00040 #    pose.orientation.z = -0.690
00041 #    pose.orientation.w = 0.105
00042 #    object.poses.append(pose)
00043 #    object.header.frame_id = 'l_gripper_r_finger_tip_link'
00044 #    psi.add_object(object)
00045 #    if not psi.attach_object_to_gripper('left_arm', 'cup_test'):
00046 #      rospy.logerr('attach object failed.')
00047 
00048     #create table
00049 #    object = CollisionObject()
00050 #    object.id = 'table_test'
00051 #    shape = Shape()
00052 #    shape.type = shape.BOX
00053 #    shape.dimensions.append(0.5)
00054 #    shape.dimensions.append(1)
00055 #    shape.dimensions.append(0.1)
00056 #    object.shapes.append(shape)
00057 #    pose = Pose()
00058 #    pose.position.x = 0.5
00059 #    pose.position.y = 0.0
00060 #    pose.position.z = 0.55
00061 #    pose.orientation.x = 0
00062 #    pose.orientation.y = 0
00063 #    pose.orientation.z = 0
00064 #    pose.orientation.w = 1
00065 #    object.poses.append(pose)
00066 #    object.header.frame_id = '/base_link'
00067 #    psi.add_object(object)
00068     
00069     # set robot state
00070     left_arm_joints = [2.1, 1.26, 1.8, -1.9, -3.5, -1.8, np.pi/2.0]
00071     right_arm_joints = [-2.1, 1.26, -1.8, -1.9, 3.5, -1.8, np.pi/2.0]
00072     pose = Pose()
00073     pose.position.x = -0.6
00074     pose.position.y = 0.0
00075     pose.position.z = 0.0510018
00076     pose.orientation.x = 0
00077     pose.orientation.y = 0
00078     pose.orientation.z = 0
00079     pose.orientation.w = 1
00080     robot_state = psi.get_robot_state()
00081     robot_state.multi_dof_joint_state.poses[0] = pose
00082     r = robot_state.joint_state.name.index('r_shoulder_pan_joint')
00083     l = robot_state.joint_state.name.index('l_shoulder_pan_joint')
00084     position = list(robot_state.joint_state.position)
00085     for offset in range(len(right_arm_joints)):
00086       position[r + offset] = right_arm_joints[offset]
00087       position[l + offset] = left_arm_joints[offset]
00088     robot_state.joint_state.position = position
00089     rospy.loginfo('setting robot state...')
00090     #psi.set_robot_state(robot_state)
00091     
00092     pickplace = PickPlace()
00093     rospy.loginfo('pickplace initialized.')
00094     # create place goal
00095     place_locations = list()
00096     poseStamped = PoseStamped()
00097     poseStamped.header.frame_id = '/base_link'
00098     pose = poseStamped.pose
00099     pose.position.x = 0.5
00100     pose.position.y = 0.0
00101     pose.position.z = 0.752
00102     pose.orientation.x = 0
00103     pose.orientation.y = 0
00104     pose.orientation.z = 0
00105     pose.orientation.w = 1
00106     #place_locations.append(poseStamped)
00107     for y in range(-5, 5):
00108       pose.position.y = y * 0.1
00109       place_locations.append(copy.deepcopy(poseStamped))
00110     place_goal = PlaceGoal('left_arm', place_locations, collision_object_name='cup_2', collision_support_surface_name= 'table1_loc1')
00111     print(place_goal.place_locations)
00112     place_goal.only_perform_feasibility_test = True
00113     place_markers = MarkerArray()
00114     for i, pose in enumerate(place_goal.place_locations):
00115       place_markers.markers.append(vt.marker_at(pose_stamped=pose, ns="putdown_test", mid=i, mtype=Marker.ARROW))
00116     vispub.publish(place_markers)
00117     try:
00118       place_result = pickplace.place(place_goal)
00119     except ManipulationError, err:
00120       rospy.loginfo(err)
00121     rospy.loginfo('done.')
00122   except:
00123     traceback.print_exc(file=sys.stdout)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


tidyup_tools
Author(s): Andreas Hertle, Christian Dornhege
autogenerated on Wed Dec 26 2012 15:50:57