Skip to content

Update to Drake 1.42 #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 3, 2025
Merged
25 changes: 22 additions & 3 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
registry_config: ENCRYPTED[!0a87ac67e240c5bb89044f49c6437615cec7c22faa151949f0648b04911a9e30785a97d897d8796745cb9f72a18732ec!]
registry_config: ENCRYPTED[!88cf0d757d2f8b93dca9e57dc166b65ddedef6378e7ac12a91a022ab3fb28dd47b10d452dc5c53a68e144e6bdbae999b!]
build_jammy_task:
timeout_in: 120m
container:
image: docker.io/michaelposa/jammy-dair-base:latest
image: ghcr.io/dairlab/docker-dair/jammy-dair-base:v1.42
cpu: 8
memory: 24G
test_script:
- bazel build
--local_resources=memory=24000
--local_resources=cpu=8
--jobs=8
--remote_http_cache=http://$CIRRUS_HTTP_CACHE_HOST
//...
- bazel test
--local_resources=memory=24000
--local_resources=cpu=8
--remote_http_cache=http://$CIRRUS_HTTP_CACHE_HOST
//...

build_noble_task:
timeout_in: 120m
container:
image: ghcr.io/dairlab/docker-dair/noble-dair-base:v1.42
cpu: 8
memory: 24G
test_script:
Expand All @@ -21,7 +40,7 @@ build_jammy_task:
drake_master_build_task:
timeout_in: 120m
container:
image: docker.io/michaelposa/jammy-dair-base
image: ghcr.io/dairlab/docker-dair/jammy-dair-base:v1.42
cpu: 8
memory: 24G
allow_failures: true
Expand Down
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ bazel_dep(name = "inekf")
# this will also work to override inekf

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

# Before changing the DRAKE_VERSION, temporarily uncomment the next line so that Bazel
# displays the suggested new value for the CHECKSUM.
Expand Down
19 changes: 5 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
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.

## Current Continuous Integration Status
* `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)
* `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)
* `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)
* 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)
* `master` 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)
* `master` 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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our main branch is now main.

* 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)
## Complete Build Instructions

### Download dairlib
Expand All @@ -29,21 +28,13 @@ There is no need to extract the tar.
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:

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

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.

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.

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.
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.

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

#### Option 2: source install of Drake
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.
```
export DAIRLIB_LOCAL_DRAKE_PATH=/home/user/my-workspace/drake
```
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.

### IDE setup
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.
Expand Down
17 changes: 13 additions & 4 deletions bindings/pydairlib/cassie/simulators_py.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,34 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>


#include "drake/bindings/pydrake/pydrake_pybind.h"

#include "examples/Cassie/diagrams/cassie_sim_diagram.h"

namespace py = pybind11;

namespace dairlib {
namespace pydairlib {

using drake::pydrake::make_unowned_shared_ptr_from_raw;
using examples::CassieSimDiagram;

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

using py_rvp = py::return_value_policy;

py::class_<dairlib::examples::CassieSimDiagram,
py::class_<CassieSimDiagram,
drake::systems::Diagram<double>>(m, "CassieSimDiagram")
.def(py::init<
std::unique_ptr<drake::multibody::MultibodyPlant<double>>,
const std::string&, bool, double, double, double>(),
.def(py::init(
[](drake::multibody::MultibodyPlant<double>& plant,
const std::string& urdf, bool visualize, double mu,
double stiffness, double dissipation_rate) {
return std::make_unique<CassieSimDiagram>(
make_unowned_shared_ptr_from_raw(&plant), urdf, visualize,
mu);
}),
py::arg("plant"), py::arg("urdf"), py::arg("visualize"), py::arg("mu"), py::arg("stiffness"),
py::arg("dissipation_rate"))
.def("get_plant", &CassieSimDiagram::get_plant,
Expand Down
1 change: 1 addition & 0 deletions bindings/pydairlib/systems/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pybind_py_library(
"//lcmtypes:lcmt_robot",
"//systems/framework:lcm_driven_loop",
"//systems/framework:vector",
"@drake//bindings/pydrake/common:value_pybind",
"@drake//:drake_shared_library",
],
cc_so_name = "framework",
Expand Down
28 changes: 22 additions & 6 deletions bindings/pydairlib/systems/framework_py.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,38 @@

#include "dairlib/lcmt_robot_output.hpp"

#include "drake/bindings/pydrake/pydrake_pybind.h"

namespace py = pybind11;

namespace dairlib {
namespace pydairlib {

using drake::pydrake::make_unowned_shared_ptr_from_raw;
using LcmOutputDrivenLoop = systems::LcmDrivenLoop<dairlib::lcmt_robot_output>;

PYBIND11_MODULE(framework, m) {

py::class_<LcmOutputDrivenLoop>(m, "LcmOutputDrivenLoop")
.def(py::init<drake::lcm::DrakeLcm*,
std::unique_ptr<drake::systems::Diagram<double>>,
const drake::systems::LeafSystem<double>*,
const std::string&, bool>(), py::arg("drake_lcm"),
py::arg("diagram"), py::arg("lcm_parser"),
py::arg("input_channel"), py::arg("is_forced_publish"))
.def(py::init(
[](drake::lcm::DrakeLcm* drake_lcm,
drake::systems::Diagram<double>& diagram,
const drake::systems::LeafSystem<double>* lcm_parser,
const std::string& input_channel, bool is_forced_publish) {
// The C++ constructor doesn't offer a bare-pointer overload,
// only shared_ptr. Because object lifetime is already
// handled by the ref_cycle annotation below (as required for
// all subclasses of Diagram), we can pass the `plant` as an
// unowned shared_ptr.
// (comment taken from Drakes controllers_py.cc)
return std::make_unique<LcmOutputDrivenLoop>(
drake_lcm, make_unowned_shared_ptr_from_raw(&diagram),
lcm_parser, input_channel, is_forced_publish);

}),
py::arg("drake_lcm"),
py::arg("diagram"), py::arg("lcm_parser"),
py::arg("input_channel"), py::arg("is_forced_publish"))
.def("Simulate", &LcmOutputDrivenLoop::Simulate,
py::arg("end_time") = std::numeric_limits<double>::infinity());

Expand Down
8 changes: 4 additions & 4 deletions examples/Cassie/cassie_lcm_driven_loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class CassieLcmDrivenLoop {
/// @param input_channel The name of the input channel
/// @param is_forced_publish A flag which enables publishing via diagram.
CassieLcmDrivenLoop(drake::lcm::DrakeLcm* drake_lcm,
std::unique_ptr<drake::systems::Diagram<double>> diagram,
std::shared_ptr<drake::systems::Diagram<double>> diagram,
const drake::systems::LeafSystem<double>* lcm_parser,
const std::string& input_channel, bool is_forced_publish)
: CassieLcmDrivenLoop(drake_lcm, std::move(diagram), lcm_parser,
Expand All @@ -84,7 +84,7 @@ class CassieLcmDrivenLoop {
/// @param switch_channel The name of the switch channel
/// @param is_forced_publish A flag which enables publishing via diagram.
CassieLcmDrivenLoop(drake::lcm::DrakeLcm* drake_lcm,
std::unique_ptr<drake::systems::Diagram<double>> diagram,
std::shared_ptr<drake::systems::Diagram<double>> diagram,
const drake::systems::LeafSystem<double>* lcm_parser,
std::vector<std::string> input_channels,
const std::string& active_channel,
Expand All @@ -99,7 +99,7 @@ class CassieLcmDrivenLoop {
}
diagram_ptr_ = diagram.get();
simulator_ =
std::make_unique<drake::systems::Simulator<double>>(std::move(diagram));
std::make_unique<drake::systems::Simulator<double>>(*diagram);

// Create subscriber for the switch (in the case of multi-input)
DRAKE_DEMAND(!input_channels.empty());
Expand Down Expand Up @@ -145,7 +145,7 @@ class CassieLcmDrivenLoop {
/// @param is_forced_publish A flag which enables publishing via diagram.
/// The use case is that the user only need the time from lcm message.
CassieLcmDrivenLoop(drake::lcm::DrakeLcm* drake_lcm,
std::unique_ptr<drake::systems::Diagram<double>> diagram,
std::shared_ptr<drake::systems::Diagram<double>> diagram,
const std::string& input_channel, bool is_forced_publish)
: CassieLcmDrivenLoop(drake_lcm, std::move(diagram), nullptr,
std::vector<std::string>(1, input_channel),
Expand Down
2 changes: 1 addition & 1 deletion examples/Cassie/diagrams/cassie_sim_diagram.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ using Eigen::Vector3d;
using Eigen::VectorXd;

CassieSimDiagram::CassieSimDiagram(
std::unique_ptr<drake::multibody::MultibodyPlant<double>> plant,
std::shared_ptr<drake::multibody::MultibodyPlant<double>> plant,
const std::string& urdf, bool visualize, double mu, double stiffness,
double dissipation_rate) {
DiagramBuilder<double> builder;
Expand Down
2 changes: 1 addition & 1 deletion examples/Cassie/diagrams/cassie_sim_diagram.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CassieSimDiagram : public drake::systems::Diagram<double> {
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(CassieSimDiagram)

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

Expand Down
6 changes: 4 additions & 2 deletions examples/Cassie/dispatcher_robot_in.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
namespace dairlib {
using drake::lcm::Subscriber;
using drake::systems::Context;
using drake::systems::Diagram;
using drake::systems::DiagramBuilder;
using drake::systems::Simulator;
using drake::systems::TriggerType;
Expand Down Expand Up @@ -188,7 +189,8 @@ int do_main(int argc, char* argv[]) {

// Finish building the diagram
auto owned_diagram = builder.Build();
owned_diagram->set_name("dispatcher_robot_in");
std::shared_ptr<Diagram<double>> shared_diagram = std::move(owned_diagram);
shared_diagram->set_name("dispatcher_robot_in");

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

Expand Down
6 changes: 4 additions & 2 deletions examples/Cassie/run_osc_jumping_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ using drake::geometry::SceneGraph;
using drake::multibody::Frame;
using drake::multibody::MultibodyPlant;
using drake::multibody::Parser;
using drake::systems::Diagram;
using drake::systems::DiagramBuilder;
using drake::systems::TriggerType;
using drake::systems::TriggerTypeSet;
Expand Down Expand Up @@ -549,11 +550,12 @@ int DoMain(int argc, char* argv[]) {
// Run lcm-driven simulation
// Create the diagram
auto owned_diagram = builder.Build();
owned_diagram->set_name(("osc_jumping_controller"));
std::shared_ptr<Diagram<double>> shared_diagram = std::move(owned_diagram);
shared_diagram->set_name(("osc_jumping_controller"));

// Run lcm-driven simulation
systems::LcmDrivenLoop<dairlib::lcmt_robot_output> loop(
&lcm, std::move(owned_diagram), state_receiver, FLAGS_channel_x, true);
&lcm, shared_diagram, state_receiver, FLAGS_channel_x, true);
DrawAndSaveDiagramGraph(*loop.get_diagram());
loop.Simulate();

Expand Down
6 changes: 4 additions & 2 deletions examples/Cassie/run_osc_running_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ using drake::geometry::SceneGraph;
using drake::multibody::Frame;
using drake::multibody::MultibodyPlant;
using drake::multibody::Parser;
using drake::systems::Diagram;
using drake::systems::DiagramBuilder;
using drake::systems::TriggerType;
using drake::systems::TriggerTypeSet;
Expand Down Expand Up @@ -607,10 +608,11 @@ int DoMain(int argc, char* argv[]) {
contact_scheduler_debug_publisher->get_input_port());

auto owned_diagram = builder.Build();
owned_diagram->set_name(("osc_running_controller"));
std::shared_ptr<Diagram<double>> shared_diagram = std::move(owned_diagram);
shared_diagram->set_name(("osc_running_controller"));

systems::LcmDrivenLoop<dairlib::lcmt_robot_output> loop(
&lcm, std::move(owned_diagram), state_receiver, FLAGS_channel_x, true);
&lcm, shared_diagram, state_receiver, FLAGS_channel_x, true);
DrawAndSaveDiagramGraph(*loop.get_diagram());

loop.Simulate();
Expand Down
6 changes: 4 additions & 2 deletions examples/Cassie/run_osc_standing_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ using Eigen::VectorXd;
using drake::geometry::SceneGraph;
using drake::multibody::MultibodyPlant;
using drake::multibody::Parser;
using drake::systems::Diagram;
using drake::systems::DiagramBuilder;
using drake::systems::TriggerType;
using drake::systems::TriggerTypeSet;
Expand Down Expand Up @@ -285,11 +286,12 @@ int DoMain(int argc, char* argv[]) {

// Create the diagram
auto owned_diagram = builder.Build();
owned_diagram->set_name(("osc_standing_controller"));
std::shared_ptr<Diagram<double>> shared_diagram = std::move(owned_diagram);
shared_diagram->set_name(("osc_standing_controller"));

// Build lcm-driven simulation
systems::LcmDrivenLoop<dairlib::lcmt_robot_output> loop(
&lcm_local, std::move(owned_diagram), state_receiver, FLAGS_channel_x,
&lcm_local, shared_diagram, state_receiver, FLAGS_channel_x,
true);
DrawAndSaveDiagramGraph(*loop.get_diagram());

Expand Down
8 changes: 5 additions & 3 deletions examples/Cassie/run_osc_walking_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ using Eigen::Vector3d;
using Eigen::VectorXd;

using drake::multibody::Frame;
using drake::systems::Diagram;
using drake::systems::DiagramBuilder;
using drake::systems::TriggerType;
using drake::systems::TriggerTypeSet;
Expand Down Expand Up @@ -620,12 +621,13 @@ int DoMain(int argc, char* argv[]) {

// Create the diagram
auto owned_diagram = builder.Build();
owned_diagram->set_name("osc walking controller");
std::shared_ptr<Diagram<double>> shared_diagram = std::move(owned_diagram);
shared_diagram->set_name("osc walking controller");

// Run lcm-driven simulation
DrawAndSaveDiagramGraph(*owned_diagram);
DrawAndSaveDiagramGraph(*shared_diagram);
systems::LcmDrivenLoop<dairlib::lcmt_robot_output> loop(
&lcm_local, std::move(owned_diagram), state_receiver, FLAGS_channel_x,
&lcm_local, shared_diagram, state_receiver, FLAGS_channel_x,
true);
loop.Simulate();

Expand Down
6 changes: 4 additions & 2 deletions examples/Cassie/run_osc_walking_controller_alip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ using Eigen::Vector3d;
using Eigen::VectorXd;

using drake::multibody::Frame;
using drake::systems::Diagram;
using drake::systems::DiagramBuilder;
using drake::systems::TriggerType;
using drake::systems::TriggerTypeSet;
Expand Down Expand Up @@ -618,11 +619,12 @@ int DoMain(int argc, char* argv[]) {

// Create the diagram
auto owned_diagram = builder.Build();
owned_diagram->set_name("osc walking controller");
std::shared_ptr<Diagram<double>> shared_diagram = std::move(owned_diagram);
shared_diagram->set_name("osc walking controller");

// Run lcm-driven simulation
systems::LcmDrivenLoop<dairlib::lcmt_robot_output> loop(
&lcm_local, std::move(owned_diagram), state_receiver, FLAGS_channel_x,
&lcm_local, shared_diagram, state_receiver, FLAGS_channel_x,
true);
loop.Simulate();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ using drake::geometry::SceneGraph;
using drake::multibody::Frame;
using drake::multibody::MultibodyPlant;
using drake::multibody::Parser;
using drake::systems::Diagram;
using drake::systems::DiagramBuilder;
using drake::systems::TriggerType;
using drake::systems::TriggerTypeSet;
Expand Down Expand Up @@ -206,11 +207,12 @@ int DoMain(int argc, char* argv[]) {
// Run lcm-driven simulation
// Create the diagram
auto owned_diagram = builder.Build();
owned_diagram->set_name(("id_walking_controller"));
std::shared_ptr<Diagram<double>> shared_diagram = std::move(owned_diagram);
shared_diagram->set_name(("id_walking_controller"));

// Run lcm-driven simulation
systems::LcmDrivenLoop<dairlib::lcmt_robot_output> loop(
&lcm, std::move(owned_diagram), state_receiver, FLAGS_channel_x, true);
&lcm, shared_diagram, state_receiver, FLAGS_channel_x, true);
loop.Simulate();

return 0;
Expand Down
Loading