Skip to content

Commit add39f2

Browse files
mposaebianchi
andauthored
Update to Drake 1.42 (#382)
* Update to Drake 1.42 * Switch to GHCR image with Cirrus secret * Add noble CI task * Update LcmDrivenLoop and CassieLcmDrivenLoop to shared_ptr for upstream pybind changes --------- Co-authored-by: Bibit Bianchini <[email protected]>
1 parent 1e6b8e3 commit add39f2

19 files changed

+115
-61
lines changed

.cirrus.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
registry_config: ENCRYPTED[!0a87ac67e240c5bb89044f49c6437615cec7c22faa151949f0648b04911a9e30785a97d897d8796745cb9f72a18732ec!]
1+
registry_config: ENCRYPTED[!88cf0d757d2f8b93dca9e57dc166b65ddedef6378e7ac12a91a022ab3fb28dd47b10d452dc5c53a68e144e6bdbae999b!]
22
build_jammy_task:
33
timeout_in: 120m
44
container:
5-
image: docker.io/michaelposa/jammy-dair-base:latest
5+
image: ghcr.io/dairlab/docker-dair/jammy-dair-base:v1.42
6+
cpu: 8
7+
memory: 24G
8+
test_script:
9+
- bazel build
10+
--local_resources=memory=24000
11+
--local_resources=cpu=8
12+
--jobs=8
13+
--remote_http_cache=http://$CIRRUS_HTTP_CACHE_HOST
14+
//...
15+
- bazel test
16+
--local_resources=memory=24000
17+
--local_resources=cpu=8
18+
--remote_http_cache=http://$CIRRUS_HTTP_CACHE_HOST
19+
//...
20+
21+
build_noble_task:
22+
timeout_in: 120m
23+
container:
24+
image: ghcr.io/dairlab/docker-dair/noble-dair-base:v1.42
625
cpu: 8
726
memory: 24G
827
test_script:
@@ -21,7 +40,7 @@ build_jammy_task:
2140
drake_master_build_task:
2241
timeout_in: 120m
2342
container:
24-
image: docker.io/michaelposa/jammy-dair-base
43+
image: ghcr.io/dairlab/docker-dair/jammy-dair-base:v1.42
2544
cpu: 8
2645
memory: 24G
2746
allow_failures: true

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ bazel_dep(name = "inekf")
7171
# this will also work to override inekf
7272

7373
# You can also use DRAKE_COMMIT to choose a Drake release; e.g.:
74-
DRAKE_VERSION = "v1.39.0"
75-
DRAKE_CHECKSUM = "63eb9455181ce9aeb9746e60531fbd4fbe731ea44539276e662e1236a78589b6"
74+
DRAKE_VERSION = "v1.42.0"
75+
DRAKE_CHECKSUM = "d860c15f50397c8a946fcc79e0a58a91ebc56f2189ef9edfcac929aa04157f8b"
7676

7777
# Before changing the DRAKE_VERSION, temporarily uncomment the next line so that Bazel
7878
# displays the suggested new value for the CHECKSUM.

README.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
Warning! This is very much "development-level" code and is provided as-is. APIs are likely to be unstable and, while we hope for the documentation to be thorough and accurate, we make no guarantees.
33

44
## Current Continuous Integration Status
5-
* `master` branch build and unit tests (Ubuntu 18.04): [![Build Status](https://api.cirrus-ci.com/github/DAIRLab/dairlib.svg?task=build&script=test)](https://cirrus-ci.com/github/DAIRLab/dairlib)
6-
* `master` branch build and unit tests (Ubuntu 20.04): [![Build Status](https://api.cirrus-ci.com/github/DAIRLab/dairlib.svg?task=build_focal&script=test)](https://cirrus-ci.com/github/DAIRLab/dairlib)
7-
* `master` branch build and unit tests (Ubuntu 20.04 with ROS): [![Build Status](https://api.cirrus-ci.com/github/DAIRLab/dairlib.svg?task=build_with_ros&script=test)](https://cirrus-ci.com/github/DAIRLab/dairlib)
8-
* Experimental build against Drake's `master` branch: [![Build Status](https://api.cirrus-ci.com/github/DAIRLab/dairlib.svg?task=drake_master_build&script=test)](https://cirrus-ci.com/github/DAIRLab/dairlib)
5+
* `main` branch build and unit tests (Ubuntu Jammy 22.04): [![Build Status](https://api.cirrus-ci.com/github/DAIRLab/dairlib.svg?task=build_jammy&script=test)](https://cirrus-ci.com/github/DAIRLab/dairlib)
6+
* `main` branch build and unit tests (Ubuntu Focal 24.04): [![Build Status](https://api.cirrus-ci.com/github/DAIRLab/dairlib.svg?task=build_focal&script=test)](https://cirrus-ci.com/github/DAIRLab/dairlib)
7+
* Experimental build against Drake's `master` branch (Jammy): [![Build Status](https://api.cirrus-ci.com/github/DAIRLab/dairlib.svg?task=drake_master_build&script=test)](https://cirrus-ci.com/github/DAIRLab/dairlib)
98
## Complete Build Instructions
109

1110
### Download dairlib
@@ -29,21 +28,13 @@ There is no need to extract the tar.
2928
The library is meant to be built with Drake (see http://drake.mit.edu/ for more details). There are two ways to use Drake within dairlib:
3029

3130
#### Option 1: use pegged revision (Note - These steps may need repeated if switching to a branch with a different pegged revision of drake).
32-
The only specific action needed here is to install all of Drake's prerequisites. There are two choices for completing this step:
3331

34-
a) In `dairlib/install`, run the appropriate `install_prereqs_xxx.sh`. This is untested on mac, and has not been tested to get every dependency for a fresh install.
35-
36-
b) Download a source copy of drake, and install pre-requisites as described here: http://drake.mit.edu/from_source.html. Drake dependencies can change without notice. For full compatiability, you may need to checkout the drake commit which is pegged in WORKSPACE to install the correct dependencies. There is no need to build Drake itself. Proceed only until you have run the Drake setup script.
37-
38-
bazel will automatically download the pegged revision, specified in the WORKSPACE file. dairlib developers hope to keep this pegged revision current, and ensure that the pegged version will always work with a specific version of dairlib.
32+
In `dairlib/install`, run the `install_prereqs_ubuntu.sh`. Our build process does not currently support MacOS, though it has in the past and likely will in the future.
3933

4034
This option is recommended for users who are not currently editing any source code in Drake itself.
4135

4236
#### Option 2: source install of Drake
43-
Complete both steps (a) and (b) above. By running the drake install script after the dairlib install script, you are capturing any dependency changes between the pegged revision and the current Drake master, while still getting any aditional dairlib dependencies we may add. There is no need to build Drake. Next, to tell dairlib to use your local install, set the environment variable `DAIRLIB_LOCAL_DRAKE_PATH`, e.g.
44-
```
45-
export DAIRLIB_LOCAL_DRAKE_PATH=/home/user/my-workspace/drake
46-
```
37+
If you would like to use your own local install of Drake, likely because you are modifying it, when you build with Bazel you will need to use `bazel build --override_module=drake=/home/user/my-workspace/drake <package you are building>` (using the appropriate directory for your own install). There is no need to build Drake.
4738

4839
### IDE setup
4940
JetBrains IDEs have worked well for us and are available for free to students. For C++ development using the CLion Bazel plugin, see https://drake.mit.edu/clion.html and replace `drake` with `dairlib` in the "Setting up Drake in CLion" section.

bindings/pydairlib/cassie/simulators_py.cc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,34 @@
33
#include <pybind11/pybind11.h>
44
#include <pybind11/stl.h>
55

6+
7+
#include "drake/bindings/pydrake/pydrake_pybind.h"
8+
69
#include "examples/Cassie/diagrams/cassie_sim_diagram.h"
710

811
namespace py = pybind11;
912

1013
namespace dairlib {
1114
namespace pydairlib {
1215

16+
using drake::pydrake::make_unowned_shared_ptr_from_raw;
1317
using examples::CassieSimDiagram;
1418

1519
PYBIND11_MODULE(simulators, m) {
1620
m.doc() = "Binding controller factories for Cassie";
1721

1822
using py_rvp = py::return_value_policy;
1923

20-
py::class_<dairlib::examples::CassieSimDiagram,
24+
py::class_<CassieSimDiagram,
2125
drake::systems::Diagram<double>>(m, "CassieSimDiagram")
22-
.def(py::init<
23-
std::unique_ptr<drake::multibody::MultibodyPlant<double>>,
24-
const std::string&, bool, double, double, double>(),
26+
.def(py::init(
27+
[](drake::multibody::MultibodyPlant<double>& plant,
28+
const std::string& urdf, bool visualize, double mu,
29+
double stiffness, double dissipation_rate) {
30+
return std::make_unique<CassieSimDiagram>(
31+
make_unowned_shared_ptr_from_raw(&plant), urdf, visualize,
32+
mu);
33+
}),
2534
py::arg("plant"), py::arg("urdf"), py::arg("visualize"), py::arg("mu"), py::arg("stiffness"),
2635
py::arg("dissipation_rate"))
2736
.def("get_plant", &CassieSimDiagram::get_plant,

bindings/pydairlib/systems/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pybind_py_library(
4747
"//lcmtypes:lcmt_robot",
4848
"//systems/framework:lcm_driven_loop",
4949
"//systems/framework:vector",
50+
"@drake//bindings/pydrake/common:value_pybind",
5051
"@drake//:drake_shared_library",
5152
],
5253
cc_so_name = "framework",

bindings/pydairlib/systems/framework_py.cc

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,38 @@
99

1010
#include "dairlib/lcmt_robot_output.hpp"
1111

12+
#include "drake/bindings/pydrake/pydrake_pybind.h"
13+
1214
namespace py = pybind11;
1315

1416
namespace dairlib {
1517
namespace pydairlib {
1618

19+
using drake::pydrake::make_unowned_shared_ptr_from_raw;
1720
using LcmOutputDrivenLoop = systems::LcmDrivenLoop<dairlib::lcmt_robot_output>;
1821

1922
PYBIND11_MODULE(framework, m) {
2023

2124
py::class_<LcmOutputDrivenLoop>(m, "LcmOutputDrivenLoop")
22-
.def(py::init<drake::lcm::DrakeLcm*,
23-
std::unique_ptr<drake::systems::Diagram<double>>,
24-
const drake::systems::LeafSystem<double>*,
25-
const std::string&, bool>(), py::arg("drake_lcm"),
26-
py::arg("diagram"), py::arg("lcm_parser"),
27-
py::arg("input_channel"), py::arg("is_forced_publish"))
25+
.def(py::init(
26+
[](drake::lcm::DrakeLcm* drake_lcm,
27+
drake::systems::Diagram<double>& diagram,
28+
const drake::systems::LeafSystem<double>* lcm_parser,
29+
const std::string& input_channel, bool is_forced_publish) {
30+
// The C++ constructor doesn't offer a bare-pointer overload,
31+
// only shared_ptr. Because object lifetime is already
32+
// handled by the ref_cycle annotation below (as required for
33+
// all subclasses of Diagram), we can pass the `plant` as an
34+
// unowned shared_ptr.
35+
// (comment taken from Drakes controllers_py.cc)
36+
return std::make_unique<LcmOutputDrivenLoop>(
37+
drake_lcm, make_unowned_shared_ptr_from_raw(&diagram),
38+
lcm_parser, input_channel, is_forced_publish);
39+
40+
}),
41+
py::arg("drake_lcm"),
42+
py::arg("diagram"), py::arg("lcm_parser"),
43+
py::arg("input_channel"), py::arg("is_forced_publish"))
2844
.def("Simulate", &LcmOutputDrivenLoop::Simulate,
2945
py::arg("end_time") = std::numeric_limits<double>::infinity());
3046

examples/Cassie/cassie_lcm_driven_loop.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class CassieLcmDrivenLoop {
6767
/// @param input_channel The name of the input channel
6868
/// @param is_forced_publish A flag which enables publishing via diagram.
6969
CassieLcmDrivenLoop(drake::lcm::DrakeLcm* drake_lcm,
70-
std::unique_ptr<drake::systems::Diagram<double>> diagram,
70+
std::shared_ptr<drake::systems::Diagram<double>> diagram,
7171
const drake::systems::LeafSystem<double>* lcm_parser,
7272
const std::string& input_channel, bool is_forced_publish)
7373
: CassieLcmDrivenLoop(drake_lcm, std::move(diagram), lcm_parser,
@@ -84,7 +84,7 @@ class CassieLcmDrivenLoop {
8484
/// @param switch_channel The name of the switch channel
8585
/// @param is_forced_publish A flag which enables publishing via diagram.
8686
CassieLcmDrivenLoop(drake::lcm::DrakeLcm* drake_lcm,
87-
std::unique_ptr<drake::systems::Diagram<double>> diagram,
87+
std::shared_ptr<drake::systems::Diagram<double>> diagram,
8888
const drake::systems::LeafSystem<double>* lcm_parser,
8989
std::vector<std::string> input_channels,
9090
const std::string& active_channel,
@@ -99,7 +99,7 @@ class CassieLcmDrivenLoop {
9999
}
100100
diagram_ptr_ = diagram.get();
101101
simulator_ =
102-
std::make_unique<drake::systems::Simulator<double>>(std::move(diagram));
102+
std::make_unique<drake::systems::Simulator<double>>(*diagram);
103103

104104
// Create subscriber for the switch (in the case of multi-input)
105105
DRAKE_DEMAND(!input_channels.empty());
@@ -145,7 +145,7 @@ class CassieLcmDrivenLoop {
145145
/// @param is_forced_publish A flag which enables publishing via diagram.
146146
/// The use case is that the user only need the time from lcm message.
147147
CassieLcmDrivenLoop(drake::lcm::DrakeLcm* drake_lcm,
148-
std::unique_ptr<drake::systems::Diagram<double>> diagram,
148+
std::shared_ptr<drake::systems::Diagram<double>> diagram,
149149
const std::string& input_channel, bool is_forced_publish)
150150
: CassieLcmDrivenLoop(drake_lcm, std::move(diagram), nullptr,
151151
std::vector<std::string>(1, input_channel),

examples/Cassie/diagrams/cassie_sim_diagram.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ using Eigen::Vector3d;
4242
using Eigen::VectorXd;
4343

4444
CassieSimDiagram::CassieSimDiagram(
45-
std::unique_ptr<drake::multibody::MultibodyPlant<double>> plant,
45+
std::shared_ptr<drake::multibody::MultibodyPlant<double>> plant,
4646
const std::string& urdf, bool visualize, double mu, double stiffness,
4747
double dissipation_rate) {
4848
DiagramBuilder<double> builder;

examples/Cassie/diagrams/cassie_sim_diagram.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CassieSimDiagram : public drake::systems::Diagram<double> {
2121
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(CassieSimDiagram)
2222

2323
/// @param[in] urdf filepath containing the osc_running_gains.
24-
CassieSimDiagram(std::unique_ptr<drake::multibody::MultibodyPlant<double>> plant,
24+
CassieSimDiagram(std::shared_ptr<drake::multibody::MultibodyPlant<double>> plant,
2525
const std::string& urdf = "examples/Cassie/urdf/cassie_v2.urdf", bool visualize = false,
2626
double mu = 0.8, double stiffness = 1e4, double dissipation_rate = 1e2);
2727

examples/Cassie/dispatcher_robot_in.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
namespace dairlib {
2828
using drake::lcm::Subscriber;
2929
using drake::systems::Context;
30+
using drake::systems::Diagram;
3031
using drake::systems::DiagramBuilder;
3132
using drake::systems::Simulator;
3233
using drake::systems::TriggerType;
@@ -188,7 +189,8 @@ int do_main(int argc, char* argv[]) {
188189

189190
// Finish building the diagram
190191
auto owned_diagram = builder.Build();
191-
owned_diagram->set_name("dispatcher_robot_in");
192+
std::shared_ptr<Diagram<double>> shared_diagram = std::move(owned_diagram);
193+
shared_diagram->set_name("dispatcher_robot_in");
192194

193195
// Channel names of the controllers
194196
std::vector<std::string> input_channels = {FLAGS_control_channel_name_initial,
@@ -204,7 +206,7 @@ int do_main(int argc, char* argv[]) {
204206
// Run lcm-driven simulation
205207
CassieLcmDrivenLoop<dairlib::lcmt_robot_input,
206208
dairlib::lcmt_controller_switch>
207-
loop(&lcm_local, std::move(owned_diagram), command_receiver,
209+
loop(&lcm_local, shared_diagram, command_receiver,
208210
input_channels, FLAGS_control_channel_name_initial, switch_channel,
209211
true, FLAGS_state_channel_name);
210212

0 commit comments

Comments
 (0)