Esempio n. 1
0
 def test_model_directives(self):
     model_dir = os.path.dirname(
         FindResourceOrThrow("drake/multibody/parsing/test/"
                             "process_model_directives_test/package.xml"))
     plant = MultibodyPlant(time_step=0.01)
     parser = Parser(plant=plant)
     parser.package_map().PopulateFromFolder(model_dir)
     directives_file = model_dir + "/add_scoped_top.yaml"
     directives = LoadModelDirectives(directives_file)
     added_models = ProcessModelDirectives(directives=directives,
                                           plant=plant,
                                           parser=parser)
     # Check for an instance.
     model_names = [model.model_name for model in added_models]
     self.assertIn("extra_model", model_names)
     plant.GetModelInstanceByName("extra_model")
     # Test that other bound symbols exist.
     ModelInstanceInfo.model_name
     ModelInstanceInfo.model_path
     ModelInstanceInfo.parent_frame_name
     ModelInstanceInfo.child_frame_name
     ModelInstanceInfo.X_PC
     ModelInstanceInfo.model_instance
     AddFrame.name
     AddFrame.X_PF
     frame = GetScopedFrameByName(plant, "world")
     self.assertIsNotNone(GetScopedFrameName(plant, frame))
Esempio n. 2
0
def MustardExampleSystem():
    builder = DiagramBuilder()

    # Create the physics engine + scene graph.
    plant, scene_graph = AddMultibodyPlantSceneGraph(builder, time_step=0.0)
    parser = Parser(plant)
    AddPackagePaths(parser)
    ProcessModelDirectives(
        LoadModelDirectives(FindResource("models/mustard_w_cameras.yaml")),
        plant, parser)

    plant.Finalize()

    # Add a visualizer just to help us see the object.
    use_meshcat = False
    if use_meshcat:
        meshcat = builder.AddSystem(MeshcatVisualizer(scene_graph))
        builder.Connect(scene_graph.get_query_output_port(),
                        meshcat.get_geometry_query_input_port())

    AddRgbdSensors(builder, plant, scene_graph)

    diagram = builder.Build()
    diagram.set_name("depth_camera_demo_system")
    return diagram
Esempio n. 3
0
 def test_process_model_directives(self):
     """Check the Process... overload using a Parser."""
     (plant, parser, directives) = self._make_plant_parser_directives()
     added_models = ProcessModelDirectives(directives=directives,
                                           parser=parser)
     model_names = [model.model_name for model in added_models]
     self.assertIn("extra_model", model_names)
     plant.GetModelInstanceByName("extra_model")
Esempio n. 4
0
 def test_model_directives(self):
     model_dir = os.path.dirname(FindResourceOrThrow(
         "drake/multibody/parsing/test/"
         "process_model_directives_test/package.xml"))
     plant = MultibodyPlant(time_step=0.01)
     parser = Parser(plant=plant)
     parser.package_map().PopulateFromFolder(model_dir)
     directives_file = model_dir + "/add_scoped_top.yaml"
     directives = LoadModelDirectives(directives_file)
     added_models = ProcessModelDirectives(
         directives=directives, plant=plant, parser=parser)
     # Check for an instance.
     model_names = [model.model_name for model in added_models]
     self.assertIn("extra_model", model_names)
     plant.GetModelInstanceByName("extra_model")