Skip to content

commands

Classes:

Name Description
PositionDebugVisualizerConfig

Defines the configuration for the debug visualizer.

PositionCommandManager

Generates a position command from uniform distribution.

PositionDebugVisualizerConfig

Bases: TypedDict

Defines the configuration for the debug visualizer.

Attributes:

Name Type Description
envs_idx list[int]

The indices of the environments to visualize. If None, all environments will be visualized.

sphere_offset float

The vertical offset of the debug arrows from the top of the robot

sphere_radius float

The radius of the shaft of the debug arrows

commanded_color tuple[float, float, float, float]

The color of the commanded velocity arrow

envs_idx instance-attribute

envs_idx: list[int]

The indices of the environments to visualize. If None, all environments will be visualized.

sphere_offset instance-attribute

sphere_offset: float

The vertical offset of the debug arrows from the top of the robot

sphere_radius instance-attribute

sphere_radius: float

The radius of the shaft of the debug arrows

commanded_color instance-attribute

commanded_color: tuple[float, float, float, float]

The color of the commanded velocity arrow

PositionCommandManager

PositionCommandManager(env: GenesisEnv, range: PositionCommandRange, resample_time_sec: float = 5.0, debug_visualizer: bool = False, debug_visualizer_cfg: PositionDebugVisualizerConfig = DEFAULT_VISUALIZER_CONFIG)

Bases: CommandManager

Generates a position command from uniform distribution. The command comprises of a linear velocity in x and y direction and an angular velocity around the z-axis.

IMPORTANT: The position commands are interpreted as world-relative coordinates: - X-axis: x coordinate of the target position - Y-axis: y coordinate of the target position - Z-axis: z coordinate of the target position

Debug visualization:

If `debug_visualizer` is set to True, a target sphere is rendered above
the commanded position.

Visual meaning:

- GREEN: Commanded position for the robot in the world frame

Parameters:

Name Type Description Default

env

GenesisEnv

The environment to control

required

range

PositionCommandRange

The ranges of linear & angular velocities

required

resample_time_sec

float

The time interval between changing the command

5.0

debug_visualizer

bool

Enable the debug arrow visualization

False

debug_visualizer_cfg

PositionDebugVisualizerConfig

The configuration for the debug visualizer

DEFAULT_VISUALIZER_CONFIG

Example::

class MyEnv(GenesisEnv):
    def config(self):
        # Create a velocity command manager
        self.command_manager = PositionCommandManager(
            self,
            visualize=True,
            range = {
                "lin_vel_x_range": (-1.0, 1.0),
                "lin_vel_y_range": (-1.0, 1.0),
                "ang_vel_z_range": (-0.5, 0.5),
            }
        )

        RewardManager(
            self,
            logging_enabled=True,
            cfg={
                "tracking_lin_vel": {
                    "weight": 1.0,
                    "fn": rewards.command_tracking_lin_vel,
                    "params": {
                        "vel_cmd_manager": self.velocity_command,
                    },
                },
                "tracking_ang_vel": {
                    "weight": 1.0,
                    "fn": rewards.command_tracking_ang_vel,
                    "params": {
                        "vel_cmd_manager": self.velocity_command,
                    },
                },
                # ... other rewards ...
            },
        )

        # Observations
        ObservationManager(
            self,
            cfg={
                "velocity_cmd": {"fn": self.velocity_command.observation},
                # ... other observations ...
            },
        )

Methods:

Name Description
resample_command

Overwrites commands for environments that should be standing still.

build

Build the position command manager

step

Render the command arrows

use_gamepad

Use a connected gamepad to control the command.

Attributes:

Name Type Description
command Tensor

The desired command value. Shape is (num_envs, num_ranges).

command property

command: Tensor

The desired command value. Shape is (num_envs, num_ranges).

resample_command

resample_command(env_ids: list[int])

Overwrites commands for environments that should be standing still.

build

build()

Build the position command manager

step

step()

Render the command arrows

use_gamepad

use_gamepad(gamepad: Gamepad, pos_x_axis: int = 0, pos_y_axis: int = 1, pos_z_axis: int = 2)

Use a connected gamepad to control the command.

Parameters:

Name Type Description Default

gamepad

Gamepad

The gamepad to use.

required

pos_x_axis

int

Map this gamepad axis index to the position in the x-direction.

0

pos_y_axis

int

Map this gamepad axis index to the position in the y-direction.

1

pos_z_axis

int

Map this gamepad axis index to the position in the z-direction.

2