Skip to content

Commit 751e472

Browse files
committed
feat: use external c3 repo for sampling example
1 parent 4478d1e commit 751e472

File tree

14 files changed

+1117
-1065
lines changed

14 files changed

+1117
-1065
lines changed

MODULE.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ archive_override(
8989
strip_prefix = "drake-{}".format(DRAKE_VERSION.lstrip("v")),
9090
)
9191

92+
bazel_dep(name = "c3")
93+
git_override(
94+
module_name = "c3",
95+
remote = "https://github.com/DAIRLab/c3.git",
96+
commit = "5c5d55753017743108c554b6aee87bc9edc22a3b"
97+
)
98+
9299
INEKF_COMMIT = "297c308e50fa599af92ce3bd5f11d71e2bf8af69"
93100
INEKF_CHECKSUM = "c5a056ce00e1625e52f5a71b1d5c202acd53c1a8c7bca33da458db1e4f3f2edf"
94101

examples/sampling_c3/anything/parameters/sampling_c3plus_options.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
### C3 options
22
admm_iter: 3
3-
rho: 0 #This isn't used anywhere!
3+
# rho: 0 #This isn't used anywhere!
44
rho_scale: 3
55
num_threads: 5
66
num_outer_threads: 4
77
delta_option: 1
88
projection_type: 'C3+' # 'MIQP' or 'QP' or 'C3+'
99
contact_model: 'anitescu' # 'stewart_and_trinkle' or 'anitescu'.
1010
warm_start: false
11+
scale_lcs: true
1112
end_on_qp_step: false
1213
solve_time_filter_alpha: 0.95
1314
publish_frequency: 0
14-
penalize_changes_in_u_across_solves: false # Penalize (u-u_prev) instead of u.
15+
penalize_input_change: false # Penalize (u-u_prev) instead of u.
1516
num_friction_directions: 2
17+
spring_stiffness: 0.0 # Not used in C3+.
1618

1719
N: 5
1820
gamma: 1.0 # discount factor on MPC costs
@@ -142,11 +144,11 @@ u_eta_position_list: [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
142144

143145
### NO NEED TO CHANGE THE BELOW. Parameters needed for the C3Options struct but
144146
### are overwritten by other sampling C3 parameters.
145-
use_predicted_x0: false # instead: use_predicted_x0_c3,
147+
# use_predicted_x0: false # instead: use_predicted_x0_c3,
146148
# use_predicted_x0_repos,
147149
# use_predicted_x0_reset_mechanism
148150
dt: 0 # instead: planning_dt_pose, planning_dt_position
149-
solve_dt: 0 # unused
151+
# solve_dt: 0 # unused
150152
mu: [] # instead based on indexing into mu_per_pair_type
151153
num_contacts: 0 # instead based on summing index of resolve_contacts_to_lists
152154
# Instead for the below, index into their _list versions.

examples/sampling_c3/generate_samples.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "examples/sampling_c3/parameter_headers/sampling_params.h"
1111
#include "multibody/geom_geom_collider.h"
1212
#include "multibody/multibody_utils.h"
13-
#include "solvers/c3_options.h"
1413
#include <drake/geometry/query_object.h>
1514
#include "systems/controllers/face.h"
1615

examples/sampling_c3/jacktoy/parameters/sampling_c3plus_options.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
### C3 options
22
admm_iter: 3
3-
rho: 0 #This isn't used anywhere!
3+
# rho: 0 #This isn't used anywhere!
44
rho_scale: 3
55
num_threads: 5
66
num_outer_threads: 4
77
delta_option: 1
88
projection_type: 'C3+' # 'MIQP' or 'QP' or 'C3+'
99
contact_model: 'anitescu' # 'stewart_and_trinkle' or 'anitescu'.
1010
warm_start: false
11+
scale_lcs: true
1112
end_on_qp_step: false
13+
# use_robust_formulation: false
1214
solve_time_filter_alpha: 0.95
1315
publish_frequency: 0
14-
penalize_changes_in_u_across_solves: false # Penalize (u-u_prev) instead of u.
16+
penalize_input_change: false # Penalize (u-u_prev) instead of u.
1517
num_friction_directions: 2
18+
spring_stiffness: 0.0 # Not used in C3+.
1619

1720
N: 5
1821
gamma: 1.0 # discount factor on MPC costs
@@ -346,11 +349,11 @@ u_eta_position_list: [
346349

347350
### NO NEED TO CHANGE THE BELOW. Parameters needed for the C3Options struct but
348351
### are overwritten by other sampling C3 parameters.
349-
use_predicted_x0: false # instead: use_predicted_x0_c3,
352+
# use_predicted_x0: false # instead: use_predicted_x0_c3,
350353
# use_predicted_x0_repos,
351354
# use_predicted_x0_reset_mechanism
352355
dt: 0 # instead: planning_dt_pose, planning_dt_position
353-
solve_dt: 0 # unused
356+
# solve_dt: 0 # unused
354357
mu: [] # instead based on indexing into mu_per_pair_type
355358
num_contacts: 0 # instead based on summing index of resolve_contacts_to_lists
356359
# Instead for the below, index into their _list versions.

examples/sampling_c3/parameter_headers/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ cc_library(
22
name = "sampling_c3_options",
33
hdrs = ["sampling_c3_options.h"],
44
visibility = ["//visibility:public"], # Allow all subpackages to use it
5-
deps = ["//solvers:c3"]
5+
deps = ["@c3//:libc3",
6+
],
67
)
78

89
cc_library(

examples/sampling_c3/parameter_headers/progress_params.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "drake/common/yaml/yaml_read_archive.h"
44

55
#include "common/file_utils.h"
6-
#include "solvers/c3_options.h"
76

87

98
/* C3 progress metric options, all phrased as improvement requirements over a
@@ -22,6 +21,31 @@ enum ProgressMetric {
2221
kConfigCostDrop
2322
};
2423

24+
/* Ways of computing C3 costs after solving the MPC problem:
25+
0. kSimLCS: Simulate the LCS dynamics from the planned
26+
inputs.
27+
1. kUseC3Plan: Use the C3 planned trajectory and inputs.
28+
2. kSimLCSReplaceC3EEPlan: Simulate the LCS dynamics from the planned
29+
inputs only for the object; use the planned
30+
EE trajectory.
31+
3. kSimImpedance: Try to emulate the real cost of the system
32+
associated not only applying the planned
33+
inputs, but also tracking the planned EE
34+
trajectory with an impedance controller.
35+
4. kSimImpedanceReplaceC3EEPlan: The same as kSimImpedance except the EE
36+
states are replaced with the plan from C3 at
37+
the end.
38+
5. kSimImpedanceObjectCostOnly: The same as kSimImpedance except only the
39+
object terms contribute to the final cost.
40+
*/
41+
enum C3CostComputationType {
42+
kSimLCS,
43+
kUseC3Plan,
44+
kSimLCSReplaceC3EEPlan,
45+
kSimImpedance,
46+
kSimImpedanceReplaceC3EEPlan,
47+
kSimImpedanceObjectCostOnly,
48+
};
2549

2650
struct SamplingC3ProgressParams {
2751
C3CostComputationType cost_type;

0 commit comments

Comments
 (0)