Go to the documentation of this file.00001
00002 import numpy as np, math
00003 import scipy.io as spio
00004 import roslib; roslib.load_manifest('hrl_object_fetching')
00005 import rospy
00006 import hrl_lib.util as hrl_util
00007 from std_msgs.msg import Float64MultiArray, Bool
00008 from pr2_msgs.msg import AccelerometerState, PressureState
00009 from sensor_msgs.msg import JointState
00010 from pr2_controllers_msgs.msg import JointTrajectoryControllerState
00011 from hrl_pr2_lib.pr2 import PR2, Joint
00012 from motion_planning_msgs.srv import FilterJointTrajectory
00013 import pr2_controllers_msgs.msg as pm
00014
00015 UNTUCK = False
00016
00017 rospy.init_node('untuck_grasp')
00018 [q, t] = hrl_util.load_pickle('untuck_traj_6.pickle')
00019 q = np.mat(q.T)
00020 q = q[:,0::30]
00021
00022
00023
00024 vel = q.copy()
00025 vel[:,1:] -= q[:,0:-1]
00026 vel[:,0] = 0
00027 vel /= 0.3
00028
00029 t = np.linspace(1.3, 1.3 + (q.shape[1] - 1) * 0.3, q.shape[1])
00030
00031
00032
00033
00034
00035 pr2 = PR2()
00036 rospy.wait_for_service('trajectory_filter/filter_trajectory')
00037 filter_traj = rospy.ServiceProxy('trajectory_filter/filter_trajectory', FilterJointTrajectory)
00038
00039
00040
00041 if not UNTUCK:
00042 q = q[:,::-1]
00043 vel = -vel[:,::-1]
00044 vel[:,-1] = 0
00045
00046
00047 t[0] = 0
00048 t[1:] += 0.1
00049
00050
00051
00052 joint_traj = pr2.right._create_trajectory(q, t, vel)
00053 result = filter_traj(trajectory=joint_traj, allowed_time=rospy.Duration.from_sec(20))
00054 filtered_traj = result.trajectory
00055 filtered_traj.header.stamp = rospy.get_rostime() + rospy.Duration(1.)
00056 g = pm.JointTrajectoryGoal()
00057 g.trajectory = joint_traj
00058 pr2.right.client.send_goal(g)
00059
00060
00061