Ejemplo n.º 1
0
    def visualise_spawn_volume(self,
                               task: SupportedTasks,
                               gazebo: scenario.GazeboSimulator,
                               color: Tuple[float, float, float,
                                            float] = (0, 0, 1, 0.8),
                               color_with_height: Tuple[float, float, float,
                                                        float] = (1, 0, 1,
                                                                  0.7)):

        # Insert translucent boxes visible only in simulation with no physical interactions
        models.Box(world=task.world,
                   name="object_spawn_volume",
                   position=task._object_spawn_centre,
                   orientation=(0, 0, 0, 1),
                   size=task._object_spawn_volume,
                   collision=False,
                   visual=True,
                   gui_only=True,
                   static=True,
                   color=color)
        models.Box(world=task.world,
                   name="object_spawn_volume_with_height",
                   position=task._object_spawn_centre,
                   orientation=(0, 0, 0, 1),
                   size=task._object_spawn_volume,
                   collision=False,
                   visual=True,
                   gui_only=True,
                   static=True,
                   color=color_with_height)
        # Execute a paused run to process model insertion
        if not gazebo.run(paused=True):
            raise RuntimeError("Failed to execute a paused Gazebo run")
Ejemplo n.º 2
0
    def add_default_object(self, task: SupportedTasks,
                           gazebo: scenario.GazeboSimulator):

        object_model = None
        if 'box' == task._object_type:
            object_model = models.Box(
                world=task.world,
                position=task._object_spawn_centre,
                orientation=conversions.Quaternion.to_wxyz(
                    task._object_quat_xyzw),
                size=task._object_dimensions,
                mass=task._object_mass,
                collision=task._object_collision,
                visual=task._object_visual,
                static=task._object_static,
                color=task._object_color)
        elif 'sphere' == task._object_type:
            object_model = models.Sphere(
                world=task.world,
                position=task._object_spawn_centre,
                orientation=conversions.Quaternion.to_wxyz(
                    task._object_quat_xyzw),
                radius=task._object_dimensions[0],
                mass=task._object_mass,
                collision=task._object_collision,
                visual=task._object_visual,
                static=task._object_static,
                color=task._object_color)
        elif 'cylinder' == task._object_type:
            object_model = models.Cylinder(
                world=task.world,
                position=task._object_spawn_centre,
                orientation=conversions.Quaternion.to_wxyz(
                    task._object_quat_xyzw),
                radius=task._object_dimensions[0],
                length=task._object_dimensions[1],
                mass=task._object_mass,
                collision=task._object_collision,
                visual=task._object_visual,
                static=task._object_static,
                color=task._object_color)
        task.object_names.append(object_model.name())

        # Execute a paused run to process model insertion
        if not gazebo.run(paused=True):
            raise RuntimeError("Failed to execute a paused Gazebo run")