utils
get_rgb_selected_worlds_and_cameras(rc, worldids, camids, rgb_out)
¶
Get the RGB data output from the render context buffers for the selected worlds and cameras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rc
|
RenderContext
|
The render context on device. |
required |
worldids
|
array[int]
|
Indices of the worlds to read RGB data for. |
required |
camids
|
array[int]
|
Indices of the cameras to read RGB data for. |
required |
rgb_out
|
array4d[vec3]
|
The output array to store the RGB data in, with shape (len(worldids), len(camids), height, width). |
required |
Source code in src/flygym/warp/utils.py
unpack_rgb_kernel_selected_worlds_and_cameras(packed, rgb_adr, worldids_to_render, camids_to_render, rgb_out)
¶
Unpack ABGR uint32 packed pixel data into separate R, G, and B channels.
Source code in src/flygym/warp/utils.py
wp_gather_indexed_cols_2d(src, dst, cols)
¶
Gather specific columns from a 2D Warp array into a narrower destination array.
This kernel is to be launched with a 2D launch configuration of
(n_rows, n_cols_narrow), where n_cols_narrow is the number of columns to gather.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
wp.array of shape (n_rows, n_cols_wide), type float32
|
Source array. |
required |
dst
|
wp.array of shape (n_rows, n_cols_narrow), type float32
|
Destination array, where n_cols_narrow <= n_cols_wide. |
required |
cols
|
wp.array of shape (n_cols_narrow,), type int32
|
Array of column indices of |
required |
Source code in src/flygym/warp/utils.py
wp_gather_indexed_rows_3d(src, dst, rows)
¶
Gather specific rows (dim 1) from a 3D Warp array into a narrower destination.
This kernel is to be launched with a 3D launch configuration of
(n_worlds, n_rows_narrow, n_cols).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
wp.array of shape (n_worlds, n_rows_wide, n_cols), type float32
|
Source array. |
required |
dst
|
wp.array of shape (n_worlds, n_rows_narrow, n_cols), type float32
|
Destination array, where n_rows_narrow <= n_rows_wide. |
required |
rows
|
wp.array of shape (n_rows_narrow,), type int32
|
Array of row indices (dim 1) of |
required |
Source code in src/flygym/warp/utils.py
wp_gather_indexed_rows_quatf(src, dst, rows)
¶
Gather specific rows from a 2D quatf array into a (n_worlds, n_rows_narrow, 4)
float32 destination.
This kernel is to be launched with a 2D launch configuration of
(n_worlds, n_rows_narrow).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
wp.array of shape (n_worlds, n_rows_wide), type quatf
|
Source array, e.g. |
required |
dst
|
wp.array of shape (n_worlds, n_rows_narrow, 4), type float32
|
Destination array. |
required |
rows
|
wp.array of shape (n_rows_narrow,), type int32
|
Body indices to gather. |
required |
Source code in src/flygym/warp/utils.py
wp_gather_indexed_rows_vec3f(src, dst, rows)
¶
Gather specific rows from a 2D vec3f array into a (n_worlds, n_rows_narrow, 3)
float32 destination.
This kernel is to be launched with a 2D launch configuration of
(n_worlds, n_rows_narrow).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
wp.array of shape (n_worlds, n_rows_wide), type vec3f
|
Source array, e.g. |
required |
dst
|
wp.array of shape (n_worlds, n_rows_narrow, 3), type float32
|
Destination array. |
required |
rows
|
wp.array of shape (n_rows_narrow,), type int32
|
Body indices to gather. |
required |
Source code in src/flygym/warp/utils.py
wp_gather_offset_body_positions(xpos, xmat, dst, bodies, relpos)
¶
Gather the global positions of frames rigidly attached to given bodies into a
(n_worlds, n_frames, 3) float32 destination.
This is used to get the positions of body segments that fusestatic has fused into
an ancestor body. This kernel is to be launched with a 2D launch configuration of
(n_worlds, n_frames).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xpos
|
wp.array of shape (n_worlds, n_bodies), type vec3f
|
Global body positions, i.e. |
required |
xmat
|
wp.array of shape (n_worlds, n_bodies), type mat33f
|
Global body orientations, i.e. |
required |
dst
|
wp.array of shape (n_worlds, n_frames, 3), type float32
|
Destination array. |
required |
bodies
|
wp.array of shape (n_frames,), type int32
|
Index of the body that each frame is attached to. |
required |
relpos
|
wp.array of shape (n_frames,), type vec3f
|
Position of each frame in the frame of its body. |
required |
Source code in src/flygym/warp/utils.py
wp_gather_offset_body_rotations(xquat, dst, bodies, relquat)
¶
Gather the global orientations of frames rigidly attached to given bodies into a
(n_worlds, n_frames, 4) float32 destination.
Counterpart of wp_gather_offset_body_positions for orientations. All quaternions
are stored in MuJoCo's (w, x, y, z) order. This kernel is to be launched with a 2D
launch configuration of (n_worlds, n_frames).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xquat
|
wp.array of shape (n_worlds, n_bodies), type quatf
|
Global body orientations, i.e. |
required |
dst
|
wp.array of shape (n_worlds, n_frames, 4), type float32
|
Destination array. |
required |
bodies
|
wp.array of shape (n_frames,), type int32
|
Index of the body that each frame is attached to. |
required |
relquat
|
wp.array of shape (n_frames,), type quatf
|
Orientation of each frame relative to its body. |
required |
Source code in src/flygym/warp/utils.py
wp_gather_worlds_2d(src, dst, world_ids)
¶
Gather specific worlds (dim 0) from a 2D Warp array of any dtype.
This kernel is to be launched with a 2D launch configuration of dst.shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
wp.array of shape (n_worlds, n_cols)
|
Source array, e.g. |
required |
dst
|
wp.array of shape (n_selected_worlds, n_cols), same dtype as `src`
|
Destination array. |
required |
world_ids
|
wp.array of shape (n_selected_worlds,), type int32
|
Indices of the worlds to gather. |
required |
Source code in src/flygym/warp/utils.py
wp_masked_copy_rows_2d(src, dst, world_mask)
¶
Copy whole rows (dim 0, indexed by world) where a per-world mask is set.
This kernel is to be launched with a 2D launch configuration of
(n_worlds, n_cols). Unlike a keyframe reset, src may hold a different row per
world, so this is the building block for per-world reference-state initialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
wp.array of shape (n_worlds, n_cols), type float32
|
Source array; rows for un-masked worlds are ignored. |
required |
dst
|
wp.array of shape (n_worlds, n_cols), type float32
|
Destination array, written in place for masked worlds only. |
required |
world_mask
|
wp.array of shape (n_worlds,), type bool
|
Per-world mask; a row is copied only where its entry is True. |
required |
Source code in src/flygym/warp/utils.py
wp_scatter_indexed_cols_2d(src, dst, cols)
¶
Scatter a 2D Warp array into specific columns of a wider destination array.
This kernel is to be launched with a 2D launch configuration of
(n_rows, n_cols_narrow), where n_cols_narrow is the number of columns to copy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src
|
wp.array of shape (n_rows, n_cols_narrow), type float32
|
Source array. |
required |
dst
|
wp.array of shape (n_rows, n_cols_wide), type float32
|
Destination array, where n_cols_wide >= n_cols_narrow. |
required |
cols
|
wp.array of shape (n_cols_narrow,), type int32
|
Array of column indices of |
required |