Skip to content

Commit 45ca1a6

Browse files
committed
TestModifyPlanningScene
1 parent b318c3c commit 45ca1a6

File tree

3 files changed

+68
-8
lines changed

3 files changed

+68
-8
lines changed

core/python/test/rostest_mps.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#! /usr/bin/env python
2+
3+
from __future__ import print_function
4+
import unittest
5+
import rostest
6+
from moveit_commander.roscpp_initializer import roscpp_initialize
7+
from moveit_commander import PlanningSceneInterface
8+
from moveit.task_constructor import core, stages
9+
from geometry_msgs.msg import PoseStamped
10+
11+
12+
def make_pose(x, y, z):
13+
pose = PoseStamped()
14+
pose.header.frame_id = "base_link"
15+
pose.pose.position.x = x
16+
pose.pose.position.y = y
17+
pose.pose.position.z = z
18+
pose.pose.orientation.w = 1.0
19+
return pose
20+
21+
22+
class TestModifyPlanningScene(unittest.TestCase):
23+
PLANNING_GROUP = "manipulator"
24+
25+
def setUp(self):
26+
super(TestModifyPlanningScene, self).setUp()
27+
self.psi = PlanningSceneInterface(synchronous=True)
28+
# insert a box to collide with
29+
self.psi.add_box("box", make_pose(0.8, 0.25, 1.25), [0.2, 0.2, 0.2])
30+
31+
# colliding motion
32+
move = stages.MoveRelative("move", core.JointInterpolationPlanner())
33+
move.group = self.PLANNING_GROUP
34+
move.setDirection({"joint_1": 0.3})
35+
36+
self.task = task = core.Task()
37+
task.add(stages.CurrentState("current"), move)
38+
39+
def test_collision(self):
40+
self.assertFalse(self.task.plan())
41+
42+
def test_allow_collision_list(self):
43+
mps = stages.ModifyPlanningScene("mps")
44+
mps.allowCollisions("box", ["link_4", "link_5", "link_6"], True)
45+
self.task.insert(mps, 1)
46+
self.assertTrue(self.task.plan())
47+
48+
def test_allow_collision_all(self):
49+
# insert an extra collision object that is unknown to ACM
50+
self.psi.add_box("block", make_pose(0.8, 0.55, 1.25), [0.2, 0.2, 0.2])
51+
# attach box to end effector
52+
self.psi.attach_box("link_6", "box")
53+
mps = stages.ModifyPlanningScene("mps")
54+
self.assertFalse(self.task.plan())
55+
56+
# allow all collisions for attached "box" object
57+
mps.allowCollisions("box", True)
58+
self.task.insert(mps, 1)
59+
self.assertTrue(self.task.plan())
60+
# restore original state
61+
self.psi.remove_attached_object("link_6", "box")
62+
self.psi.remove_world_object("block")
63+
64+
65+
if __name__ == "__main__":
66+
roscpp_initialize("test_mtc")
67+
rostest.rosrun("mtc", "mps", TestModifyPlanningScene)

core/python/test/rostest_mtc.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414
class Test(unittest.TestCase):
1515
PLANNING_GROUP = "manipulator"
1616

17-
@classmethod
18-
def setUpClass(self):
19-
pass
20-
21-
@classmethod
22-
def tearDown(self):
23-
pass
24-
2517
def test_MoveAndExecute(self):
2618
moveRel = stages.MoveRelative("moveRel", core.JointInterpolationPlanner())
2719
moveRel.group = self.PLANNING_GROUP

core/python/test/rostest_mtc.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<launch>
22
<include file="$(find moveit_resources_fanuc_moveit_config)/launch/test_environment.launch" />
33
<test pkg="moveit_task_constructor_core" type="rostest_mtc.py" test-name="rostest_mtc" time-limit="60" args="" />
4+
<test pkg="moveit_task_constructor_core" type="rostest_mps.py" test-name="rostest_mps" time-limit="60" args="" />
45
<test pkg="moveit_task_constructor_core" type="rostest_trampoline.py" test-name="rostest_trampoline" time-limit="60" args="" />
56
</launch>

0 commit comments

Comments
 (0)