Go to the documentation of this file.00001
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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
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
00091
00092 pickplace = PickPlace()
00093 rospy.loginfo('pickplace initialized.')
00094
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
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)