|
7 | 7 | ) # You could replace this with numpy's regular assert for better compatibility |
8 | 8 |
|
9 | 9 | from semantic_digital_twin.reasoning.world_reasoner import WorldReasoner |
10 | | -from semantic_digital_twin.testing import * |
| 10 | +from semantic_digital_twin.robots.minimal_robot import MinimalRobot |
| 11 | +from semantic_digital_twin.robots.pr2 import PR2 |
11 | 12 | from semantic_digital_twin.semantic_annotations.semantic_annotations import * |
| 13 | +from semantic_digital_twin.testing import * |
| 14 | +from semantic_digital_twin.world_description.world_entity import ( |
| 15 | + KinematicStructureEntity, |
| 16 | +) |
12 | 17 |
|
13 | 18 | try: |
14 | 19 | from ripple_down_rules.user_interface.gui import RDRCaseViewer |
@@ -131,10 +136,7 @@ def test_aggregate_bodies(kitchen_world): |
131 | 136 |
|
132 | 137 | def test_handle_semantic_annotation_eql(apartment_world): |
133 | 138 | with rule_mode(): |
134 | | - body = let( |
135 | | - type_=Body, |
136 | | - domain=apartment_world.bodies |
137 | | - ) |
| 139 | + body = let(type_=Body, domain=apartment_world.bodies) |
138 | 140 | query = infer(entity(Handle(body=body), in_("handle", body.name.name.lower()))) |
139 | 141 |
|
140 | 142 | handles = list(query.evaluate()) |
@@ -251,3 +253,26 @@ def test_semantic_annotation_serde_multiple(apartment_world): |
251 | 253 | assert door == door_de2 |
252 | 254 | assert type(door.handle) == type(door_de2.handle) |
253 | 255 | assert type(door.body) == type(door_de2.body) |
| 256 | + |
| 257 | + |
| 258 | +def test_minimal_robot_annotation(pr2_world): |
| 259 | + urdf_dir = os.path.join( |
| 260 | + os.path.dirname(os.path.abspath(__file__)), "..", "..", "resources", "urdf" |
| 261 | + ) |
| 262 | + pr2 = os.path.join(urdf_dir, "pr2_kinematic_tree.urdf") |
| 263 | + pr2_parser = URDFParser.from_file(file_path=pr2) |
| 264 | + world_with_pr2 = pr2_parser.parse() |
| 265 | + with world_with_pr2.modify_world(): |
| 266 | + MinimalRobot.from_world(world_with_pr2) |
| 267 | + pr2_root = world_with_pr2.root |
| 268 | + localization_body = Body(name=PrefixedName("odom_combined")) |
| 269 | + world_with_pr2.add_kinematic_structure_entity(localization_body) |
| 270 | + c_root_bf = OmniDrive.create_with_dofs( |
| 271 | + parent=localization_body, child=pr2_root, world=world_with_pr2 |
| 272 | + ) |
| 273 | + world_with_pr2.add_connection(c_root_bf) |
| 274 | + |
| 275 | + robot = world_with_pr2.get_semantic_annotations_by_type(MinimalRobot)[0] |
| 276 | + pr2 = PR2.from_world(pr2_world) |
| 277 | + assert len(robot.bodies) == len(pr2.bodies) |
| 278 | + assert len(robot.connections) == len(pr2.connections) |
0 commit comments