arm_jta.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
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_arm_controller/follow_joint_trajectory', FollowJointTrajectoryAction)
00019             rospy.loginfo('Waiting for arm joint trajectory action')
00020             self.jta.wait_for_server()
00021             rospy.loginfo('Found arm joint trajectory action server!')
00022 
00023             
00024         def move_joint(self, angles):
00025             goal = FollowJointTrajectoryGoal()                  
00026             goal.trajectory.joint_names = ['base_rotation_joint','shoulder_joint','elbow1_joint','elbow2_joint','wrist_joint']
00027             point = JointTrajectoryPoint()
00028             point.positions = angles
00029             point.time_from_start = rospy.Duration(5)                   
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.2,0.2,0.0,0.2,1.0])
00040             rospy.sleep(5.0)
00041             arm.move_joint([-0.2,-0.2,-0.0,-0.2,-1.0])
00042             rospy.sleep(5.0)
00043             arm.move_joint([0.0,0.0,0.0,0.0,0])
00044 def myhook():
00045   print "Done!"
00046   
00047 if __name__ == '__main__':
00048       rospy.init_node('joint_position_tester')
00049       main()
00050       rospy.on_shutdown(myhook)


ric_robot
Author(s): RoboTiCan
autogenerated on Fri May 20 2016 03:50:58