sample_moveit_publisher.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 
00003 import roslib
00004 import rospy
00005 import time
00006 import actionlib
00007 from moveit_msgs.srv import *
00008 from moveit_msgs.msg import RobotState
00009 from moveit_msgs.msg import WorkspaceParameters
00010 from moveit_msgs.msg import JointConstraint
00011 from moveit_msgs.msg import Constraints
00012 from moveit_msgs.msg import MoveGroupAction
00013 from moveit_msgs.msg import MoveGroupGoal
00014 from moveit_msgs.msg import MoveGroupActionGoal
00015 from moveit_msgs.msg import MotionPlanRequest
00016 from geometry_msgs.msg import Vector3
00017 
00018 
00019 if __name__ == '__main__':
00020     rospy.init_node('moveit_publisher')
00021     client = actionlib.SimpleActionClient('move_group', MoveGroupAction)
00022     client.wait_for_server()
00023     move_group_goal = MoveGroupGoal()
00024 
00025     try:
00026         msg = MotionPlanRequest()
00027 
00028         workspace_parameters = WorkspaceParameters()
00029         workspace_parameters.header.stamp = rospy.Time.now()
00030         workspace_parameters.header.frame_id = "/BASE"
00031         workspace_parameters.min_corner = Vector3(-1.0, -1.0, -1.0)
00032         workspace_parameters.max_corner = Vector3(1.0, 1.0, 1.0)
00033 
00034         start_state = RobotState()
00035 #        start_state.joint_state.header.stamp = rospy.Time.now()
00036         start_state.joint_state.header.frame_id = "/BASE"
00037         start_state.joint_state.name =  ["j1", "j2", "j3", "j4", "j5", "flange"]
00038         start_state.joint_state.position = [-0.2569046038066598, -0.8442722962923348, 1.849082034218144, 0.26825374068443164, -0.04090683809444329, 5.745512865657193]
00039         start_state.joint_state.velocity =  [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
00040 
00041         jc2 = JointConstraint()
00042         jc2.joint_name = "j1"
00043         jc2.position = -1.37353344093
00044         jc2.tolerance_above = 0.0001
00045         jc2.tolerance_below = 0.0001
00046         jc2.weight = 1.0
00047 
00048         jc3 = JointConstraint()
00049         jc3.joint_name = "j2"
00050         jc3.position = -1.45013378543
00051         jc3.tolerance_above = 0.0001
00052         jc3.tolerance_below = 0.0001
00053         jc3.weight = 1.0
00054 
00055         jc4 = JointConstraint()
00056         jc4.joint_name = "j3"
00057         jc4.position = 2.18173030842
00058         jc4.tolerance_above = 0.0001
00059         jc4.tolerance_below = 0.0001
00060         jc4.weight = 1.0
00061 
00062         jc5 = JointConstraint()
00063         jc5.joint_name = "j4"
00064         jc5.position = 1.46043924358
00065         jc5.tolerance_above = 0.0001
00066         jc5.tolerance_below = 0.0001
00067         jc5.weight = 1.0
00068 
00069         jc1 = JointConstraint()
00070         jc1.joint_name = "j5"
00071         jc1.position = 1.25752837976
00072         jc1.tolerance_above = 0.0001
00073         jc1.tolerance_below = 0.0001
00074         jc1.weight = 1.0
00075 
00076         jc0 = JointConstraint()
00077         jc0.joint_name = "flange"
00078         jc0.position = -4.43859335239
00079         jc0.tolerance_above = 0.0001
00080         jc0.tolerance_below = 0.0001
00081         jc0.weight = 1.0
00082 
00083         cons = Constraints()
00084         cons.name = ""
00085         cons.joint_constraints.append(jc2)
00086         cons.joint_constraints.append(jc3)
00087         cons.joint_constraints.append(jc4)
00088         cons.joint_constraints.append(jc5)
00089         cons.joint_constraints.append(jc1)
00090         cons.joint_constraints.append(jc0)
00091 
00092         msg.workspace_parameters = workspace_parameters
00093         msg.start_state = start_state
00094         msg.goal_constraints.append(cons)
00095 
00096         msg.num_planning_attempts = 1
00097         msg.allowed_planning_time = 5.0
00098 
00099         msg.group_name = "manipulator"
00100 
00101         move_group_goal.request = msg
00102 
00103         client.send_goal(move_group_goal)
00104         client.wait_for_result(rospy.Duration.from_sec(5.0))
00105 
00106 
00107     except rospy.ROSInterruptException, e:
00108         print "failed: %s"%e
00109 


rwt_moveit
Author(s): Kazuto Murase
autogenerated on Wed Aug 26 2015 16:45:34