-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional Numpy Compute Backend #1051
base: og-develop
Are you sure you want to change the base?
Conversation
# Conflicts: # omnigibson/controllers/multi_finger_gripper_controller.py # omnigibson/robots/fetch.py # omnigibson/robots/tiago.py # omnigibson/robots/vx300s.py # setup.py
for more information, see https://pre-commit.ci
# Conflicts: # setup.py
# Conflicts: # omnigibson/controllers/multi_finger_gripper_controller.py
for more information, see https://pre-commit.ci
target_pos = cb.copy(control_dict[f"{self.task_name}_pos_relative"]) | ||
target_quat = cb.copy(control_dict[f"{self.task_name}_quat_relative"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is copying needed?
) | ||
|
||
@property | ||
def command_dim(self): | ||
return IK_MODE_COMMAND_DIMS[self.mode] | ||
|
||
|
||
import torch as th |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it imported here?
# Set these as part of the backend values | ||
setattr(_ComputeBackend, "compute_ik_qpos", None) | ||
setattr(_ComputeTorchBackend, "compute_ik_qpos", _compute_ik_qpos_torch) | ||
setattr(_ComputeNumpyBackend, "compute_ik_qpos", _compute_ik_qpos_numpy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm so why don't we define these functions in _ComputeTorch/NumpyBackend
?
@jit(nopython=True) | ||
def numba_ix(arr, rows, cols): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is significantly faster than np.meshgrid?
def _generate_default_command_output_limits(self): | ||
command_output_limits = super()._generate_default_command_output_limits() | ||
|
||
return cb.mean(command_output_limits[0]), cb.mean(command_output_limits[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only works for the smoothing
mode? For binary
mode, it's command_output_limits = (-1.0, 1.0)
and for independent
mode, it's just super()._generate_default_command_output_limits()
?
@@ -58,7 +57,7 @@ def __init__( | |||
applied | |||
""" | |||
# Store values | |||
self._default_command = th.zeros(len(dof_idx)) if default_command is None else default_command | |||
self._default_command = cb.zeros(len(dof_idx)) if default_command is None else default_command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait so self._default_command
still has the same dimension as dof_idx
instead of 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: update to default_goal
ee_ang_vel_err=cb.as_float32( | ||
cb.T.quat2axisangle( | ||
cb.T.quat_multiply(cb.T.axisangle2quat(-ee_vel[3:]), cb.T.axisangle2quat(base_ang_vel)) | ||
) | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe compute this first and then feed in? Also should we use orientation_error here or is this different?
Or is it cleaner to just feed in ee_ang_vel
and do this computation within the compute_osc_torques
function?
|
||
|
||
@jit(nopython=True) | ||
def mat2quat_batch(rmat): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
figure out if this is used
_NEXT_AXIS = [1, 2, 0, 1] | ||
|
||
# map axes strings to/from tuples of inner axis, parity, repetition, frame | ||
_AXES2TUPLE = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure one-to-one correspondence with transform_utils.py
.
Add a comment at the top of the file to explain that: by default, we use scipy, but we optionally implement numba versions for functions that are often called in "batch" mode?
No description provided.