dual_arm_robot_state_update.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import unittest
4 import rospy
5 import rostest
6 import os
7 
8 import moveit_commander
9 
10 from moveit_msgs.msg import MoveItErrorCodes, RobotTrajectory
11 
12 
13 class RobotStateUpdateTest(unittest.TestCase):
14  @classmethod
15  def setUpClass(self):
16  self.dual_arm_group = moveit_commander.MoveGroupCommander("dual_arm")
17  self.panda_1_group = moveit_commander.MoveGroupCommander("panda_1")
18  self.panda_2_group = moveit_commander.MoveGroupCommander("panda_2")
19 
20  @classmethod
21  def tearDown(self):
22  pass
23 
24  def plan(self, target):
25  self.dual_arm_group.set_joint_value_target(target)
26  return self.dual_arm_group.plan()
27 
28  def test(self):
29  panda_1_pose = self.panda_1_group.get_current_pose("panda_1_link8")
30  panda_1_pose.pose.position.z -= 0.05
31  panda_1_pose.pose.position.x += 0.05
32 
33  panda_2_pose = self.panda_2_group.get_current_pose("panda_2_link8")
34  panda_2_pose.pose.position.z -= 0.05
35  panda_2_pose.pose.position.x -= 0.05
36  self.dual_arm_group.set_start_state_to_current_state()
37  self.dual_arm_group.set_pose_target(
38  panda_1_pose, end_effector_link="panda_1_link8"
39  )
40  self.dual_arm_group.set_pose_target(
41  panda_2_pose, end_effector_link="panda_2_link8"
42  )
43 
44  result = self.dual_arm_group.plan()
45  if isinstance(result, RobotTrajectory):
46  self.assertTrue(result.joint_trajectory.joint_names)
47  else:
48  success, plan, planning_time, error = result
49  self.assertTrue(error.val == MoveItErrorCodes.SUCCESS)
50 
51 
52 if __name__ == "__main__":
53  PKGNAME = "moveit_ros_planning_interface"
54  NODENAME = "moveit_test_robot_state_update"
55  rospy.init_node(NODENAME)
56  rostest.rosrun(PKGNAME, NODENAME, RobotStateUpdateTest)
57 
58  # suppress cleanup segfault in ROS < Kinetic
59  os._exit(0)
dual_arm_robot_state_update.RobotStateUpdateTest.dual_arm_group
dual_arm_group
Definition: dual_arm_robot_state_update.py:16
dual_arm_robot_state_update.RobotStateUpdateTest.setUpClass
def setUpClass(self)
Definition: dual_arm_robot_state_update.py:15
dual_arm_robot_state_update.RobotStateUpdateTest
Definition: dual_arm_robot_state_update.py:13
dual_arm_robot_state_update.RobotStateUpdateTest.tearDown
def tearDown(self)
Definition: dual_arm_robot_state_update.py:21
dual_arm_robot_state_update.RobotStateUpdateTest.plan
def plan(self, target)
Definition: dual_arm_robot_state_update.py:24
dual_arm_robot_state_update.RobotStateUpdateTest.panda_2_group
panda_2_group
Definition: dual_arm_robot_state_update.py:18
dual_arm_robot_state_update.RobotStateUpdateTest.panda_1_group
panda_1_group
Definition: dual_arm_robot_state_update.py:17
dual_arm_robot_state_update.RobotStateUpdateTest.test
def test(self)
Definition: dual_arm_robot_state_update.py:28


planning_interface
Author(s): Ioan Sucan
autogenerated on Thu Nov 21 2024 03:25:11