Skip to content

Commit 720d12b

Browse files
committed
feat: bring output publishers from dairlib to c3
1 parent dad2fb5 commit 720d12b

18 files changed

+518
-34
lines changed

core/BUILD.bazel

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ cc_library(
2929
"c3.h",
3030
"c3_miqp.h",
3131
"c3_qp.h",
32+
"configs/solve_options_default.hpp"
3233
],
3334
copts = ["-fopenmp"],
3435
linkopts = ["-fopenmp"],
35-
data = glob([
36-
"configs/**",
37-
]),
3836
deps = [
3937
":lcs",
4038
":options",

core/c3.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "lcs.h"
1010
#include "solver_options_io.h"
11+
#include "configs/solve_options_default.hpp"
1112

1213
#include "drake/common/text_logging.h"
1314
#include "drake/solvers/mathematical_program.h"
@@ -154,8 +155,7 @@ C3::C3(const LCS& lcs, const CostMatrices& costs,
154155

155156
// Set default solver options
156157
drake::solvers::SolverOptions solver_options =
157-
drake::yaml::LoadYamlFile<c3::SolverOptionsFromYaml>(
158-
"core/configs/solver_options_default.yaml")
158+
drake::yaml::LoadYamlString<c3::SolverOptionsFromYaml>(default_solver_options)
159159
.GetAsSolverOptions(drake::solvers::OsqpSolver::id());
160160
SetSolverOptions(solver_options);
161161
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
#include <string>
3+
const std::string default_solver_options =
4+
"print_to_console: 0\nlog_file_name: \"\"\nint_options:\n max_iter: "
5+
"1000\n # linsys_solver: 0\n verbose: 0\n warm_start: 1\n polish: 1\n "
6+
"scaled_termination: 1\n check_termination: 25\n polish_refine_iter: 3\n "
7+
" scaling: 10\n adaptive_rho: 1\n adaptive_rho_interval: "
8+
"0\n\ndouble_options:\n rho: 0.0001\n sigma: 1e-6\n eps_abs: 1e-5\n "
9+
"eps_rel: 1e-5\n eps_prim_inf: 1e-5\n eps_dual_inf: 1e-5\n alpha: 1.6\n "
10+
" delta: 1e-6\n adaptive_rho_tolerance: 5\n adaptive_rho_fraction: 0.4\n "
11+
" time_limit: 1.0\n\nstring_options: {}";

core/configs/solver_options_default.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

lcmtypes/BUILD.bazel

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
load(
2+
"@drake//tools/skylark:drake_lcm.bzl",
3+
"drake_lcm_cc_library",
4+
"drake_lcm_java_library",
5+
"drake_lcm_py_library",
6+
)
7+
load(
8+
"@drake//tools/skylark:drake_java.bzl",
9+
"drake_java_binary",
10+
)
11+
load("@drake//tools/lint:lint.bzl", "add_lint_tests")
12+
13+
package(default_visibility = ["//visibility:public"])
14+
15+
#Lcm libraries
16+
drake_lcm_cc_library(
17+
name = "lcmt_c3",
18+
lcm_package = "c3",
19+
lcm_srcs = glob(["*.lcm"]),
20+
)
21+
22+
drake_lcm_java_library(
23+
name = "lcmtypes_c3_java",
24+
lcm_package = "c3",
25+
lcm_srcs = glob(["*.lcm"]),
26+
)
27+
28+
drake_lcm_py_library(
29+
name = "lcmtypes_c3_py",
30+
add_current_package_to_imports = True, # Use //:module_py instead.
31+
extra_srcs = ["__init__.py"],
32+
lcm_package = "c3",
33+
lcm_srcs = glob(["*.lcm"]),
34+
deps = [
35+
"@drake//:module_py",
36+
],
37+
)
38+
39+
drake_java_binary(
40+
name = "c3-lcm-spy",
41+
main_class = "lcm.spy.Spy",
42+
visibility = ["//visibility:private"],
43+
runtime_deps = [
44+
":lcmtypes_c3_java",
45+
"@drake//lcmtypes:lcmtypes_drake_java",
46+
],
47+
)

lcmtypes/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Empty Python module `__init__`, required to make this a module.

lcmtypes/lcmt_contact_force.lcm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package c3;
2+
3+
/* lcmtype containing information to visualize forces in meshcat
4+
*/
5+
struct lcmt_contact_force
6+
{
7+
int64_t utime;
8+
9+
// These are all expressed in the world frame.
10+
double contact_point[3];
11+
double contact_force[3];
12+
}

lcmtypes/lcmt_forces.lcm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package c3;
2+
3+
/* lcmtype containing information to visualize forces in meshcat
4+
*/
5+
struct lcmt_forces
6+
{
7+
int64_t utime;
8+
9+
int32_t num_forces;
10+
lcmt_contact_force forces[num_forces];
11+
}

lcmtypes/lcmt_intermediates.lcm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package c3;
2+
3+
struct lcmt_intermediates
4+
{
5+
int32_t num_points;
6+
int32_t num_total_variables;
7+
8+
float time_vec[num_points];
9+
float z_sol[num_total_variables][num_points];
10+
float delta_sol[num_total_variables][num_points];
11+
float w_sol[num_total_variables][num_points];
12+
}

lcmtypes/lcmt_output.lcm

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package c3;
2+
3+
struct lcmt_output
4+
{
5+
int64_t utime;
6+
7+
lcmt_solution solution;
8+
lcmt_intermediates intermediates;
9+
}

0 commit comments

Comments
 (0)