untuck_grasp.py
Go to the documentation of this file.
00001 #! /usr/bin/python
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 #trim_val = -1
00022 #q = q[:,0:trim_val]
00023 #q[:,-1] = np.mat([[-0.269010636167, -0.307363010617, -1.52246181858, -1.67151320238, 294.057002545, -1.55558026761, -1.71909509593]]).T
00024 vel = q.copy()
00025 vel[:,1:] -= q[:,0:-1]
00026 vel[:,0] = 0
00027 vel /= 0.3
00028 #vel[:,-1] = np.mat([[0.1] * 7]).T
00029 t = np.linspace(1.3, 1.3 + (q.shape[1] - 1) * 0.3, q.shape[1])
00030 #t[-1]  = t[-1] + 2
00031 #t = q / vel
00032 #t = t.max(1)
00033 #t = np.cumsum(t)
00034 #print t
00035 pr2 = PR2()
00036 rospy.wait_for_service('trajectory_filter/filter_trajectory')
00037 filter_traj = rospy.ServiceProxy('trajectory_filter/filter_trajectory', FilterJointTrajectory)
00038 #print q.shape
00039 #vel = vel[:,0:trim_val]
00040 #t = t[0:trim_val]
00041 if not UNTUCK:
00042     q = q[:,::-1]
00043     vel = -vel[:,::-1]
00044     vel[:,-1] = 0
00045     #vel[:,0] = np.mat([[0.1] * 7]).T
00046     #t[-1] = t[-1] - 2
00047     t[0] = 0
00048     t[1:] += 0.1
00049     #print q
00050     #print vel
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 #pr2.right.set_poses(q, t, vel)
00061 #def set_poses(self, pos_mat, times, vel_mat=None, block=True):


hrl_object_fetching
Author(s): Kelsey Hawkins. Advisor: Prof. Charlie Kemp. Healthcare Robotics Lab, Georgia Tech
autogenerated on Wed Nov 27 2013 11:33:13