Go to the documentation of this file.00001
00002 import roslib
00003 roslib.load_manifest('ric_robot')
00004
00005 import rospy
00006 import actionlib
00007 from std_msgs.msg import Float64
00008 import trajectory_msgs.msg
00009 import control_msgs.msg
00010 from trajectory_msgs.msg import JointTrajectoryPoint
00011 from control_msgs.msg import JointTrajectoryAction, JointTrajectoryGoal, FollowJointTrajectoryAction, FollowJointTrajectoryGoal
00012
00013
00014
00015 class Joint:
00016 def __init__(self, motor_name):
00017 self.name = motor_name
00018 self.jta = actionlib.SimpleActionClient('/komodo_1/komodo_gripper_controller/follow_joint_trajectory', FollowJointTrajectoryAction)
00019 rospy.loginfo('Waiting for gripper joint trajectory action')
00020 self.jta.wait_for_server()
00021 rospy.loginfo('Found gripper joint trajectory action server!')
00022
00023
00024 def move_joint(self, angles):
00025 goal = FollowJointTrajectoryGoal()
00026 goal.trajectory.joint_names = ['right_finger_joint','left_finger_joint']
00027 point = JointTrajectoryPoint()
00028 point.positions = angles
00029 point.time_from_start = rospy.Duration(1)
00030 goal.trajectory.points.append(point)
00031 try:
00032 self.jta.send_goal_and_wait(goal)
00033 except TypeError as e:
00034 print e
00035
00036
00037 def main():
00038 arm = Joint('komodo_arm_controller')
00039 arm.move_joint([-0.3,0.3])
00040 arm.move_joint([0.3,-0.3])
00041 arm.move_joint([0.0,0.0])
00042
00043 def myhook():
00044 print "Done!"
00045
00046 if __name__ == '__main__':
00047 rospy.init_node('joint_position_tester')
00048 main()
00049 rospy.on_shutdown(myhook)