test_check_state_validity_in_empty_scene.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import sys
4 import rospy
5 import unittest
6 from actionlib import SimpleActionClient
7 import moveit_commander
8 from moveit_msgs.msg import Constraints
9 from moveit_msgs.srv import GetStateValidity
10 
11 
12 class TestCheckStateValidityInEmptyScene(unittest.TestCase):
13 
14  def setUp(self):
15  moveit_commander.roscpp_initialize(sys.argv)
16  self.robot_commander = moveit_commander.RobotCommander()
17  self.group_name = self.robot_commander.get_group_names()[0]
18  self.group_commander = moveit_commander.MoveGroupCommander(self.group_name)
19 
20  self._check_state_validity = rospy.ServiceProxy('/check_state_validity', GetStateValidity)
21 
23  current_robot_state = self.robot_commander.get_current_state()
24 
25  validity_report = self._check_state_validity(current_robot_state, self.group_name, Constraints())
26  self.assertListEqual(validity_report.contacts, [], "In the default_robot_state, the robot should not collide with itself")
27 
28 
30  current_robot_state = self.robot_commander.get_current_state()
31 
32  # force a colliding state with the Fanuc M-10iA
33  current_robot_state.joint_state.position = list(current_robot_state.joint_state.position)
34  current_robot_state.joint_state.position[current_robot_state.joint_state.name.index("joint_3")] = -2
35 
36  validity_report = self._check_state_validity(current_robot_state, self.group_name, Constraints())
37 
38  self.assertNotEqual(len(validity_report.contacts), 0, "When the robot collides with itself, it should have some contacts (with itself)")
39 
40 
41 if __name__ == '__main__':
42  import rostest
43  rospy.init_node('check_state_validity_in_empty_scene')
44  rostest.rosrun('moveit_ros_move_group', 'test_check_state_validity_in_empty_scene', TestCheckStateValidityInEmptyScene)


move_group
Author(s): Ioan Sucan , Sachin Chitta
autogenerated on Sun Oct 18 2020 13:18:14