commands
类:
| 名称 | 描述 |
|---|---|
PositionDebugVisualizerConfig |
Defines the configuration for the debug visualizer. |
PositionCommandManager |
Generates a position + heading command from uniform distribution. |
PositionDebugVisualizerConfig
Bases: TypedDict
Defines the configuration for the debug visualizer.
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
envs_idx |
list[int]
|
The indices of the environments to visualize. If None, all environments will be visualized. |
z_offset |
float
|
The vertical offset of the debug arrows above the robot / target. |
arrow_radius |
float
|
The radius of the arrow shaft. |
arrow_scale |
float
|
Scale factor for the position-error arrow length. |
heading_arrow_len |
float
|
Length of the heading direction arrow. |
commanded_color |
tuple[float, float, float, float]
|
The color of the commanded position arrow. |
heading_color |
tuple[float, float, float, float]
|
The color of the commanded heading arrow. |
envs_idx
instance-attribute
envs_idx: list[int]
The indices of the environments to visualize. If None, all environments will be visualized.
z_offset
instance-attribute
z_offset: float
The vertical offset of the debug arrows above the robot / target.
arrow_radius
instance-attribute
arrow_radius: float
The radius of the arrow shaft.
arrow_scale
instance-attribute
arrow_scale: float
Scale factor for the position-error arrow length.
heading_arrow_len
instance-attribute
heading_arrow_len: float
Length of the heading direction arrow.
commanded_color
instance-attribute
commanded_color: tuple[float, float, float, float]
The color of the commanded position arrow.
heading_color
instance-attribute
heading_color: tuple[float, float, float, float]
The color of the commanded heading 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 + heading command from uniform distribution. The command comprises a 3-D position target and a heading target.
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 - Heading: target yaw angle in radians
The .command property returns a body-frame tensor of shape (num_envs, 4):
- [:, 0:3] position error rotated into yaw-only body frame
- [:, 3] heading error (target heading - current heading), wrapped to [-pi, pi]
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
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
GenesisEnv
|
The environment to control |
必需 |
|
PositionCommandRange
|
The ranges of position & heading |
必需 |
|
float
|
The time interval between changing the command |
5.0
|
|
bool
|
Enable the debug arrow visualization |
False
|
|
PositionDebugVisualizerConfig
|
The configuration for the debug visualizer |
DEFAULT_VISUALIZER_CONFIG
|
Example::
class MyEnv(GenesisEnv):
def config(self):
self.position_command = PositionCommandManager(
self,
range={
"pos_x": (-2.0, 2.0),
"pos_y": (-2.0, 2.0),
"pos_z": (0.5, 1.5),
"heading": (-3.14, 3.14),
},
)
方法:
| 名称 | 描述 |
|---|---|
build |
Build the position command manager |
step |
Render the command arrows |
use_gamepad |
Use a connected gamepad to control the command. |
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
command |
Tensor
|
The desired command in yaw-only body frame. Shape is (num_envs, 4). |
command
property
command: Tensor
The desired command in yaw-only body frame. Shape is (num_envs, 4).
Columns 0-3: [pos_x, pos_y, pos_z, heading_error] all in body frame.
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, heading_axis: int = 3)
Use a connected gamepad to control the command.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
Gamepad
|
The gamepad to use. |
必需 |
|
int
|
Map this gamepad axis index to the position in the x-direction. |
0
|
|
int
|
Map this gamepad axis index to the position in the y-direction. |
1
|
|
int
|
Map this gamepad axis index to the position in the z-direction. |
2
|
|
int
|
Map this gamepad axis index to the heading. |
3
|