NVlabs / curobo

CUDA Accelerated Robot Library
https://curobo.org
Other
662 stars 86 forks source link

`goal_quat` view size is not compatible, use `.reshape()` instead #278

Closed cremebrule closed 1 month ago

cremebrule commented 1 month ago

If it’s not a bug, please use discussions: https://github.com/NVlabs/curobo/discussions

Please provide the below information in addition to your issue:

  1. cuRobo installation mode (choose from [python, isaac sim, docker python, docker isaac sim]): isaac-sim
  2. python version: 3.10
  3. Isaac Sim version (if using): 2023.1.1

Issue Details

Running a batch trajectory solve results in the following error, using the latest curobo installed from source:

File ~/projects/repo/curobo/src/curobo/curobolib/geom.py:182, in get_pose_distance(out_distance, out_position_distance, out_rotation_distance, out_p_vec, out_q_vec, out_idx, current_position, goal_position, current_quat, goal_quat, vec_weight, weight, vec_convergence, run_weight, run_vec_weight, offset_waypoint, offset_tstep_fraction, batch_pose_idx, batch_size, horizon, mode, num_goals, write_grad, write_distance, use_metric, project_distance)
    169 if batch_pose_idx.shape[0] != batch_size:
    170     raise ValueError("Index buffer size is different from batch size")
    172 r = geom_cu.pose_distance(
    173     out_distance,
    174     out_position_distance,
    175     out_rotation_distance,
    176     out_p_vec,
    177     out_q_vec,
    178     out_idx,
    179     current_position,
    180     goal_position.view(-1),
    181     current_quat,
--> 182     goal_quat.view(-1),
    183     vec_weight,
    184     weight,
    185     vec_convergence,
    186     run_weight,
    187     run_vec_weight,
    188     offset_waypoint,
    189     offset_tstep_fraction,
    190     batch_pose_idx,
    191     batch_size,
    192     horizon,
    193     mode,
    194     num_goals,
    195     write_grad,
    196     write_distance,
    197     use_metric,
    198     project_distance,
    199 )
    201 out_distance = r[0]
    202 out_position_distance = r[1]

RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

The fix seems trivial -- simply changing the offending line to be .reshape() seems to fix things.

balakumar-s commented 1 month ago

reshape causes a memory copy which we want to avoid to be more efficient. For the most common case, view would work.

I would move the reshape to be before calling the solve function.