NVlabs / curobo

CUDA Accelerated Robot Library
https://curobo.org
Other
796 stars 125 forks source link

motion_gen.plan_batch_env gives no grad error #340

Closed supersglzc closed 4 months ago

supersglzc commented 4 months ago
  1. cuRobo installation mode (choose from [python, isaac sim, docker python, docker isaac sim]): isaac sim
  2. python version: 3.10.14
  3. Isaac Sim version (if using): 4.0.0

Hi, I tried to use motion_gen.plan_batch_env for motion planning. However, it gives me the following error:

File "/home/steven/code/curobo/src/curobo/wrap/reacher/motion_gen.py", line 1681, in plan_batch_env result = self._plan_batch_attempts( File "/home/steven/code/curobo/src/curobo/wrap/reacher/motion_gen.py", line 3113, in _plan_batch_attempts result = self._plan_from_solve_state_batch( File "/home/steven/code/curobo/src/curobo/wrap/reacher/motion_gen.py", line 3763, in _plan_from_solve_state_batch ik_result = self._solve_ik_from_solve_state( File "/home/steven/miniconda3/envs/curobo/lib/python3.10/contextlib.py", line 79, in inner return func(*args, **kwds) File "/home/steven/code/curobo/src/curobo/wrap/reacher/motion_gen.py", line 2741, in _solve_ik_from_solve_state ik_result = self.ik_solver.solve_any( File "/home/steven/code/curobo/src/curobo/wrap/reacher/ik_solver.py", line 1203, in solve_any return self.solve_batch_env( File "/home/steven/code/curobo/src/curobo/wrap/reacher/ik_solver.py", line 921, in solve_batch_env return self._solve_from_solve_state( File "/home/steven/code/curobo/src/curobo/wrap/reacher/ik_solver.py", line 1045, in _solve_from_solve_state result = self.solver.solve(goal_buffer, coord_position_seed) File "/home/steven/code/curobo/src/curobo/wrap/wrap_base.py", line 149, in solve act_seq = self.optimize(seed, shift_steps=0) File "/home/steven/code/curobo/src/curobo/wrap/wrap_base.py", line 71, in optimize act_seq = opt.optimize(act_seq, shift_steps) File "/home/steven/code/curobo/src/curobo/opt/opt_base.py", line 170, in optimize out = self._optimize(opt_tensor, shift_steps, n_iters) File "/home/steven/code/curobo/src/curobo/opt/newton/newton_base.py", line 144, in _optimize self._initialize_opt_iters_graph(q, grad_q, shift_steps=shift_steps) File "/home/steven/code/curobo/src/curobo/opt/newton/newton_base.py", line 499, in _initialize_opt_iters_graph self._create_opt_iters_graph(q, grad_q, shift_steps) File "/home/steven/code/curobo/src/curobo/opt/newton/newton_base.py", line 540, in _create_opt_iters_graph self._cu_opt_q, self._cu_opt_cost, self._cu_q, self._cu_gq = self._opt_iters( File "/home/steven/code/curobo/src/curobo/opt/newton/newton_base.py", line 173, in _opt_iters cost_n, q, grad_q = self._opt_step(q.detach(), grad_q.detach()) File "/home/steven/code/curobo/src/curobo/opt/newton/newton_base.py", line 182, in _opt_step q_n, cost_n, grad_q_n = self._approx_line_search(q, grad_q) File "/home/steven/code/curobo/src/curobo/opt/newton/newton_base.py", line 428, in _approx_line_search return self._wolfe_line_search(x, step_direction) File "/home/steven/code/curobo/src/curobo/opt/newton/newton_base.py", line 255, in _wolfe_line_search c, g_x = self._compute_cost_gradient(x_set) File "/home/steven/code/curobo/src/curobo/opt/newton/newton_base.py", line 236, in _compute_cost_gradient g_x = cost.backward(gradient=self.l_vec, retain_graph=False) File "/home/steven/miniconda3/envs/curobo/lib/python3.10/site-packages/torch/_tensor.py", line 487, in backward torch.autograd.backward( File "/home/steven/miniconda3/envs/curobo/lib/python3.10/site-packages/torch/autograd/__init__.py", line 200, in backward Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

The input of joint state and ik goal is printed as following: JointState(position=tensor([[0., 0., 0., 0., 0., 0., 0.]], device='cuda:0'), velocity=tensor([[0., 0., 0., 0., 0., 0., 0.]], device='cuda:0'), acceleration=tensor([[0., 0., 0., 0., 0., 0., 0.]], device='cuda:0'), joint_names=['J1_l', 'J2_l', 'J3_l', 'J4_l', 'J5_l', 'J6_l', 'J7_l'], jerk=tensor([[0., 0., 0., 0., 0., 0., 0.]], device='cuda:0'), tensor_args=TensorDeviceType(device=device(type='cuda', index=0), dtype=torch.float32, collision_geometry_dtype=torch.float32, collision_gradient_dtype=torch.float32, collision_distance_dtype=torch.float32), aux_data={}) Pose(position=tensor([[0.2000, 0.5000, 1.4000]], device='cuda:0'), quaternion=tensor([[1., 0., 0., 0.]], device='cuda:0'), rotation=None, batch=1, n_goalset=1, name='ee_link', normalize_rotation=True)

I found it had no format difference with the input I printed from the example. But the error happened.

Thanks!