mdp
模块:
| 名称 | 描述 |
|---|---|
actions |
|
commands |
|
rewards |
|
类:
| 名称 | 描述 |
|---|---|
FlightActionMapper |
Map batched normalized actions into controller targets, wrench, or RPM. |
FlightMappingConfig |
Mapping-range configuration for normalized action scaling. |
Mixer |
Map batched thrust and moment demands to rotor speed commands. |
VehicleParams |
Generic multi-rotor vehicle physics. |
RotorDynamics |
Batched motor dynamics model for rotor thrust and torque. |
FlightControlActionManager |
Base class for Genesis flight action managers. |
PositionDebugVisualizerConfig |
Defines the configuration for the debug visualizer. |
PositionCommandManager |
Generates a position + heading command from uniform distribution. |
函数:
| 名称 | 描述 |
|---|---|
wrap_to_pi |
Wraps input angles (in radians) to the range :math: |
lin_vel_l2 |
Penalize base linear velocity using L2 squared kernel. |
ang_vel_l2 |
Penalize base angular velocity using L2 squared kernel. |
pos_error_l2 |
Penalize asset pos from its target pos using L2 squared kernel. |
pos_error_tanh |
Penalize asset pos from its target pos using tanh kernel. |
yaw_error_l2 |
Penalize heading error from target heading using L2 squared kernel. |
yaw_error_tanh |
Penalize heading error from target heading using tanh kernel. |
FlightActionMapper
FlightActionMapper(control_mode: str, params: VehicleParams = VehicleParams(), mapping: FlightMappingConfig | None = None, control_mask: dict | None = None, num_envs: int = 1, device=None, *, backend: BackendName | None = None, xp: ModuleType | None = None)
Map batched normalized actions into controller targets, wrench, or RPM.
Initialize the batched action mapper and backend namespace.
方法:
| 名称 | 描述 |
|---|---|
randomize |
Randomize. |
action_to_collective_acc |
Action to collective acc. |
collective_acc_to_thrust |
Collective acc to thrust. |
action_to_collective_thrust |
Action to collective thrust. |
decode_action |
Decode normalized batched action into a runtime-neutral control request. |
map_action |
Resolve normalized batched action into simulation rotor RPM commands. |
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
requires_controller |
bool
|
Requires controller. |
requires_controller
property
requires_controller: bool
Requires controller.
randomize
randomize(env_ids=None, randomization: dict | None = None)
Randomize.
action_to_collective_acc
action_to_collective_acc(action: ArrayLike, mixer) -> ArrayLike
Action to collective acc.
collective_acc_to_thrust
collective_acc_to_thrust(collective_acc: ArrayLike) -> ArrayLike
Collective acc to thrust.
action_to_collective_thrust
action_to_collective_thrust(action: ArrayLike, mixer) -> ArrayLike
Action to collective thrust.
decode_action
decode_action(action: ArrayLike, mixer, *, state: ControllerState | None = None) -> FlightMapping
Decode normalized batched action into a runtime-neutral control request.
map_action
map_action(action: ArrayLike, mixer, *, state: ControllerState | None = None, flight_controller: ControllerBase | None = None) -> FlightMapping
Resolve normalized batched action into simulation rotor RPM commands.
FlightMappingConfig
dataclass
FlightMappingConfig(velocity_range: tuple[float, float, float] | None = None, acceleration_range: tuple[float, float, float] | None = None, attitude_range: tuple[float, float, float] | None = None, body_rate_range: tuple[float, float, float] | None = (2.0, 2.0, 2.0), rel_rotation: bool = False, rotation_step_len: float | None = None)
Mapping-range configuration for normalized action scaling.
方法:
| 名称 | 描述 |
|---|---|
from_params |
Build mapping ranges from vehicle parameters. |
resolve |
Resolve config overrides into concrete mapping ranges. |
from_params
classmethod
from_params(params: VehicleParams) -> FlightMappingConfig
Build mapping ranges from vehicle parameters.
resolve
resolve(params: VehicleParams) -> FlightMappingConfig
Resolve config overrides into concrete mapping ranges.
Mixer
Mixer(params: VehicleParams = VehicleParams(), num_envs: int = 1, device=None, *, backend: BackendName | None = None, xp: ModuleType | None = None, allocation_mode: Literal['pinv', 'saturation'] = 'pinv')
Map batched thrust and moment demands to rotor speed commands.
The default "pinv" allocator applies direct pseudo-inverse allocation.
"saturation" enables a staged trim strategy: roll/pitch authority is
trimmed first if needed, and yaw authority is allocated from the remaining
rotor-speed margin.
Initialize the mixer matrix and backend namespace.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
VehicleParams
|
Vehicle parameters used to build the allocation matrix. |
VehicleParams()
|
|
int
|
Number of parallel environments represented by the batch. |
1
|
|
Optional backend device, mainly used by Torch. |
None
|
|
|
BackendName | None
|
Explicit Array API backend. If omitted, NumPy is used when
|
None
|
|
ModuleType | None
|
Pre-resolved Array API namespace. Overrides |
None
|
|
Literal['pinv', 'saturation']
|
|
'pinv'
|
方法:
| 名称 | 描述 |
|---|---|
randomize |
Randomize mixer parameters for selected environments. |
calculate_rotor_commands |
Allocate |
randomize
randomize(env_ids=None, randomization: dict | None = None)
Randomize mixer parameters for selected environments.
calculate_rotor_commands
calculate_rotor_commands(control: ArrayLike) -> ArrayLike
Allocate [thrust, roll, pitch, yaw] controls to rotor RPM.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
ArrayLike
|
Batched control array with shape |
必需 |
返回:
| 类型 | 描述 |
|---|---|
ArrayLike
|
Batched rotor speed magnitudes with shape |
VehicleParams
dataclass
VehicleParams(*, rho: float = 1.184, g: float = 9.81, sim_dt: float = 0.01, step_dt: float = 0.01, randomization: dict[str, dict[str, tuple[float, float]]] = dict(), mass: float = 2.1, inertia: list = (lambda: [[0.015, 0.0, 0.0], [0.0, 0.0348, 0.0], [0.0, 0.0, 0.042503]])(), x: float = 0.0952, y: float = 0.114423, h: float = -0.0125, alpha: float = math.radians(8.0), diameter: float = 0.476, Cdx: float = 0.5, r_p: float = 0.0775, Ct: float = 0.666, Cq: float = 0.0716, theta0: float = math.radians(14.6), thetaTip: float = math.radians(6.8), theta1: float = math.nan, lock: float = 0.6051, cT: float = math.nan, cM: float = math.nan, spin_dir: tuple[float, float, float, float] = (1.0, 1.0, -1.0, -1.0), tau_f: float = 0.01, tau_m: float = 0.05, max_rpm: float = 10000.0, init_rpm: float = math.nan, rotor_rpm_rate_limit: float = 50000.0, tau_up: float = math.nan, tau_down: float = math.nan, mpc_xy_vel_max: float = 12.0, mpc_z_vel_max_up: float = 3.0, mpc_z_vel_max_dn: float = 1.5, mpc_acc_hor_max: float = 5.0, mpc_acc_up_max: float = 4.0, mpc_acc_down_max: float = 3.0, mpc_man_tilt_max: float = math.radians(35.0), mc_rollrate_max: float = math.radians(220.0), mc_pitchrate_max: float = math.radians(220.0), mc_yawrate_max: float = math.radians(200.0))
Generic multi-rotor vehicle physics.
The base class carries LAV2-compatible defaults for the shared multi-rotor
parameters so that VehicleParams() continues to produce a working
LAV2-flavoured flight configuration (without track / airframe specifics).
Concrete subclasses add robot-specific locomotion and geometry:
TrackVehicleParams— LAV2: tracked ground locomotion + ducted airframeTiltWheelVehicleParams— ATMO: tilting arms + two side motors whose belt transmissions synchronize four wheel shells
方法:
| 名称 | 描述 |
|---|---|
__post_init__ |
Calculate derived parameters and resolve default sentinels. |
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
rho |
float
|
Air density (kg/m³). |
g |
float
|
Gravitational acceleration (m/s²). |
sim_dt |
float
|
Simulation time step (s). |
step_dt |
float
|
Control time step (s). |
randomization |
dict[str, dict[str, tuple[float, float]]]
|
Per-component parameter-randomisation scale ranges. |
mass |
float
|
Total vehicle mass (kg — LAV2 default; override for other robots). |
inertia |
list
|
Inertia matrix (kg*m^2). |
x |
float
|
Arm length in x — rotor moment-arm for roll (m). |
y |
float
|
Arm length in y — rotor moment-arm for pitch (m). |
h |
float
|
CG height below rotor plane (m, negative = below). |
alpha |
float
|
Duct / rotor cant angle about y-axis (rad — 0 for flat rotors like ATMO). |
diameter |
float
|
Overall vehicle diameter (m). |
Cdx |
float
|
Body drag coefficient. |
r_p |
float
|
Propeller radius (m). |
Ct |
float
|
Thrust coefficient (blade-element). |
Cq |
float
|
Torque coefficient (blade-element). |
theta0 |
float
|
Blade root pitch angle (rad). |
thetaTip |
float
|
Blade tip pitch angle (rad). |
theta1 |
float
|
Blade twist (rad), defaults to theta0 - thetaTip. |
lock |
float
|
Lock number. |
cT |
float
|
Thrust coefficient T = cT·rpm² (N / rpm²); defaults from Ct. |
cM |
float
|
Reaction-torque coefficient M = cM·rpm² (N·m / rpm²); defaults from Cq. |
spin_dir |
tuple[float, float, float, float]
|
Rotor spin direction signs; + means clockwise, - means counter-clockwise. |
tau_f |
float
|
Motor filter time constant (s). |
tau_m |
float
|
Legacy motor time constant (s). |
max_rpm |
float
|
Maximum rotor speed (rpm — LAV2 default). |
init_rpm |
float
|
Initial rotor speed — defaults to 0.2·max_rpm. |
rotor_rpm_rate_limit |
float
|
Rotor-speed rate-of-change limit (rpm/s). |
tau_up |
float
|
Motor spin-up time constant (s), defaults to tau_m. |
tau_down |
float
|
Motor spin-down time constant (s), defaults to tau_m. |
mpc_xy_vel_max |
float
|
Maximum horizontal velocity setpoint magnitude in m/s (0 - 20). |
mpc_z_vel_max_up |
float
|
Maximum upward velocity setpoint in m/s (0.5 - 8). |
mpc_z_vel_max_dn |
float
|
Maximum downward velocity setpoint magnitude in m/s (0.5 - 4). |
mpc_acc_hor_max |
float
|
Maximum horizontal acceleration setpoint magnitude in m/s^2 (2 - 15). |
mpc_acc_up_max |
float
|
Maximum upward acceleration setpoint in m/s^2 (2 - 15). |
mpc_acc_down_max |
float
|
Maximum downward acceleration setpoint magnitude in m/s^2 (2 - 15). |
mpc_man_tilt_max |
float
|
Maximum manual tilt angle in radians (deg: 0 - 90). |
mc_rollrate_max |
float
|
Maximum roll-rate setpoint in rad/s (deg/s: 0 - 1800). |
mc_pitchrate_max |
float
|
Maximum pitch-rate setpoint in rad/s (deg/s: 0 - 1800). |
mc_yawrate_max |
float
|
Maximum yaw-rate setpoint in rad/s (deg/s: 0 - 1800). |
rho
class-attribute
instance-attribute
rho: float = 1.184
Air density (kg/m³).
g
class-attribute
instance-attribute
g: float = 9.81
Gravitational acceleration (m/s²).
sim_dt
class-attribute
instance-attribute
sim_dt: float = 0.01
Simulation time step (s).
step_dt
class-attribute
instance-attribute
step_dt: float = 0.01
Control time step (s).
randomization
class-attribute
instance-attribute
randomization: dict[str, dict[str, tuple[float, float]]] = field(default_factory=dict)
Per-component parameter-randomisation scale ranges.
mass
class-attribute
instance-attribute
mass: float = 2.1
Total vehicle mass (kg — LAV2 default; override for other robots).
inertia
class-attribute
instance-attribute
inertia: list = field(default_factory=lambda: [[0.015, 0.0, 0.0], [0.0, 0.0348, 0.0], [0.0, 0.0, 0.042503]])
Inertia matrix (kg*m^2).
x
class-attribute
instance-attribute
x: float = 0.0952
Arm length in x — rotor moment-arm for roll (m).
y
class-attribute
instance-attribute
y: float = 0.114423
Arm length in y — rotor moment-arm for pitch (m).
h
class-attribute
instance-attribute
h: float = -0.0125
CG height below rotor plane (m, negative = below).
alpha
class-attribute
instance-attribute
alpha: float = math.radians(8.0)
Duct / rotor cant angle about y-axis (rad — 0 for flat rotors like ATMO).
diameter
class-attribute
instance-attribute
diameter: float = 0.476
Overall vehicle diameter (m).
Cdx
class-attribute
instance-attribute
Cdx: float = 0.5
Body drag coefficient.
r_p
class-attribute
instance-attribute
r_p: float = 0.0775
Propeller radius (m).
Ct
class-attribute
instance-attribute
Ct: float = 0.666
Thrust coefficient (blade-element).
Cq
class-attribute
instance-attribute
Cq: float = 0.0716
Torque coefficient (blade-element).
theta0
class-attribute
instance-attribute
theta0: float = math.radians(14.6)
Blade root pitch angle (rad).
thetaTip
class-attribute
instance-attribute
thetaTip: float = math.radians(6.8)
Blade tip pitch angle (rad).
theta1
class-attribute
instance-attribute
theta1: float = math.nan
Blade twist (rad), defaults to theta0 - thetaTip.
lock
class-attribute
instance-attribute
lock: float = 0.6051
Lock number.
cT
class-attribute
instance-attribute
cT: float = math.nan
Thrust coefficient T = cT·rpm² (N / rpm²); defaults from Ct.
cM
class-attribute
instance-attribute
cM: float = math.nan
Reaction-torque coefficient M = cM·rpm² (N·m / rpm²); defaults from Cq.
spin_dir
class-attribute
instance-attribute
spin_dir: tuple[float, float, float, float] = (1.0, 1.0, -1.0, -1.0)
Rotor spin direction signs; + means clockwise, - means counter-clockwise.
LAV2 defaults to rotors 0/1 clockwise and 2/3 counter-clockwise, so the
signs are (+,+,-,-).
tau_f
class-attribute
instance-attribute
tau_f: float = 0.01
Motor filter time constant (s).
tau_m
class-attribute
instance-attribute
tau_m: float = 0.05
Legacy motor time constant (s).
max_rpm
class-attribute
instance-attribute
max_rpm: float = 10000.0
Maximum rotor speed (rpm — LAV2 default).
init_rpm
class-attribute
instance-attribute
init_rpm: float = math.nan
Initial rotor speed — defaults to 0.2·max_rpm.
rotor_rpm_rate_limit
class-attribute
instance-attribute
rotor_rpm_rate_limit: float = 50000.0
Rotor-speed rate-of-change limit (rpm/s).
tau_up
class-attribute
instance-attribute
tau_up: float = math.nan
Motor spin-up time constant (s), defaults to tau_m.
tau_down
class-attribute
instance-attribute
tau_down: float = math.nan
Motor spin-down time constant (s), defaults to tau_m.
mpc_xy_vel_max
class-attribute
instance-attribute
mpc_xy_vel_max: float = 12.0
Maximum horizontal velocity setpoint magnitude in m/s (0 - 20).
mpc_z_vel_max_up
class-attribute
instance-attribute
mpc_z_vel_max_up: float = 3.0
Maximum upward velocity setpoint in m/s (0.5 - 8).
mpc_z_vel_max_dn
class-attribute
instance-attribute
mpc_z_vel_max_dn: float = 1.5
Maximum downward velocity setpoint magnitude in m/s (0.5 - 4).
mpc_acc_hor_max
class-attribute
instance-attribute
mpc_acc_hor_max: float = 5.0
Maximum horizontal acceleration setpoint magnitude in m/s^2 (2 - 15).
mpc_acc_up_max
class-attribute
instance-attribute
mpc_acc_up_max: float = 4.0
Maximum upward acceleration setpoint in m/s^2 (2 - 15).
mpc_acc_down_max
class-attribute
instance-attribute
mpc_acc_down_max: float = 3.0
Maximum downward acceleration setpoint magnitude in m/s^2 (2 - 15).
mpc_man_tilt_max
class-attribute
instance-attribute
mpc_man_tilt_max: float = math.radians(35.0)
Maximum manual tilt angle in radians (deg: 0 - 90).
mc_rollrate_max
class-attribute
instance-attribute
mc_rollrate_max: float = math.radians(220.0)
Maximum roll-rate setpoint in rad/s (deg/s: 0 - 1800).
mc_pitchrate_max
class-attribute
instance-attribute
mc_pitchrate_max: float = math.radians(220.0)
Maximum pitch-rate setpoint in rad/s (deg/s: 0 - 1800).
mc_yawrate_max
class-attribute
instance-attribute
mc_yawrate_max: float = math.radians(200.0)
Maximum yaw-rate setpoint in rad/s (deg/s: 0 - 1800).
__post_init__
__post_init__()
Calculate derived parameters and resolve default sentinels.
RotorDynamics
RotorDynamics(params: VehicleParams = VehicleParams(), num_envs: int = 1, device=None, *, backend: BackendName | None = None, xp: ModuleType | None = None)
Bases: DynamicsBase
Batched motor dynamics model for rotor thrust and torque.
This is the backend-agnostic Array API implementation. It keeps
the same low-pass motor response, RPM rate limiting, quadratic thrust/torque
coefficients, and motor-direction torque signs while operating on
(num_envs, 4) batches.
See :mod:lav2.dynamics.numpy.rotor and :mod:lav2.dynamics.torch.rotor
for the legacy backend-specific implementations.
Initialize rotor dynamics and backend arrays.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
VehicleParams
|
Vehicle parameters used by the motor model. |
VehicleParams()
|
|
int
|
Number of parallel environments represented by the batch. |
1
|
|
Optional backend device, mainly used by Torch. |
None
|
|
|
BackendName | None
|
Explicit Array API backend name. |
None
|
|
ModuleType | None
|
Pre-resolved Array API namespace. Overrides |
None
|
方法:
| 名称 | 描述 |
|---|---|
randomize |
Randomize motor parameters for selected environments. |
update |
Update motor state and return thrust/torque outputs. |
reset |
Reset selected environments to initial rotor speeds. |
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
params |
VehicleParams
|
Vehicle parameters for the dynamics model. |
params
instance-attribute
params: VehicleParams = params
Vehicle parameters for the dynamics model.
randomize
randomize(env_ids=None, randomization: dict[str, tuple[float, float]] | None = None)
Randomize motor parameters for selected environments.
update
update(commands: ArrayLike) -> ArrayLike
Update motor state and return thrust/torque outputs.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
ArrayLike
|
Desired rotor speeds with shape |
必需 |
返回:
| 类型 | 描述 |
|---|---|
ArrayLike
|
Batched thrusts followed by torques with shape |
reset
reset(env_ids=None)
Reset selected environments to initial rotor speeds.
FlightControlActionManager
FlightControlActionManager(env: GenesisEnv, delay_step: int = 0, params: VehicleParams = VehicleParams(), gains: dict | None = None, limits: dict | None = None, mapping: FlightMappingConfig = FlightMappingConfig(), entity_attr: str = 'robot', rotor_link_names: tuple[str, ...] = ('rotor0', 'rotor1', 'rotor2', 'rotor3'), control_mode: str = 'cmd_motor_speeds', controller: str = 'FlightController', randomize_gains: bool | dict = False)
Bases: BaseActionManager
Base class for Genesis flight action managers.
Initialize the Genesis flight action manager.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
GenesisEnv
|
The environment that owns the controlled robot entity. |
必需 |
|
int
|
Number of control steps to delay incoming actions. |
0
|
|
VehicleParams
|
Vehicle physical parameters. |
VehicleParams()
|
|
dict | None
|
Optional flight-controller gain overrides. |
None
|
|
dict | None
|
Optional flight-controller command-limit overrides. |
None
|
|
FlightMappingConfig
|
Action-mapping overrides resolved against |
FlightMappingConfig()
|
|
str
|
Environment attribute name for the robot entity. |
'robot'
|
|
tuple[str, ...]
|
Ordered rotor link names matching controller/mixer order. |
('rotor0', 'rotor1', 'rotor2', 'rotor3')
|
|
str
|
Flight control mode for interpreting the incoming action. |
'cmd_motor_speeds'
|
|
str
|
Controller class name. Options: 'FlightController' (PID), 'GeoControl'. |
'FlightController'
|
|
bool | dict
|
If |
False
|
方法:
| 名称 | 描述 |
|---|---|
step |
Process the incoming actions (analogous to Isaac Lab |
send_actions_to_simulation |
Apply the processed actions to the simulation (Isaac Lab |
reset |
Reset environments. |
get_actions |
Get the current actions for the environments. |
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
num_actions |
int
|
The total number of actions. |
action_space |
tuple[float, float]
|
If using the default action handler, the action space is [-1, 1]. |
actions |
Tensor
|
The actions for for the current step. |
raw_actions |
Tensor
|
The actions received from the policy, before being converted. |
num_actions
property
num_actions: int
The total number of actions.
action_space
property
action_space: tuple[float, float]
If using the default action handler, the action space is [-1, 1].
actions
property
actions: Tensor
The actions for for the current step.
raw_actions
property
raw_actions: Tensor
The actions received from the policy, before being converted.
step
step(actions: Tensor) -> torch.Tensor
Process the incoming actions (analogous to Isaac Lab process_actions).
Only the raw and clamped policy actions are stored here; the flight
controller, mixer, rotor dynamics and body-force application all run in
:meth:send_actions_to_simulation (the apply phase). Keeping the
controller in the apply phase lets it read fresh robot state on each
apply tick, mirroring Isaac Lab's process_actions/apply_actions
split.
send_actions_to_simulation
send_actions_to_simulation(processed_actions: Tensor) -> torch.Tensor
Apply the processed actions to the simulation (Isaac Lab apply_actions).
genesis_forge>=0.5 splits action handling into step (process) and
send_actions_to_simulation (apply), which runs at a different cadence
than processing. This reads fresh robot state, runs the flight
controller/mixer to obtain the rotor RPM command, steps the rotor
dynamics, and writes the resulting body forces/torques to the solver.
reset
reset(envs_idx: list[int] | None)
Reset environments.
get_actions
get_actions() -> torch.Tensor
Get the current actions for the environments.
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
|
wrap_to_pi
wrap_to_pi(angles: Tensor) -> torch.Tensor
Wraps input angles (in radians) to the range :math:[-\pi, \pi].
This function wraps angles in radians to the range :math:[-\pi, \pi], such that
:math:\pi maps to :math:\pi, and :math:-\pi maps to :math:-\pi. In general,
odd positive multiples of :math:\pi are mapped to :math:\pi, and odd negative
multiples of :math:\pi are mapped to :math:-\pi.
The function behaves similar to MATLAB's wrapToPi <https://www.mathworks.com/help/map/ref/wraptopi.html>_
function.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
Tensor
|
Input angles of any shape. |
必需 |
返回:
| 类型 | 描述 |
|---|---|
Tensor
|
torch.Tensor: Angles in the range :math: |
lin_vel_l2
lin_vel_l2(env: GenesisEnv, entity_attr: str = 'robot', entity_manager: EntityManager = None) -> torch.Tensor
Penalize base linear velocity using L2 squared kernel.
ang_vel_l2
ang_vel_l2(env: GenesisEnv, entity_attr: str = 'robot', entity_manager: EntityManager = None) -> torch.Tensor
Penalize base angular velocity using L2 squared kernel.
pos_error_l2
pos_error_l2(env: GenesisEnv, target_pose: Tensor = None, pose_command: CommandManager = None) -> torch.Tensor
Penalize asset pos from its target pos using L2 squared kernel.
pos_error_tanh
pos_error_tanh(env: GenesisEnv, target_pose: Tensor = None, std: float = 0.8, pose_command: CommandManager = None) -> torch.Tensor
Penalize asset pos from its target pos using tanh kernel.
yaw_error_l2
yaw_error_l2(env: GenesisEnv, target_pose: Tensor = None, pose_command: CommandManager = None) -> torch.Tensor
Penalize heading error from target heading using L2 squared kernel.
Expects pose_command.command[:, 3] to be the body-frame heading error (already wrapped to [-pi, pi]).
yaw_error_tanh
yaw_error_tanh(env: GenesisEnv, target_pose: Tensor = None, std: float = 0.8, pose_command: CommandManager = None) -> torch.Tensor
Penalize heading error from target heading using tanh kernel.
Expects pose_command.command[:, 3] to be the body-frame heading error (already wrapped to [-pi, pi]).