7from test_moveit.core.collision_detection
import CollisionRequest, CollisionResult
8from test_moveit.core.planning_scene
import PlanningScene
9from test_moveit.core.robot_model
import RobotModel
10from test_moveit.core.robot_state
import RobotState
12dir_path = os.path.dirname(os.path.realpath(__file__))
13URDF_FILE =
"{}/fixtures/panda.urdf".format(dir_path)
14SRDF_FILE =
"{}/fixtures/panda.srdf".format(dir_path)
20 """Helper function that returns a RobotModel instance."""
21 return RobotModel(urdf_xml_path=URDF_FILE, srdf_xml_path=SRDF_FILE)
26 Run call() in a loop for duration seconds and count how often another Python thread gets to run meanwhile.
28 The switch interval is raised far above duration, so the interpreter does not hand the GIL to the other
29 thread on its own: the other thread only runs while call() releases the GIL.
31 stop = threading.Event()
36 while not stop.is_set():
40 old_interval = sys.getswitchinterval()
41 sys.setswitchinterval(30.0)
42 ticker = threading.Thread(target=tick, daemon=
True)
45 deadline = time.monotonic() + duration
46 while time.monotonic() < deadline:
51 sys.setswitchinterval(old_interval)
57 """The collision checks release the GIL, so other Python threads keep running during bulk checks."""
66 self.
state.set_to_default_values()
73 self.assertGreater(ticks, 10)
83 lambda: self.
scene.is_state_colliding(self.
state, GROUP)
88 lambda: self.
scene.check_collision(CollisionRequest(), CollisionResult())
93 lambda: self.
scene.check_collision(
94 CollisionRequest(), CollisionResult(), self.
state
100 lambda: self.
scene.check_self_collision(
101 CollisionRequest(), CollisionResult(), self.
state
106if __name__ ==
"__main__":
assert_releases_gil(self, call)
test_is_state_valid(self)
test_is_state_colliding_current_state(self)
test_check_collision(self)
test_check_self_collision_state(self)
test_is_state_colliding(self)
test_check_collision_state(self)
count_ticks_while(call, duration=0.5)