Skip to content

Commit 2fbffc3

Browse files
committed
fix terminal action, 10x more accurate pose reaching
1 parent 36ea382 commit 2fbffc3

15 files changed

+198
-28
lines changed

CHANGELOG.md

+29
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,34 @@ its affiliates is strictly prohibited.
1010
-->
1111
# Changelog
1212

13+
## Version 0.7.6
14+
15+
### Changes in Default Behavior
16+
- Acceleration and Jerk in Output trajectory from motion_gen is not filtered. Previously, this was
17+
filtered with a sliding window to remove aliasing artifacts. To get previous behavior, set
18+
`filter_robot_command=True` in `MotionGenConfig.load_from_robot_config()`.
19+
- Terminal action for motion planning is now fixed from initial seed. This improves accuracy (10x).
20+
To get previous behavior, set `trajopt_fix_terminal_action=True` and also
21+
`trajopt_js_fix_terminal_action=True` in `MotionGenConfig.load_from_robot_config()`.
22+
- Introduce higher accuracy weights for IK in `gradient_ik_autotune.yml`. To use old file,
23+
pass `gradient_ik_file='gradient_ik.yml'` in `MotionGenConfig.load_from_robot_config()`. Similarly
24+
for IKSolver, pass `gradient_file='gradient_ik.yml'` in `IKSolverConfig.load_from_robot_config()`.
25+
26+
### New Features
27+
- Add fix terminal action in quasi-netwon solvers. This keeps the final action constant (from
28+
initial seed) and only optimizing for the remaining states. Improved accuracy in
29+
reaching targets (10x improvement for Cartesian pose targets and exact reaching for joint position
30+
targets).
31+
32+
33+
### BugFixes & Misc.
34+
35+
- Fix bug (opposite sign) in gradient calculation for jerk. Trajectory optimizaiton generates
36+
shorter motion time trajectories.
37+
- Fix numerical precision issues when calculating linear interpolated seeds by copying terminal
38+
state to final action of trajectory after interpolation.
39+
40+
1341
## Version 0.7.5
1442

1543
### Changes in Default Behavior
@@ -44,6 +72,7 @@ numpy array was created instead of torch tensor.
4472
- Improve sphere position to voxel location calculation to match nvblox's implementation.
4573
- Add self collision checking support for spheres > 1024 and number of checks > 512 * 1024.
4674
- Fix gradient passthrough in warp batch transform kernels.
75+
- Remove torch.Size() initialization with device kwarg.
4776

4877
## Version 0.7.4
4978

benchmark/curobo_benchmark.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def benchmark_mb(
240240
og_tsteps = 32
241241
if override_tsteps is not None:
242242
og_tsteps = override_tsteps
243-
og_finetune_dt_scale = 0.85
243+
og_finetune_dt_scale = 0.8
244244
og_trajopt_seeds = 4
245245
og_parallel_finetune = True
246246
og_collision_activation_distance = 0.01

src/curobo/content/configs/task/finetune_trajopt.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cost:
5454
run_weight: 0.00 #1
5555

5656
bound_cfg:
57-
weight: [10000.0, 500000.0, 500.0, 500.0]
57+
weight: [50000.0, 50000.0, 5000.0, 5.0]
5858
smooth_weight: [0.0,10000.0, 5.0, 0.0]
5959
run_weight_velocity: 0.0
6060
run_weight_acceleration: 1.0

src/curobo/content/configs/task/finetune_trajopt_slow.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ model:
2424
max_dt: 0.15
2525
vel_scale: 1.0
2626
control_space: 'POSITION'
27-
state_finite_difference_mode: "CENTRAL"
27+
state_finite_difference_mode: "CENTRAL"
2828

2929
teleport_mode: False
3030
return_full_act_buffer: True
@@ -35,7 +35,7 @@ cost:
3535
weight: [2000,500000.0,30,60]
3636
vec_convergence: [0.0,0.0] # orientation, position, orientation metric activation, position metric activation
3737
terminal: True
38-
run_weight: 1.0
38+
run_weight: 1.0
3939
use_metric: True
4040

4141
link_pose_cfg:
@@ -46,19 +46,19 @@ cost:
4646
terminal: True
4747
run_weight: 1.0
4848
use_metric: True
49-
49+
5050
cspace_cfg:
5151
weight: 10000.0
5252
terminal: True
5353
run_weight: 0.00 #1
5454

5555
bound_cfg:
56-
weight: [10000.0, 500000.0, 500.0, 500.0]
56+
weight: [10000.0, 500000.0, 5000.0, 5.0]
5757
smooth_weight: [0.0,10000.0, 5.0, 0.0]
5858
run_weight_velocity: 0.0
5959
run_weight_acceleration: 1.0
6060
run_weight_jerk: 1.0
61-
activation_distance: [0.05,0.05,0.05,0.05] # for position, velocity, acceleration and jerk
61+
activation_distance: [0.05,0.001,0.001,0.001] # for position, velocity, acceleration and jerk
6262
null_space_weight: [0.0]
6363

6464
primitive_collision_cfg:
@@ -77,9 +77,9 @@ cost:
7777

7878

7979
lbfgs:
80-
n_iters: 400
81-
inner_iters: 25
82-
cold_start_n_iters: null
80+
n_iters: 400
81+
inner_iters: 25
82+
cold_start_n_iters: null
8383
min_iters: 25
8484
line_search_scale: [0.1, 0.3, 0.7,1.0] # #
8585
fixed_iters: True

src/curobo/content/configs/task/gradient_ik.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ lbfgs:
6868
min_iters: null
6969
line_search_scale: [0.1, 0.3, 0.7, 1.0]
7070
fixed_iters: True
71-
cost_convergence: 0.001
72-
cost_delta_threshold: 1.0 #0.0001
71+
cost_convergence: 1e-11
72+
cost_delta_threshold: 1e-11 #0.0001
7373
cost_relative_threshold: 0.999
7474
epsilon: 0.01 #0.01 # used only in stable_mode
7575
history: 6
@@ -84,7 +84,7 @@ lbfgs:
8484
use_cuda_line_search_kernel: True
8585
use_cuda_update_best_kernel: True
8686
sync_cuda_time: True
87-
step_scale: 1.0
87+
step_scale: 0.98
8888
use_coo_sparse: True
8989
last_best: 10
9090
debug_info:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
##
2+
## Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
##
4+
## NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
5+
## property and proprietary rights in and to this material, related
6+
## documentation and any modifications thereto. Any use, reproduction,
7+
## disclosure or distribution of this material and related documentation
8+
## without an express license agreement from NVIDIA CORPORATION or
9+
## its affiliates is strictly prohibited.
10+
##
11+
12+
cost:
13+
bound_cfg:
14+
activation_distance:
15+
- 0.001
16+
null_space_weight: 0.0
17+
use_l2_kernel: true
18+
weight: 6617.916155103846
19+
cspace_cfg:
20+
weight: 0.0
21+
link_pose_cfg:
22+
run_weight: 1.0
23+
terminal: false
24+
use_metric: true
25+
vec_convergence:
26+
- 0.0
27+
- 0.0
28+
vec_weight:
29+
- 1.0
30+
- 1.0
31+
- 1.0
32+
- 1.0
33+
- 1.0
34+
- 1.0
35+
weight:
36+
- 51057.936375400066
37+
- 843196.9018921662
38+
- 57.65743420107279
39+
- 27.3008552454367
40+
pose_cfg:
41+
project_distance: false
42+
run_weight: 1.0
43+
terminal: false
44+
use_metric: true
45+
vec_convergence:
46+
- 0.0
47+
- 0.0
48+
vec_weight:
49+
- 1.0
50+
- 1.0
51+
- 1.0
52+
- 1.0
53+
- 1.0
54+
- 1.0
55+
weight:
56+
- 51057.936375400066
57+
- 843196.9018921662
58+
- 57.65743420107279
59+
- 27.3008552454367
60+
primitive_collision_cfg:
61+
activation_distance: 0.01
62+
classify: false
63+
use_sweep: false
64+
weight: 6955.6913192212
65+
self_collision_cfg:
66+
classify: false
67+
weight: 2140.4341585026104
68+
lbfgs:
69+
cold_start_n_iters: null
70+
cost_convergence: 1.0e-11
71+
cost_delta_threshold: 1.0e-11
72+
cost_relative_threshold: 0.999
73+
debug_info:
74+
visual_traj: null
75+
epsilon: 0.01
76+
fixed_iters: true
77+
history: 6
78+
horizon: 1
79+
inner_iters: 25
80+
last_best: 10
81+
line_search_scale:
82+
- 0.11626529237230242
83+
- 0.5544193619969185
84+
- 0.7460490833893989
85+
- 1.0502486637627748
86+
line_search_type: approx_wolfe
87+
min_iters: null
88+
n_iters: 100
89+
n_problems: 1
90+
stable_mode: true
91+
step_scale: 0.98
92+
store_debug: false
93+
sync_cuda_time: true
94+
use_coo_sparse: true
95+
use_cuda_graph: true
96+
use_cuda_kernel: true
97+
use_cuda_line_search_kernel: true
98+
use_cuda_update_best_kernel: true
99+
use_shared_buffers_kernel: true
100+
model:
101+
control_space: POSITION
102+
dt_traj_params:
103+
base_dt: 0.02
104+
base_ratio: 1.0
105+
max_dt: 0.25
106+
horizon: 1
107+
state_filter_cfg:
108+
enable: false
109+
filter_coeff:
110+
acceleration: 0.0
111+
position: 1.0
112+
velocity: 1.0
113+
teleport_mode: true
114+
vel_scale: 1.0

src/curobo/content/configs/task/gradient_trajopt.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ cost:
5353
run_weight: 0.0
5454

5555
bound_cfg:
56-
weight: [50000.0, 50000.0, 500.0,500.0]
56+
weight: [50000.0, 50000.0, 5000.0,5.0]
5757
smooth_weight: [0.0,10000.0,5.0, 0.0]
5858
run_weight_velocity: 0.00
5959
run_weight_acceleration: 1.0

src/curobo/curobolib/cpp/tensor_step_kernel.cu

+1-1
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ namespace Curobo
850850
(1.333333333f) * g_acc[3] + (-0.083333333f) * g_acc[4]) * dt * dt +
851851

852852
// ( g_acc[3] + g_acc[1] - (2.0) * g_acc[2]) * dt * dt +
853-
(0.5f * g_jerk[0] - g_jerk[1] + g_jerk[3] - 0.5f * g_jerk[4]) * dt * dt * dt);
853+
(-0.5f * g_jerk[0] + g_jerk[1] - g_jerk[3] + 0.5f * g_jerk[4]) * dt * dt * dt);
854854
}
855855
else if (hid == horizon - 3)
856856
{

src/curobo/opt/newton/newton_base.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class NewtonOptConfig(OptimizerConfig):
5252
last_best: float = 0
5353
use_temporal_smooth: bool = False
5454
cost_relative_threshold: float = 0.999
55+
fix_terminal_action: bool = False
5556

5657
# use_update_best_kernel: bool
5758
# c_1: float
@@ -416,16 +417,21 @@ def _armijo_line_search(self, x, step_direction):
416417
def _approx_line_search(self, x, step_direction):
417418
if self.step_scale != 0.0 and self.step_scale != 1.0:
418419
step_direction = self.scale_step_direction(step_direction)
420+
if self.fix_terminal_action and self.action_horizon > 1:
421+
step_direction[..., (self.action_horizon - 1) * self.d_action :] = 0.0
419422
if self.line_search_type == LineSearchType.GREEDY:
420-
return self._greedy_line_search(x, step_direction)
423+
best_x, best_c, best_grad = self._greedy_line_search(x, step_direction)
421424
elif self.line_search_type == LineSearchType.ARMIJO:
422-
return self._armijo_line_search(x, step_direction)
425+
best_x, best_c, best_grad = self._armijo_line_search(x, step_direction)
423426
elif self.line_search_type in [
424427
LineSearchType.WOLFE,
425428
LineSearchType.STRONG_WOLFE,
426429
LineSearchType.APPROX_WOLFE,
427430
]:
428-
return self._wolfe_line_search(x, step_direction)
431+
best_x, best_c, best_grad = self._wolfe_line_search(x, step_direction)
432+
if self.fix_terminal_action and self.action_horizon > 1:
433+
best_grad[..., (self.action_horizon - 1) * self.d_action :] = 0.0
434+
return best_x, best_c, best_grad
429435

430436
def check_convergence(self, cost):
431437
above_threshold = cost > self.cost_convergence

src/curobo/rollout/arm_reacher.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ def convergence_fn(
367367
current_fn = self._link_pose_convergence[k]
368368
if current_fn.enabled:
369369
# get link pose
370-
current_pos = link_poses[k].position
371-
current_quat = link_poses[k].quaternion
370+
current_pos = link_poses[k].position.contiguous()
371+
current_quat = link_poses[k].quaternion.contiguous()
372372

373373
pose_err, pos_err, quat_err = current_fn.forward_out_distance(
374374
current_pos, current_quat, self._goal_buffer, k

src/curobo/util/sample_lib.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,7 @@ def get_samples(self, sample_shape, base_seed=None, **kwargs):
377377
if self.sample_ratio[k] == 0.0:
378378
continue
379379
n_samples = round(sample_shape[0] * self.sample_ratio[k])
380-
s_shape = torch.Size(
381-
[n_samples], device=self.tensor_args.device, dtype=self.tensor_args.dtype
382-
)
380+
s_shape = torch.Size([n_samples])
383381
# if(k == 'halton' or k == 'random'):
384382
samples = self.sample_fns[k](sample_shape=s_shape)
385383
# else:

src/curobo/wrap/reacher/ik_solver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def load_from_robot_config(
129129
world_coll_checker=None,
130130
base_cfg_file: str = "base_cfg.yml",
131131
particle_file: str = "particle_ik.yml",
132-
gradient_file: str = "gradient_ik.yml",
132+
gradient_file: str = "gradient_ik_autotune.yml",
133133
use_cuda_graph: bool = True,
134134
self_collision_check: bool = True,
135135
self_collision_opt: bool = True,

0 commit comments

Comments
 (0)