Exemplo n.º 1
0
 def get_model_file(self, fuel=True) -> str:
     if fuel:
         return scenario_gazebo.get_model_file_from_fuel(
             "https://fuel.ignitionrobotics.org/1.0/AndrejOrsula/models/panda"
         )
     else:
         return "panda"
def insert_cube_in_operating_area(
        world: scenario_gazebo.World) -> scenario_gazebo.Model:

    # Insert objects from Fuel
    uri = lambda org, name: f"https://fuel.ignitionrobotics.org/{org}/models/{name}"

    # Download the cube SDF file
    cube_sdf = scenario_gazebo.get_model_file_from_fuel(uri=uri(
        org="openrobotics", name="wood cube 5cm"),
                                                        use_cache=False)

    # Sample a random position
    random_position = np.random.uniform(low=[0.2, -0.3, 1.01],
                                        high=[0.4, 0.3, 1.01])

    # Get a unique name
    model_name = gym_ignition.utils.scenario.get_unique_model_name(
        world=world, model_name="cube")

    # Insert the model
    assert world.insert_model(
        cube_sdf, scenario_core.Pose(random_position, [1., 0, 0, 0]),
        model_name)

    # Return the model
    return world.get_model(model_name=model_name)
def insert_table(world: scenario_gazebo.World) -> scenario_gazebo.Model:

    # Insert objects from Fuel
    uri = lambda org, name: f"https://fuel.ignitionrobotics.org/{org}/models/{name}"

    # Download the cube SDF file
    bucket_sdf = scenario_gazebo.get_model_file_from_fuel(
        uri=uri(org="OpenRobotics", name="Table"), use_cache=False
    )

    # Assign a custom name to the model
    model_name = "table"

    # Insert the model
    assert world.insert_model(bucket_sdf, scenario_core.Pose_identity(), model_name)

    # Return the model
    return world.get_model(model_name=model_name)
def insert_bucket(world: scenario_gazebo.World) -> scenario_gazebo.Model:

    # Insert objects from Fuel
    uri = lambda org, name: f"https://fuel.ignitionrobotics.org/{org}/models/{name}"

    # Download the cube SDF file
    bucket_sdf = scenario_gazebo.get_model_file_from_fuel(uri=uri(
        org="GoogleResearch",
        name="Threshold_Basket_Natural_Finish_Fabric_Liner_Small"),
                                                          use_cache=False)

    # Assign a custom name to the model
    model_name = "bucket"

    # Insert the model
    assert world.insert_model(
        bucket_sdf, scenario_core.Pose([0.68, 0, 1.02], [1., 0, 0, 1]),
        model_name)

    # Return the model
    return world.get_model(model_name=model_name)
Exemplo n.º 5
0
def test_download_model_from_fuel(gazebo: scenario.GazeboSimulator):

    assert gazebo.initialize()

    # Get the default world
    world = gazebo.get_world()

    # Download a model from Fuel (testing a name with spaces)
    model_name = "Electrical Box"
    model_sdf = scenario.get_model_file_from_fuel(
        f"https://fuel.ignitionrobotics.org/openrobotics/models/{model_name}", False
    )
    assert model_sdf

    assert world.insert_model(model_sdf, core.Pose_identity())
    assert model_name in world.model_names()

    # Insert another model changing its name
    other_model_name = "my_box"
    other_model_pose = core.Pose([3.0, 0.0, 0.0], [1.0, 0, 0, 0])
    assert world.insert_model(model_sdf, other_model_pose, other_model_name)
    assert other_model_name in world.model_names()

    assert gazebo.run()
Exemplo n.º 6
0
def point_on_table():
    return center + np.random.rand(3) * 2 * half_extent - half_extent


urls = [
    "https://fuel.ignitionrobotics.org/openrobotics/models/wood cube 5cm",
    "https://fuel.ignitionrobotics.org/openrobotics/models/wood cube 5cm",
    "https://fuel.ignitionrobotics.org/1.0/chapulina/models/Cordless drill with spaces",
    "https://fuel.ignitionrobotics.org/1.0/GoogleResearch/models/Vtech_Roll_Learn_Turtle",
    "https://fuel.ignitionrobotics.org/1.0/GoogleResearch/models/Threshold_Porcelain_Teapot_White",
]

item_list = [
    scenario_gazebo.get_model_file_from_fuel(
        uri=url,
        use_cache=False,
    ) for url in urls
]


def spawn_cube(position, velocity=np.array((0, 0, 3)), idx=0):
    # Get a unique name
    model_name = gym_ignition.utils.scenario.get_unique_model_name(
        world=world, model_name="cube")

    model = item_list[idx % len(urls)]

    # Insert the model
    assert world.insert_model(model,
                              scenario_core.Pose(position, [1.0, 0, 0, 0]),
                              model_name)