├── drake_bazel_external ├── .bazelignore ├── .bazelversion ├── .gitignore ├── .bazelproject ├── BUILD.bazel ├── CPPLINT.cfg ├── apps │ ├── import_all_test.py │ ├── exec.sh │ ├── find_resource_test.py │ ├── simple_adder.cc │ ├── simple_adder.h │ ├── simple_logging_example.py │ ├── simple_adder-inl.h │ ├── simple_adder_py.cc │ ├── simple_adder_test.cc │ ├── simple_adder_py_test.py │ ├── simple_continuous_time_system.cc │ └── BUILD.bazel ├── .github │ ├── setup │ ├── ci_build_test │ └── ubuntu_setup ├── LICENSE ├── setup │ └── install_prereqs ├── README.md ├── .clang-format ├── .bazelrc └── MODULE.bazel ├── drake_bazel_download ├── .bazelversion ├── .gitignore ├── CPPLINT.cfg ├── apps │ ├── import_all_test.py │ ├── exec.sh │ ├── find_resource_test.cc │ ├── find_resource_test.py │ ├── include_paths_test.cc │ ├── simple_logging_example.py │ └── BUILD.bazel ├── eigen.bzl ├── eigen.BUILD.bazel ├── .github │ ├── ubuntu_setup │ ├── ci_build_test │ └── workflows │ │ └── ci.yml ├── setup │ ├── install_bazelisk │ └── install_prereqs ├── .bazelrc ├── BUILD.bazel ├── LICENSE ├── README.md ├── MODULE.bazel ├── .clang-format └── drake.BUILD.bazel ├── .gitattributes ├── private ├── drake_cmake_external_static │ ├── .github │ │ ├── setup │ │ ├── ci_build_test │ │ └── ubuntu_setup │ ├── setup │ │ └── install_prereqs │ ├── drake_external_examples │ │ ├── simple_continuous_time_system.cc │ │ ├── lcm_disabled_test.cc │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── README.md └── test │ └── file_sync_test.py ├── drake_cmake_external ├── .gitignore ├── CPPLINT.cfg ├── drake_external_examples │ ├── import_all_test.py │ ├── solver_disabled_test.py │ ├── CMakeLists.txt │ └── simple_continuous_time_system.cc ├── .github │ ├── setup │ ├── ubuntu_setup │ └── ci_build_test ├── LICENSE ├── setup │ └── install_prereqs ├── README.md ├── .clang-format └── CMakeLists.txt ├── drake_cmake_installed ├── .gitignore ├── CPPLINT.cfg ├── src │ ├── import_all_test.py │ ├── find_resource │ │ ├── find_resource_example.py │ │ ├── README.md │ │ ├── CMakeLists.txt │ │ └── find_resource_example.cc │ ├── simple_continuous_time_system │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ └── simple_continuous_time_system.cc │ ├── CMakeLists.txt │ ├── particle │ │ ├── CMakeLists.txt │ │ ├── particle.h │ │ ├── particle.py │ │ ├── particle.cc │ │ ├── particle_test.py │ │ └── particle_test.cc │ └── simple_bindings │ │ ├── CMakeLists.txt │ │ ├── simple_bindings_test.py │ │ └── simple_bindings.cc ├── third_party │ ├── CMakeLists.txt │ └── googletest │ │ └── LICENSE ├── .github │ ├── ci_build_test │ ├── ubuntu_setup │ └── workflows │ │ └── ci.yml ├── LICENSE ├── CMakeLists.txt ├── .clang-format ├── setup │ └── install_prereqs └── README.md ├── drake_cmake_installed_apt ├── .gitignore ├── CPPLINT.cfg ├── .github │ ├── ci_build_test │ ├── workflows │ │ └── ci.yml │ └── ubuntu_apt_setup ├── src │ ├── CMakeLists.txt │ ├── particle.h │ ├── particle.py │ ├── particle.cc │ ├── particle_test.py │ └── particle_test.cc ├── README.md ├── LICENSE ├── CMakeLists.txt ├── third_party │ ├── googletest │ │ └── 1.10 │ │ │ └── LICENSE │ └── cmake │ │ └── 3.12 │ │ ├── Copyright.txt │ │ └── Modules │ │ └── FindPython.cmake └── .clang-format ├── drake_poetry ├── .github │ ├── ci_build_test │ ├── setup │ └── workflows │ │ └── ci.yml ├── pyproject.toml ├── LICENSE ├── setup │ └── install_prereqs ├── README.md └── src │ ├── particle.py │ └── particle_test.py ├── drake_pip ├── .github │ ├── ci_build_test │ ├── ubuntu_setup │ └── workflows │ │ └── ci.yml ├── requirements.txt ├── setup │ ├── install_prereqs │ └── setup_env ├── LICENSE ├── src │ ├── particle.py │ └── particle_test.py └── README.md ├── .github ├── workflows │ ├── stale.yml │ ├── cmake_installed_apt.yml │ ├── bazel_download.yml │ ├── cmake_installed.yml │ ├── pip.yml │ ├── poetry.yml │ └── ci.yml └── renovate.json ├── LICENSE ├── README.md └── Jenkinsfile /drake_bazel_external/.bazelignore: -------------------------------------------------------------------------------- 1 | drake 2 | -------------------------------------------------------------------------------- /drake_bazel_download/.bazelversion: -------------------------------------------------------------------------------- 1 | 8.5.0 2 | -------------------------------------------------------------------------------- /drake_bazel_external/.bazelversion: -------------------------------------------------------------------------------- 1 | 8.5.0 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | WORKSPACE diff=bazel 4 | -------------------------------------------------------------------------------- /private/drake_cmake_external_static/.github/setup: -------------------------------------------------------------------------------- 1 | ../../../drake_cmake_external/.github/setup -------------------------------------------------------------------------------- /private/drake_cmake_external_static/.github/ci_build_test: -------------------------------------------------------------------------------- 1 | ../../../drake_cmake_external/.github/ci_build_test -------------------------------------------------------------------------------- /private/drake_cmake_external_static/.github/ubuntu_setup: -------------------------------------------------------------------------------- 1 | ../../../drake_cmake_external/.github/ubuntu_setup -------------------------------------------------------------------------------- /private/drake_cmake_external_static/setup/install_prereqs: -------------------------------------------------------------------------------- 1 | ../../../drake_cmake_external/setup/install_prereqs -------------------------------------------------------------------------------- /drake_cmake_external/.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | /.idea/ 4 | /build/ 5 | /cmake-build-*/ 6 | -------------------------------------------------------------------------------- /drake_cmake_installed/.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | /.idea/ 4 | /build/ 5 | /cmake-build-*/ 6 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | /.idea/ 4 | /build/ 5 | /cmake-build-*/ 6 | -------------------------------------------------------------------------------- /drake_bazel_download/.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | /MODULE.bazel.lock 4 | /bazel-* 5 | /user.bazelrc 6 | -------------------------------------------------------------------------------- /drake_bazel_external/.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | /bazel-* 4 | /user.bazelrc 5 | /MODULE.bazel.lock 6 | -------------------------------------------------------------------------------- /drake_bazel_external/.bazelproject: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | directories: 4 | . 5 | 6 | targets: 7 | //...:all 8 | -------------------------------------------------------------------------------- /private/drake_cmake_external_static/drake_external_examples/simple_continuous_time_system.cc: -------------------------------------------------------------------------------- 1 | ../../../drake_cmake_external/drake_external_examples/simple_continuous_time_system.cc -------------------------------------------------------------------------------- /drake_bazel_external/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | # This is an empty BUILD file, to ensure that this project's root directory is 4 | # a Bazel package. 5 | -------------------------------------------------------------------------------- /drake_bazel_download/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | set noparent 4 | 5 | filter=-build/c++11 6 | filter=-build/header_guard 7 | filter=-build/include_subdir 8 | -------------------------------------------------------------------------------- /drake_bazel_external/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | set noparent 4 | 5 | filter=-build/c++11 6 | filter=-build/header_guard 7 | filter=-build/include_subdir 8 | -------------------------------------------------------------------------------- /drake_cmake_external/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | set noparent 4 | 5 | filter=-build/c++11 6 | filter=-build/header_guard 7 | filter=-build/include_subdir 8 | -------------------------------------------------------------------------------- /drake_cmake_installed/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | set noparent 4 | 5 | filter=-build/c++11 6 | filter=-build/header_guard 7 | filter=-build/include_subdir 8 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | set noparent 4 | 5 | filter=-build/c++11 6 | filter=-build/header_guard 7 | filter=-build/include_subdir 8 | -------------------------------------------------------------------------------- /drake_bazel_download/apps/import_all_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | """ 4 | Provides an example of importing all modules available in pydrake. 5 | """ 6 | 7 | import pydrake.all 8 | -------------------------------------------------------------------------------- /drake_bazel_external/apps/import_all_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | """ 4 | Provides an example of importing all modules available in pydrake. 5 | """ 6 | 7 | import pydrake.all 8 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/import_all_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | """ 4 | Provides an example of importing all modules available in pydrake. 5 | """ 6 | 7 | import pydrake.all 8 | -------------------------------------------------------------------------------- /drake_cmake_external/drake_external_examples/import_all_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | """ 4 | Provides an example of importing all modules available in pydrake. 5 | """ 6 | 7 | import pydrake.all 8 | -------------------------------------------------------------------------------- /drake_bazel_external/.github/setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | # CI setup 7 | sudo .github/ubuntu_setup 8 | 9 | # drake source setup 10 | setup/install_prereqs "$@" 11 | -------------------------------------------------------------------------------- /drake_bazel_download/apps/exec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | # Proxy script for things such as passing a `py_binary` to a `sh_test`, since 5 | # we cannot list the Python binary in `srcs` for the test. 6 | exec "$@" 7 | -------------------------------------------------------------------------------- /drake_bazel_external/apps/exec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | # Proxy script for things such as passing a `py_binary` to a `sh_test`, since 5 | # we cannot list the Python binary in `srcs` for the test. 6 | exec "$@" 7 | -------------------------------------------------------------------------------- /drake_poetry/.github/ci_build_test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | poetry --version 7 | 8 | cd src 9 | poetry run python particle_test.py 10 | 11 | cd .. 12 | rm -rf src/__pycache__ 13 | -------------------------------------------------------------------------------- /drake_pip/.github/ci_build_test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | source env/bin/activate 7 | 8 | cd src 9 | python3 particle_test.py 10 | 11 | cd .. 12 | deactivate 13 | rm -rf env src/__pycache__ 14 | -------------------------------------------------------------------------------- /drake_bazel_download/eigen.bzl: -------------------------------------------------------------------------------- 1 | def _impl(repo_ctx): 2 | repo_ctx.symlink("/usr/include/eigen3", "include") 3 | repo_ctx.symlink(Label("@//:eigen.BUILD.bazel"), "BUILD.bazel") 4 | 5 | local_eigen_repository = repository_rule( 6 | implementation = _impl, 7 | ) 8 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/find_resource/find_resource_example.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | """Test the Drake find resource API.""" 4 | 5 | from pydrake.common import FindResourceOrThrow 6 | 7 | FindResourceOrThrow('drake/examples/pendulum/Pendulum.urdf') 8 | -------------------------------------------------------------------------------- /drake_bazel_download/eigen.BUILD.bazel: -------------------------------------------------------------------------------- 1 | # -*- bazel -*- 2 | 3 | cc_library( 4 | name = "eigen", 5 | hdrs = glob(["include/Eigen/**", "include/unsupported/Eigen/**"], allow_empty = False), 6 | strip_include_prefix = "include", 7 | visibility = ["//visibility:public"], 8 | ) 9 | -------------------------------------------------------------------------------- /drake_cmake_installed/third_party/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | find_package(Threads) 4 | 5 | add_library(gtest STATIC googletest/gtest-all.cc googletest/gtest/gtest.h) 6 | target_include_directories(gtest PUBLIC googletest) 7 | target_link_libraries(gtest Threads::Threads) 8 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/.github/ci_build_test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | cmake --version 7 | 8 | mkdir build 9 | pushd build 10 | 11 | cmake .. 12 | make 13 | ctest -V . 14 | 15 | popd 16 | 17 | chmod -R a+w build || true 18 | rm -rf build 19 | -------------------------------------------------------------------------------- /private/drake_cmake_external_static/drake_external_examples/lcm_disabled_test.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | #include 4 | #include 5 | 6 | int main() { 7 | DRAKE_DEMAND(drake::lcm::DrakeLcm::available() == false); 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /drake_cmake_installed/.github/ci_build_test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | cmake --version 7 | 8 | mkdir build 9 | pushd build 10 | 11 | cmake -DCMAKE_PREFIX_PATH=$HOME/drake "$@" .. 12 | make 13 | ctest -V . 14 | 15 | popd 16 | 17 | chmod -R a+w build || true 18 | rm -rf build 19 | -------------------------------------------------------------------------------- /drake_bazel_download/apps/find_resource_test.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | #include "drake/common/find_resource.h" 4 | #include "drake/common/text_logging.h" 5 | 6 | int main() 7 | { 8 | drake::logging::set_log_level("debug"); 9 | drake::FindResourceOrThrow("drake/examples/pendulum/Pendulum.urdf"); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/simple_continuous_time_system/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | add_executable(simple_continuous_time_system simple_continuous_time_system.cc) 4 | target_link_libraries(simple_continuous_time_system drake::drake) 5 | add_test(NAME simple_continuous_time_system 6 | COMMAND simple_continuous_time_system 7 | ) 8 | -------------------------------------------------------------------------------- /drake_pip/.github/ubuntu_setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries 7 | echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes 8 | 9 | export DEBIAN_FRONTEND='noninteractive' 10 | 11 | setup/install_prereqs "$@" 12 | -------------------------------------------------------------------------------- /drake_bazel_download/.github/ubuntu_setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries 7 | echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes 8 | 9 | export DEBIAN_FRONTEND='noninteractive' 10 | 11 | setup/install_prereqs "$@" 12 | -------------------------------------------------------------------------------- /drake_cmake_installed/.github/ubuntu_setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries 7 | echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes 8 | 9 | export DEBIAN_FRONTEND='noninteractive' 10 | 11 | setup/install_prereqs "$@" 12 | -------------------------------------------------------------------------------- /drake_pip/requirements.txt: -------------------------------------------------------------------------------- 1 | # Currently, this only includes a recent version of Drake. 2 | # Feel free to add more packages for your own project below! 3 | # Note: When specifying a compatible version of Drake with ~=, 4 | # use 'drake~=x.y' instead of 'drake~=x.y.z'. See 5 | # https://packaging.python.org/en/latest/specifications/version-specifiers/#compatible-release 6 | # for more details. 7 | drake~=1.48 8 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | add_subdirectory(find_resource) 4 | add_subdirectory(particle) 5 | add_subdirectory(simple_bindings) 6 | add_subdirectory(simple_continuous_time_system) 7 | 8 | add_test(NAME import_all_test COMMAND 9 | "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/import_all_test.py" 10 | ) 11 | set_tests_properties(import_all_test PROPERTIES 12 | ENVIRONMENT "PYTHONPATH=${DRAKE_PYTHONPATH}" 13 | ) 14 | -------------------------------------------------------------------------------- /drake_poetry/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["poetry-core"] 3 | build-backend = "poetry.core.masonry.api" 4 | 5 | [project] 6 | name = "drake-external-examples" 7 | version = "0.0.0.dev0" 8 | description = "External examples for Drake" 9 | authors = [{ name = "RobotLocomotion <@>" }] 10 | readme = "README.md" 11 | requires-python = ">=3.10,<3.14" 12 | dynamic = ["dependencies"] 13 | 14 | [tool.poetry] 15 | package-mode = false 16 | 17 | [tool.poetry.dependencies] 18 | drake = "~=1.48" 19 | -------------------------------------------------------------------------------- /private/README.md: -------------------------------------------------------------------------------- 1 | # Private files 2 | 3 | These files are for use by the Drake maintainers, and should not be 4 | copied into your own project(s). 5 | 6 | * `drake_cmake_external_static/`: A pared-down copy of the drake_cmake_external 7 | example in order to provide CI coverage of installing and linking libdrake 8 | statically. 9 | * `test/`: General testing utilities. 10 | * `upgrade_cmake_externals.py`: A script to automatically upgrade the upstream 11 | dependencies used by the drake_cmake_external example. 12 | -------------------------------------------------------------------------------- /drake_bazel_download/apps/find_resource_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | """ 4 | Provides an example (and test) of finding resources with Python from a Bazel 5 | project. 6 | """ 7 | 8 | import logging 9 | 10 | from pydrake.common import FindResourceOrThrow 11 | 12 | # If you have trouble finding resources, you can enable debug logging to see 13 | # how `FindResource*` is searching. 14 | logging.getLogger("drake").setLevel(logging.DEBUG) 15 | 16 | FindResourceOrThrow("drake/examples/pendulum/Pendulum.urdf") 17 | -------------------------------------------------------------------------------- /drake_bazel_external/apps/find_resource_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | """ 4 | Provides an example (and test) of finding resources with Python from a Bazel 5 | project. 6 | """ 7 | 8 | import logging 9 | 10 | from pydrake.common import FindResourceOrThrow 11 | 12 | # If you have trouble finding resources, you can enable debug logging to see 13 | # how `FindResource*` is searching. 14 | logging.getLogger("drake").setLevel(logging.DEBUG) 15 | 16 | FindResourceOrThrow("drake/examples/pendulum/Pendulum.urdf") 17 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/find_resource/README.md: -------------------------------------------------------------------------------- 1 | # Find Resources 2 | 3 | ## Description 4 | 5 | Simply tests the Drake find resource API from outside of Drake, i.e., finds and loads resources that are part of the Drake install. 6 | 7 | ## How do I build it? 8 | 9 | Follow the instructions in the [README](../../README.md) for this project. 10 | 11 | ## How do I run it? 12 | 13 | ``` 14 | # Switch to the build directory 15 | cd build/src/find_resource_example 16 | # Run the example 17 | ./test_find_resource_example 18 | ``` 19 | -------------------------------------------------------------------------------- /drake_bazel_download/setup/install_bazelisk: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # TODO(jwnimmer-tri) Drake's install_prereqs script should offer to perform 4 | # this install step for us, but it doesn't -- so we need this work-around 5 | # in the meantime. 6 | 7 | set -euxo pipefail 8 | 9 | maybe_sudo= 10 | if [[ "${EUID}" -ne 0 ]]; then 11 | maybe_sudo=sudo 12 | fi 13 | 14 | wget -O bazelisk.deb \ 15 | https://github.com/bazelbuild/bazelisk/releases/download/v1.24.0/bazelisk-amd64.deb 16 | ${maybe_sudo} dpkg -i bazelisk.deb 17 | rm -f bazelisk.deb 18 | -------------------------------------------------------------------------------- /drake_cmake_external/.github/setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | # CI setup 7 | sudo .github/ubuntu_setup 8 | 9 | # drake source setup 10 | setup/install_prereqs "$@" 11 | 12 | # Provide regression coverage for the WITH_USER_...=ON options by un-installing 13 | # packages that should not be necessary in this particular build flavor. This 14 | # example configures them to be built from source. 15 | sudo apt-get remove libeigen3-dev libfmt-dev libspdlog-dev 16 | sudo apt-get autoremove 17 | -------------------------------------------------------------------------------- /drake_bazel_external/apps/simple_adder.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | /** 4 | * @file 5 | * Provides an example of creating a simple Drake C++ system that will later be 6 | * bound. 7 | * 8 | * This is the instantiation portion of the -inl.h pattern: 9 | * http://drake.mit.edu/cxx_inl.html#cxx-inl-files 10 | */ 11 | 12 | #include "simple_adder-inl.h" 13 | 14 | #include 15 | 16 | DRAKE_DEFINE_CLASS_TEMPLATE_INSTANTIATIONS_ON_DEFAULT_SCALARS( 17 | class ::drake_external_examples::SimpleAdder); 18 | -------------------------------------------------------------------------------- /drake_cmake_external/drake_external_examples/solver_disabled_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | """ 4 | Our CMakeLists.txt file disabled the CSDP solver as part of the Drake build. 5 | Here, we'll check that the opt-out succeeded. 6 | """ 7 | 8 | import unittest 9 | 10 | from pydrake.solvers import CsdpSolver 11 | 12 | class TestCsdpSolver(unittest.TestCase): 13 | def test_unavailable(self): 14 | solver = CsdpSolver() 15 | self.assertFalse(solver.available()) 16 | 17 | if __name__ == '__main__': 18 | unittest.main() 19 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/find_resource/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | add_executable(find_resource_example find_resource_example.cc) 4 | target_link_libraries(find_resource_example drake::drake) 5 | add_test(NAME find_resource_example COMMAND find_resource_example) 6 | 7 | add_test(NAME find_resource_example_py COMMAND 8 | "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/find_resource_example.py" 9 | ) 10 | set_tests_properties(find_resource_example_py PROPERTIES 11 | ENVIRONMENT "PYTHONPATH=${DRAKE_PYTHONPATH}" 12 | ) 13 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/simple_continuous_time_system/README.md: -------------------------------------------------------------------------------- 1 | # Simple Continuous Time System 2 | 3 | This is the hello world for the `drake::system` classes. 4 | 5 | ## How do I build it? 6 | 7 | Follow the instructions in the [README](../../README.md) for this project. 8 | 9 | ## How do I run it? 10 | 11 | ``` 12 | # Switch to the build directory 13 | cd build/src/simple_continuous_time_system 14 | # Run the tests 15 | ./simple_continuous_time_system 16 | ``` 17 | 18 | Note that there is no interaction nor output from this program. It is merely intended to exercise the code. -------------------------------------------------------------------------------- /drake_bazel_external/.github/ci_build_test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | cat < "user.bazelrc" 7 | # Use what we downloaded to drake_bazel_external/drake, 8 | # rather than the URL to the latest Drake master branch 9 | # found in drake_bazel_external/MODULE.bazel. 10 | build --override_module=drake=drake 11 | 12 | # Pass along the compiler version to Drake 13 | # (as suggested in drake_bazel_external/.bazelrc). 14 | build --@drake//tools/cc_toolchain:compiler_major=$(gcc -dumpversion) 15 | EOF 16 | 17 | bazel version 18 | bazel test //... 19 | -------------------------------------------------------------------------------- /drake_bazel_download/.github/ci_build_test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | cat < "user.bazelrc" 7 | # Use what we installed to $HOME/drake, 8 | # rather than the URL to the most recent nightly release 9 | # found in drake_bazel_download/MODULE.bazel. 10 | build --override_repository=+_repo_rules2+drake=$HOME/drake 11 | EOF 12 | 13 | # Setup $HOME/drake as a Bazel workspace via 14 | # BUILD and WORKSPACE files. 15 | ln -sf $(realpath drake.BUILD.bazel) "$HOME/drake/BUILD.bazel" 16 | touch "$HOME/drake/WORKSPACE.bazel" 17 | 18 | bazel version 19 | bazel test //... 20 | -------------------------------------------------------------------------------- /drake_pip/setup/install_prereqs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | maybe_sudo= 7 | if [[ "${EUID}" -ne 0 ]]; then 8 | maybe_sudo=sudo 9 | fi 10 | 11 | # Ubuntu-specific installations 12 | # See https://github.com/RobotLocomotion/drake/blob/master/tools/wheel/content/INSTALLATION 13 | # for a complete list of the required libraries to be installed. 14 | ${maybe_sudo} apt-get update 15 | ${maybe_sudo} apt-get install --no-install-recommends $(cat <&2 8 | exit 2 9 | fi 10 | 11 | echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries 12 | echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes 13 | 14 | export DEBIAN_FRONTEND='noninteractive' 15 | 16 | apt-get update 17 | apt-get install --no-install-recommends lsb-release 18 | 19 | if [[ "$(lsb_release -sc)" != 'noble' ]]; then 20 | echo 'This script requires Ubuntu 24.04 (Noble)' >&2 21 | exit 3 22 | fi 23 | -------------------------------------------------------------------------------- /drake_cmake_external/.github/ubuntu_setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | if [[ "${EUID:-}" -ne 0 ]]; then 7 | echo 'This script must be run as root' >&2 8 | exit 2 9 | fi 10 | 11 | echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries 12 | echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes 13 | 14 | export DEBIAN_FRONTEND='noninteractive' 15 | 16 | apt-get update 17 | apt-get install --no-install-recommends lsb-release 18 | 19 | if [[ "$(lsb_release -sc)" != 'noble' ]]; then 20 | echo 'This script requires Ubuntu 24.04 (Noble)' >&2 21 | exit 3 22 | fi 23 | -------------------------------------------------------------------------------- /drake_bazel_download/.bazelrc: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | # Default to an optimized build. 4 | build --compilation_mode=opt 5 | build --features=prefer_pic_for_opt_binaries 6 | 7 | # Default build options. 8 | build --strip=never 9 | 10 | # Default test options. 11 | build --test_output=errors 12 | build --test_summary=terse 13 | 14 | # Use C++20. 15 | build --cxxopt=-std=c++20 16 | build --host_cxxopt=-std=c++20 17 | 18 | # https://github.com/bazelbuild/bazel/issues/1164 19 | build --action_env=CCACHE_DISABLE=1 20 | 21 | # TODO(jwnimmer-tri) We should see if we can reuse more of Drake's 22 | # customizations somehow. 23 | 24 | # Try to import user-specific configuration local to workspace. 25 | try-import %workspace%/user.bazelrc 26 | -------------------------------------------------------------------------------- /drake_poetry/.github/setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | case "$OSTYPE" in 7 | darwin*) 8 | # Mac-specific installations 9 | brew install pipx 10 | ;; 11 | 12 | linux*) 13 | if [[ "${EUID:-}" -ne 0 ]]; then 14 | echo 'This script must be run as root' >&2 15 | exit 2 16 | fi 17 | 18 | # Ubuntu-specific installations 19 | echo 'APT::Acquire::Retries "4";' > /etc/apt/apt.conf.d/80-acquire-retries 20 | echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/90-get-assume-yes 21 | 22 | export DEBIAN_FRONTEND='noninteractive' 23 | 24 | apt-get update 25 | apt-get install --no-install-recommends pipx python3 26 | ;; 27 | esac 28 | 29 | pipx install poetry 30 | pipx ensurepath 31 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | add_library(particle particle.cc particle.h) 4 | target_link_libraries(particle drake::drake) 5 | 6 | add_executable(particle_test particle_test.cc) 7 | target_link_libraries(particle_test particle drake::drake gtest) 8 | add_test(NAME cc_particle_test COMMAND particle_test) 9 | set_tests_properties(cc_particle_test PROPERTIES LABELS small TIMEOUT 60) 10 | 11 | add_test(NAME python_particle_test 12 | COMMAND Python3::Interpreter -B -m unittest particle_test 13 | ) 14 | set_tests_properties(python_particle_test PROPERTIES 15 | ENVIRONMENT "PYTHONPATH=${DRAKE_PYTHONPATH}" 16 | LABELS small 17 | REQUIRED_FILES "${CMAKE_CURRENT_SOURCE_DIR}/particle_test.py" 18 | TIMEOUT 60 19 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 20 | ) 21 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/particle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | add_library(particle particle.cc particle.h) 4 | target_link_libraries(particle drake::drake) 5 | 6 | add_executable(particle_test particle_test.cc) 7 | target_link_libraries(particle_test particle drake::drake gtest) 8 | add_test(NAME cc_particle_test COMMAND particle_test) 9 | set_tests_properties(cc_particle_test PROPERTIES LABELS small TIMEOUT 60) 10 | 11 | add_test(NAME python_particle_test 12 | COMMAND Python3::Interpreter -B -m unittest particle_test 13 | ) 14 | set_tests_properties(python_particle_test PROPERTIES 15 | ENVIRONMENT "PYTHONPATH=${DRAKE_PYTHONPATH}" 16 | LABELS small 17 | REQUIRED_FILES "${CMAKE_CURRENT_SOURCE_DIR}/particle_test.py" 18 | TIMEOUT 60 19 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 20 | ) 21 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/find_resource/find_resource_example.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | /// 4 | /// @brief A simple find_resource test for locating installed drake resources. 5 | /// 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | namespace drake_external_examples { 13 | namespace { 14 | 15 | int main() { 16 | drake::FindResourceOrThrow("drake/examples/pendulum/Pendulum.urdf"); 17 | 18 | try { 19 | drake::FindResourceOrThrow("nobody_home.urdf"); 20 | std::cerr << "Should have thrown" << std::endl; 21 | return 1; 22 | } catch (const std::runtime_error&) { 23 | } 24 | 25 | return 0; 26 | } 27 | 28 | } // namespace 29 | } // namespace drake_external_examples 30 | 31 | int main() { return drake_external_examples::main(); } 32 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | --- 4 | name: stale 5 | on: 6 | schedule: 7 | - cron: '30 1 * * *' 8 | jobs: 9 | stale: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/stale@v10 13 | with: 14 | days-before-issue-close: -1 15 | days-before-issue-stale: -1 16 | days-before-pr-close: 14 17 | days-before-pr-stale: 180 18 | repo-token: ${{ secrets.GITHUB_TOKEN }} 19 | stale-pr-label: 'result: stale' 20 | stale-pr-message: > 21 | Thank you for your contribution. This pull request has been open for 22 | 180 days without activity and so is considered stale. It will be 23 | automatically closed in 14 days unless you comment or remove the 24 | "result: stale" label. 25 | -------------------------------------------------------------------------------- /drake_bazel_external/apps/simple_adder.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | /** 4 | * @file 5 | * Provides an example of creating a simple Drake C++ system that will later be 6 | * bound. 7 | * 8 | * This is the header portion of the -inl.h pattern: 9 | * http://drake.mit.edu/cxx_inl.html#cxx-inl-files 10 | */ 11 | 12 | #include 13 | 14 | namespace drake_external_examples { 15 | 16 | /// Adds a constant to an input. 17 | template 18 | class SimpleAdder : public drake::systems::LeafSystem { 19 | public: 20 | explicit SimpleAdder(T add); 21 | 22 | private: 23 | void CalcOutput( 24 | const drake::systems::Context& context, 25 | drake::systems::BasicVector* output) const; 26 | 27 | const T add_{}; 28 | }; 29 | 30 | } // namespace drake_external_examples 31 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended" 5 | ], 6 | "automerge": false, 7 | "schedule": [ 8 | "at any time" 9 | ], 10 | "timezone": "America/New_York", 11 | "enabledManagers": [ 12 | "pip_requirements", 13 | "poetry", 14 | "bazelisk", 15 | "bazel-module", 16 | "github-actions" 17 | ], 18 | "includePaths": [ 19 | "drake_pip/**", 20 | "drake_poetry/**", 21 | "drake_bazel_download/**", 22 | "drake_bazel_external/**", 23 | "**/.github/**" 24 | ], 25 | "packageRules": [ 26 | { 27 | "matchManagers": [ 28 | "pip_requirements", 29 | "poetry", 30 | "bazelisk", 31 | "bazel-module", 32 | "github-actions" 33 | ], 34 | "rangeStrategy": "bump" 35 | } 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /drake_bazel_download/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | # We must opt-out of the py_exec_tools_toolchain, otherwise rules_python will 4 | # download a random copy from the internet that doesn't work correctly in CI. 5 | # 6 | # The py_exec_tools_toolchain is used to byte-compile python sources during 7 | # the build step (vs the first time they are run) for improved performance. 8 | # We don't need that optimization in this project. 9 | 10 | load( 11 | "@rules_python//python:py_exec_tools_toolchain.bzl", 12 | "py_exec_tools_toolchain", 13 | ) 14 | 15 | py_exec_tools_toolchain( 16 | name = "python_no_exec_tools", 17 | exec_interpreter = "@rules_python//python:none", 18 | ) 19 | 20 | toolchain( 21 | name = "python_no_exec_tools_toolchain", 22 | toolchain = ":python_no_exec_tools", 23 | toolchain_type = "@rules_python//python:exec_tools_toolchain_type", 24 | ) 25 | -------------------------------------------------------------------------------- /.github/workflows/cmake_installed_apt.yml: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | --- 4 | name: ci 5 | on: 6 | workflow_call: 7 | 8 | jobs: 9 | ubuntu_noble_cmake_installed_apt: 10 | name: ubuntu 24.04 noble 11 | runs-on: ubuntu-latest 12 | container: ubuntu:noble 13 | steps: 14 | - name: checkout 15 | uses: actions/checkout@v6 16 | - name: setup 17 | working-directory: drake_cmake_installed_apt 18 | run: | 19 | args=() 20 | if [[ '${{ github.event.inputs.linux_noble_package_deb }}' != '' ]]; then 21 | args+=(--package-url ${{ github.event.inputs.linux_noble_package_deb }}) 22 | fi 23 | .github/ubuntu_apt_setup "${args[@]}" 24 | shell: bash 25 | - name: cmake_installed_apt build and test 26 | working-directory: drake_cmake_installed_apt 27 | run: .github/ci_build_test 28 | shell: bash 29 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/README.md: -------------------------------------------------------------------------------- 1 | # CMake Project with Drake Installed Using APT 2 | 3 | This example uses the [`cmake`](https://cmake.org/) build system with an 4 | instance of Drake installed using the 5 | [APT](https://manpages.ubuntu.com/manpages/noble/man8/apt.8.html) package 6 | manager. 7 | 8 | ## Instructions 9 | 10 | Install the `drake-dev` APT package by following the instructions found at: 11 | 12 | 13 | 14 | For this example, also install the `build-essential`, `cmake`, and 15 | `python3-dev` APT packages: 16 | 17 | ```bash 18 | sudo apt-get update 19 | sudo apt-get --no-install-recommends install \ 20 | build-essential cmake python3-dev 21 | ``` 22 | 23 | To build the `drake_cmake_installed_apt` example: 24 | 25 | ```bash 26 | mkdir build 27 | cd build 28 | cmake .. 29 | make 30 | ``` 31 | 32 | To run the `drake_cmake_installed_apt` tests: 33 | 34 | ```bash 35 | cd build 36 | ctest . 37 | ``` 38 | -------------------------------------------------------------------------------- /drake_bazel_download/apps/include_paths_test.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | // This test program checks that Drake headers that include third-party headers 4 | // can be successfully included when using drake_bazel_download. It serves as 5 | // a regression test for Drake moreso than an example program for end-users. 6 | 7 | #include "drake/common/drake_assert.h" 8 | #include "drake/common/eigen_types.h" 9 | #include "drake/common/text_logging.h" 10 | #include "drake/manipulation/kuka_iiwa/iiwa_status_receiver.h" 11 | 12 | int main() { 13 | // Check eigen-related include paths. 14 | drake::VectorX empty; 15 | DRAKE_DEMAND(empty.size() == 0); 16 | 17 | // Check lcm-related include paths. 18 | const drake::manipulation::kuka_iiwa::IiwaStatusReceiver iiwa; 19 | DRAKE_DEMAND(iiwa.num_input_ports() > 0); 20 | 21 | // Check fmt- and spdlog-related include paths. 22 | drake::log()->info("Info check {}", "passed"); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017-2025 by the drake-external-examples developers. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 16 | SOFTWARE. 17 | -------------------------------------------------------------------------------- /drake_pip/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017-2025 by the drake-external-examples developers. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 16 | SOFTWARE. 17 | -------------------------------------------------------------------------------- /drake_poetry/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017-2025 by the drake-external-examples developers. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 16 | SOFTWARE. 17 | -------------------------------------------------------------------------------- /drake_bazel_download/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017-2025 by the drake-external-examples developers. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 16 | SOFTWARE. 17 | -------------------------------------------------------------------------------- /drake_bazel_external/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017-2025 by the drake-external-examples developers. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 16 | SOFTWARE. 17 | -------------------------------------------------------------------------------- /drake_cmake_external/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017-2025 by the drake-external-examples developers. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 16 | SOFTWARE. 17 | -------------------------------------------------------------------------------- /drake_cmake_installed/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017-2025 by the drake-external-examples developers. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 16 | SOFTWARE. 17 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017-2025 by the drake-external-examples developers. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 16 | SOFTWARE. 17 | -------------------------------------------------------------------------------- /.github/workflows/bazel_download.yml: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | --- 4 | name: ci 5 | on: 6 | workflow_call: 7 | 8 | jobs: 9 | ubuntu_noble_bazel_download: 10 | name: ubuntu 24.04 noble 11 | runs-on: ubuntu-latest 12 | container: ubuntu:noble 13 | steps: 14 | - name: checkout 15 | uses: actions/checkout@v6 16 | - name: setup 17 | working-directory: drake_bazel_download 18 | run: | 19 | args=() 20 | if [[ '${{ github.event.inputs.linux_noble_package_tar }}' != '' ]]; then 21 | args+=(--package-url ${{ github.event.inputs.linux_noble_package_tar }}) 22 | fi 23 | .github/ubuntu_setup "${args[@]}" 24 | shell: bash 25 | - name: install_bazelisk 26 | working-directory: drake_bazel_download 27 | run: setup/install_bazelisk 28 | shell: bash 29 | - name: bazel_download build and test 30 | working-directory: drake_bazel_download 31 | run: .github/ci_build_test 32 | shell: bash 33 | -------------------------------------------------------------------------------- /drake_bazel_download/apps/simple_logging_example.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | """ 4 | Provides an example of using pydrake from a Bazel external. 5 | """ 6 | 7 | from __future__ import print_function 8 | 9 | import numpy as np 10 | 11 | from pydrake.systems.analysis import Simulator 12 | from pydrake.systems.framework import ( 13 | DiagramBuilder, 14 | ) 15 | from pydrake.systems.primitives import ( 16 | ConstantVectorSource, 17 | VectorLogSink, 18 | ) 19 | 20 | 21 | def main(): 22 | builder = DiagramBuilder() 23 | source = builder.AddSystem(ConstantVectorSource([10.])) 24 | logger = builder.AddSystem(VectorLogSink(1)) 25 | builder.Connect(source.get_output_port(0), logger.get_input_port(0)) 26 | diagram = builder.Build() 27 | 28 | simulator = Simulator(diagram) 29 | simulator.AdvanceTo(1) 30 | 31 | x = logger.FindLog(simulator.get_context()).data() 32 | print("Output values: {}".format(x)) 33 | assert np.allclose(x, 10.) 34 | 35 | 36 | if __name__ == "__main__": 37 | main() 38 | -------------------------------------------------------------------------------- /drake_bazel_external/apps/simple_logging_example.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | """ 4 | Provides an example of using pydrake from a Bazel external. 5 | """ 6 | 7 | from __future__ import print_function 8 | 9 | import numpy as np 10 | 11 | from pydrake.systems.analysis import Simulator 12 | from pydrake.systems.framework import ( 13 | DiagramBuilder, 14 | ) 15 | from pydrake.systems.primitives import ( 16 | ConstantVectorSource, 17 | VectorLogSink, 18 | ) 19 | 20 | 21 | def main(): 22 | builder = DiagramBuilder() 23 | source = builder.AddSystem(ConstantVectorSource([10.])) 24 | logger = builder.AddSystem(VectorLogSink(1)) 25 | builder.Connect(source.get_output_port(0), logger.get_input_port(0)) 26 | diagram = builder.Build() 27 | 28 | simulator = Simulator(diagram) 29 | simulator.AdvanceTo(1) 30 | 31 | x = logger.FindLog(simulator.get_context()).data() 32 | print("Output values: {}".format(x)) 33 | assert np.allclose(x, 10.) 34 | 35 | 36 | if __name__ == "__main__": 37 | main() 38 | -------------------------------------------------------------------------------- /drake_cmake_external/setup/install_prereqs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # SPDX-License-Identifier: MIT-0 4 | 5 | set -euxo pipefail 6 | 7 | drake_commit_hash='master' 8 | 9 | while [ "${1:-}" != "" ]; do 10 | case "$1" in 11 | --drake-commit-hash) 12 | shift 13 | if [[ $# -eq 0 ]]; then 14 | echo 'No argument specified for --drake-commit-hash' >&2 15 | exit 1 16 | fi 17 | drake_commit_hash="$1" 18 | ;; 19 | *) 20 | echo 'Invalid command line argument' >&2 21 | exit 1 22 | esac 23 | shift 24 | done 25 | 26 | maybe_sudo= 27 | if [[ "${EUID}" -ne 0 ]]; then 28 | maybe_sudo=sudo 29 | fi 30 | 31 | ${maybe_sudo} apt-get install --no-install-recommends $(cat <&2 15 | exit 1 16 | fi 17 | drake_commit_hash="$1" 18 | ;; 19 | *) 20 | echo 'Invalid command line argument' >&2 21 | exit 1 22 | esac 23 | shift 24 | done 25 | 26 | maybe_sudo= 27 | if [[ "${EUID}" -ne 0 ]]; then 28 | maybe_sudo=sudo 29 | fi 30 | 31 | ${maybe_sudo} apt-get install --no-install-recommends $(cat <&2 14 | exit 1 15 | fi 16 | drake_commit_hash="$1" 17 | ;; 18 | *) 19 | echo 'Invalid command line argument' >&2 20 | exit 1 21 | esac 22 | shift 23 | done 24 | 25 | cmake --version 26 | 27 | mkdir build 28 | pushd build 29 | 30 | export LD_LIBRARY_PATH="${PWD}/install/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" 31 | 32 | cmake_args=() 33 | if [[ ! -z "${drake_commit_hash}" ]]; then 34 | # Use a specific commit of Drake source, 35 | # rather than the latest from master. 36 | cmake_args+=(-DDRAKE_COMMIT_HASH=${drake_commit_hash}) 37 | fi 38 | 39 | cmake .. "${cmake_args[@]}" 40 | cmake --build . 41 | 42 | cd drake_external_examples 43 | ctest -V . 44 | 45 | popd 46 | 47 | chmod -R a+w build || true 48 | rm -rf build 49 | -------------------------------------------------------------------------------- /drake_pip/setup/setup_env: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | wheel_url= 7 | python_version='3' 8 | 9 | while [ "${1:-}" != "" ]; do 10 | case "$1" in 11 | --wheel-url) 12 | shift 13 | if [[ $# -eq 0 ]]; then 14 | echo 'No argument specified for --wheel-url' >&2 15 | exit 1 16 | fi 17 | wheel_url="$1" 18 | ;; 19 | --python-version) 20 | shift 21 | if [[ $# -eq 0 ]]; then 22 | echo 'No argument specified for --python-version' >&2 23 | exit 1 24 | fi 25 | python_version="$1" 26 | ;; 27 | *) 28 | echo 'Invalid command line argument' >&2 29 | exit 1 30 | esac 31 | shift 32 | done 33 | 34 | echo "Creating virtual environment with python${python_version}" 35 | "python${python_version}" -m venv env 36 | # Install from requirements.txt, which currently only includes drake. 37 | "env/bin/pip$python_version" install -r requirements.txt 38 | 39 | # Use custom wheels if specified. 40 | if [[ ! -z "${wheel_url}" ]]; then 41 | "env/bin/pip$python_version" install "${wheel_url}" 42 | fi 43 | -------------------------------------------------------------------------------- /drake_bazel_external/apps/simple_adder-inl.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | /** 4 | * @file 5 | * Provides an example of creating a simple Drake C++ system that will later be 6 | * bound. 7 | * 8 | * This is the definition portion of the -inl.h pattern: 9 | * http://drake.mit.edu/cxx_inl.html#cxx-inl-files 10 | */ 11 | 12 | #include "simple_adder.h" 13 | 14 | namespace drake_external_examples { 15 | 16 | using drake::systems::BasicVector; 17 | using drake::systems::Context; 18 | using drake::systems::LeafSystem; 19 | using drake::systems::kVectorValued; 20 | 21 | template 22 | SimpleAdder::SimpleAdder(T add) 23 | : add_(add) { 24 | this->DeclareInputPort("in", kVectorValued, 1); 25 | this->DeclareVectorOutputPort( 26 | "out", BasicVector(1), &SimpleAdder::CalcOutput); 27 | } 28 | 29 | template 30 | void SimpleAdder::CalcOutput( 31 | const Context& context, BasicVector* output) const { 32 | auto u = this->get_input_port(0).Eval(context); 33 | auto&& y = output->get_mutable_value(); 34 | y.array() = u.array() + add_; 35 | } 36 | 37 | } // namespace drake_external_examples 38 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/simple_bindings/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | find_package(pybind11 CONFIG REQUIRED) 4 | 5 | pybind11_add_module(simple_bindings MODULE simple_bindings.cc) 6 | target_link_libraries(simple_bindings PUBLIC drake::drake) 7 | # N.B. `pybind11_add_module` normally sets the default visibility to "hidden" 8 | # to avoid warnings. However, we need the default visibility to be public so 9 | # template instantions that are bound in Python (e.g. `drake::Value<>`) 10 | # maintain the same RTTI across translation units. 11 | # Additionally, in Drake we avoid mixing hidden and public symbols, so we 12 | # can confidently re-enable this setting for Drake's symbols. 13 | # For more information, see: 14 | # https://github.com/pybind/pybind11/issues/2479 15 | set_target_properties(simple_bindings PROPERTIES CXX_VISIBILITY_PRESET default) 16 | 17 | add_test(NAME simple_bindings_test COMMAND 18 | "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/simple_bindings_test.py") 19 | set_tests_properties(simple_bindings_test PROPERTIES 20 | # Using `pybind11/tests/test_cmake_build/installed_target` as an example. 21 | ENVIRONMENT "PYTHONPATH=$:${DRAKE_PYTHONPATH}") 22 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/simple_bindings/simple_bindings_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | """ 4 | Provides an example of using pybind11-bound Drake C++ system with pydrake. 5 | """ 6 | 7 | from __future__ import print_function 8 | 9 | from simple_bindings import SimpleAdder 10 | 11 | import numpy as np 12 | 13 | from pydrake.systems.analysis import Simulator 14 | from pydrake.systems.framework import ( 15 | DiagramBuilder, 16 | ) 17 | from pydrake.systems.primitives import ( 18 | ConstantVectorSource, 19 | VectorLogSink, 20 | ) 21 | 22 | 23 | def main(): 24 | builder = DiagramBuilder() 25 | source = builder.AddSystem(ConstantVectorSource([10.])) 26 | adder = builder.AddSystem(SimpleAdder(100.)) 27 | builder.Connect(source.get_output_port(0), adder.get_input_port(0)) 28 | logger = builder.AddSystem(VectorLogSink(1)) 29 | builder.Connect(adder.get_output_port(0), logger.get_input_port(0)) 30 | diagram = builder.Build() 31 | 32 | simulator = Simulator(diagram) 33 | simulator.AdvanceTo(1) 34 | 35 | x = logger.FindLog(simulator.get_context()).data() 36 | print("Output values: {}".format(x)) 37 | assert np.allclose(x, 110.) 38 | 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /drake_cmake_installed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | # Note that the minimum required version of CMake to consume a binary 4 | # installation of Drake is lower than the minimum required version 5 | # when building Drake from source (as seen in drake_cmake_external). 6 | # The maximum version below allows for the use of modern policies 7 | # with newer versions of CMake. 8 | cmake_minimum_required(VERSION 3.9...4.0) 9 | project(drake_cmake_installed) 10 | 11 | include(CTest) 12 | 13 | find_package(drake CONFIG REQUIRED) 14 | 15 | find_package(Python3 ${drake_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development) 16 | 17 | execute_process(COMMAND ${Python3_EXECUTABLE}-config --exec-prefix 18 | OUTPUT_VARIABLE PYTHON_EXEC_PREFIX 19 | OUTPUT_STRIP_TRAILING_WHITESPACE 20 | ) 21 | list(APPEND CMAKE_PREFIX_PATH "${PYTHON_EXEC_PREFIX}") 22 | 23 | get_filename_component(DRAKE_PYTHONPATH 24 | "${drake_DIR}/../../python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages" 25 | REALPATH 26 | ) 27 | 28 | set(CMAKE_CXX_EXTENSIONS OFF) 29 | set(CMAKE_CXX_STANDARD 20) 30 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 31 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 32 | 33 | add_subdirectory(src) 34 | add_subdirectory(third_party) 35 | -------------------------------------------------------------------------------- /drake_bazel_download/README.md: -------------------------------------------------------------------------------- 1 | # Bazel Project with Drake as a Precompiled External 2 | 3 | This pulls in a downloaded or installed binary build of Drake via the Bazel 4 | workspace mechanism. 5 | 6 | For an introduction to Bazel, refer to 7 | [Getting Started with Bazel](https://bazel.build/start). 8 | 9 | ## Instructions 10 | 11 | First, run the `install_prereqs` script to download the 12 | Drake source to `$HOME/drake/`. This also runs Drake's 13 | setup script to install the required Ubuntu packages: 14 | 15 | ```bash 16 | setup/install_prereqs 17 | ``` 18 | 19 | Additionally, if you don't already have bazel or bazelisk installed, then install bazelisk: 20 | 21 | ```bash 22 | setup/install_bazelisk 23 | ``` 24 | 25 | Then, to build and test all apps: 26 | 27 | ```bash 28 | bazel test //... 29 | ``` 30 | 31 | As an example to run a binary directly: 32 | 33 | ```bash 34 | bazel run //apps:simple_logging_example 35 | ``` 36 | 37 | You may also run the binary directly per the `bazel-bin/...` path that the 38 | above command prints out; however, be aware that your working directories may 39 | cause differences. This is important when using tools like 40 | `drake::FindResource` / `pydrake.common.FindResource`. 41 | You may generally want to stick to using `bazel run` when able. 42 | -------------------------------------------------------------------------------- /drake_bazel_external/apps/simple_adder_py.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | /** 4 | * @file 5 | * Provides an example of binding a simple Drake C++ system in pybind11, to be 6 | * used with pydrake. 7 | */ 8 | 9 | #include 10 | 11 | #include "drake/bindings/pydrake/common/cpp_template_pybind.h" 12 | #include "drake/bindings/pydrake/common/default_scalars_pybind.h" 13 | 14 | #include "simple_adder.h" 15 | 16 | namespace py = pybind11; 17 | 18 | using drake::pydrake::CommonScalarPack; 19 | using drake::pydrake::DefineTemplateClassWithDefault; 20 | using drake::pydrake::GetPyParam; 21 | using drake::systems::LeafSystem; 22 | 23 | namespace drake_external_examples { 24 | namespace { 25 | 26 | PYBIND11_MODULE(simple_adder, m) { 27 | m.doc() = "Example module interfacing with pydrake and Drake C++"; 28 | 29 | py::module::import("pydrake.systems.framework"); 30 | 31 | auto bind_common_scalar_types = [m](auto dummy) { 32 | using T = decltype(dummy); 33 | 34 | DefineTemplateClassWithDefault, LeafSystem>( 35 | m, "SimpleAdder", GetPyParam()) 36 | .def(py::init(), py::arg("add")); 37 | }; 38 | type_visit(bind_common_scalar_types, CommonScalarPack{}); 39 | } 40 | 41 | } // namespace 42 | } // namespace drake_external_examples 43 | -------------------------------------------------------------------------------- /drake_bazel_download/MODULE.bazel: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | module(name = "drake_external_examples") 4 | 5 | # Add the Bazel rulesets we need. 6 | bazel_dep(name = "rules_cc", version = "0.2.16") 7 | bazel_dep(name = "rules_python", version = "1.7.0") 8 | 9 | # Use the host system python. 10 | register_toolchains("@rules_python//python/runtime_env_toolchains:all") 11 | 12 | # Disable the exec tools toolchain. 13 | register_toolchains("//:python_no_exec_tools_toolchain") 14 | 15 | # Use the host system Eigen. 16 | local_eigen_repository = use_repo_rule("//:eigen.bzl", "local_eigen_repository") 17 | local_eigen_repository(name = "eigen") 18 | 19 | # Use a downloaded, pre-compiled build of Drake. 20 | http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 21 | http_archive( 22 | name = "drake", 23 | urls = [ 24 | # This URL refers to the most recent nightly build of Drake (which is 25 | # helpful for our CI test coverage). Users will probably want to pin 26 | # this to a specific release version, instead. To find those URLs, 27 | # refer to https://github.com/RobotLocomotion/drake/releases. 28 | "https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-noble.tar.gz" 29 | ], 30 | build_file = "drake.BUILD.bazel", 31 | strip_prefix = "drake", 32 | ) 33 | -------------------------------------------------------------------------------- /drake_cmake_external/drake_external_examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | cmake_minimum_required(VERSION 3.16) 4 | project(drake_external_examples) 5 | 6 | find_package(drake CONFIG REQUIRED) 7 | 8 | find_package(Python3 ${drake_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development) 9 | 10 | get_filename_component(DRAKE_PYTHONPATH 11 | "${drake_DIR}/../../python${drake_PYTHON_VERSION}/site-packages" 12 | REALPATH 13 | ) 14 | 15 | add_executable(simple_continuous_time_system simple_continuous_time_system.cc) 16 | target_link_libraries(simple_continuous_time_system drake::drake) 17 | 18 | include(CTest) 19 | 20 | add_test(NAME simple_continuous_time_system 21 | COMMAND simple_continuous_time_system 22 | ) 23 | add_test(NAME import_all_test COMMAND 24 | "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/import_all_test.py" 25 | ) 26 | set_tests_properties(import_all_test PROPERTIES 27 | ENVIRONMENT "PYTHONPATH=${DRAKE_PYTHONPATH}" 28 | ) 29 | 30 | add_test(NAME solver_disabled_test 31 | COMMAND Python3::Interpreter -B -m unittest solver_disabled_test 32 | ) 33 | set_tests_properties(solver_disabled_test PROPERTIES 34 | ENVIRONMENT "PYTHONPATH=${DRAKE_PYTHONPATH}" 35 | LABELS small 36 | REQUIRED_FILES "${CMAKE_CURRENT_SOURCE_DIR}/solver_disabled_test.py" 37 | TIMEOUT 60 38 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 39 | ) 40 | -------------------------------------------------------------------------------- /drake_cmake_external/README.md: -------------------------------------------------------------------------------- 1 | # CMake Project with Drake as an External 2 | 3 | This pulls in Drake using the CMake `ExternalProject_Add(drake)` mechanism. 4 | 5 | ## Instructions 6 | 7 | First, run the `install_prereqs` script to download the 8 | Drake source to `drake/` (from the current directory). 9 | This also runs Drake's setup script to install the required Ubuntu packages: 10 | 11 | ```bash 12 | setup/install_prereqs 13 | ``` 14 | 15 | Keep in mind that within the top-level CMakeLists, the drake source is once 16 | again downloaded as an external project. If the CMakeLists is modified to use 17 | a specific version of drake other than master, and any dependencies have 18 | changed within that version, then the script ran above must also be modified. 19 | 20 | Once all necessary dependencies have been installed, build and run tests 21 | using CMake: 22 | 23 | ```bash 24 | mkdir build 25 | cd build 26 | cmake .. 27 | cmake --build . 28 | 29 | cd drake_external_examples 30 | ctest -V . 31 | ``` 32 | 33 | ### Using a specific commit of Drake 34 | 35 | To use Drake sources from a specific commit, pass two cache variables to 36 | CMake (from either the CLI or the GUI): 37 | 38 | * `DRAKE_COMMIT_HASH`: the commit hash 39 | * `DRAKE_COMMIT_SHA256`: the checksum of the archive downloaded from GitHub 40 | (download https://github.com/RobotLocomotion/drake/archive/.tar.gz 41 | and use `shasum -a 256 'xxx.tar.gz'`) 42 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | # Note that the minimum required version of CMake to consume a binary 4 | # installation of Drake is lower than the minimum required version 5 | # when building Drake from source (as seen in drake_cmake_external). 6 | # The maximum version below allows for the use of modern policies 7 | # with newer versions of CMake. 8 | cmake_minimum_required(VERSION 3.9...4.0) 9 | project(drake_cmake_installed_apt) 10 | 11 | include(CTest) 12 | 13 | set(CMAKE_CXX_EXTENSIONS OFF) 14 | set(CMAKE_CXX_STANDARD 20) 15 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 16 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 17 | 18 | find_package(Threads MODULE REQUIRED) 19 | 20 | add_library(gtest STATIC 21 | third_party/googletest/1.10/googletest/include/gtest/gtest.h 22 | third_party/googletest/1.10/googletest/src/gtest-all.cc 23 | ) 24 | target_include_directories(gtest PUBLIC 25 | third_party/googletest/1.10/googletest/include 26 | ) 27 | target_link_libraries(gtest Threads::Threads) 28 | 29 | find_package(drake CONFIG REQUIRED PATHS /opt/drake) 30 | find_package(Python3 ${drake_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development) 31 | 32 | get_filename_component(DRAKE_PYTHONPATH "${drake_DIR}" DIRECTORY) 33 | get_filename_component(DRAKE_PYTHONPATH "${DRAKE_PYTHONPATH}" DIRECTORY) 34 | set(DRAKE_PYTHONPATH 35 | "${DRAKE_PYTHONPATH}/python${drake_PYTHON_VERSION}/site-packages" 36 | ) 37 | 38 | add_subdirectory(src) 39 | 40 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | --- 4 | name: ci 5 | on: 6 | push: 7 | branches: 8 | - main 9 | pull_request: 10 | branches: 11 | - main 12 | schedule: 13 | - cron: '0 12 * * *' 14 | workflow_dispatch: 15 | inputs: 16 | linux_noble_package_deb: 17 | description: 'Drake linux-noble-*-packaging .deb artifact URL' 18 | required: false 19 | concurrency: 20 | # Cancel previous CI runs when additional commits are added to a pull request. 21 | # This will not cancel CI runs associated with `schedule` or `push`. 22 | group: ${{ github.head_ref || github.run_id }} 23 | cancel-in-progress: true 24 | jobs: 25 | ubuntu_noble_cmake_installed_apt: 26 | name: ubuntu 24.04 noble 27 | runs-on: ubuntu-latest 28 | container: ubuntu:noble 29 | steps: 30 | - name: checkout 31 | uses: actions/checkout@v6 32 | - name: setup 33 | working-directory: drake_cmake_installed_apt 34 | run: | 35 | args=() 36 | if [[ '${{ github.event.inputs.linux_noble_package_deb }}' != '' ]]; then 37 | args+=(--package-url ${{ github.event.inputs.linux_noble_package_deb }}) 38 | fi 39 | .github/ubuntu_apt_setup "${args[@]}" 40 | shell: bash 41 | - name: cmake_installed_apt build and test 42 | working-directory: drake_cmake_installed_apt 43 | run: .github/ci_build_test 44 | shell: bash 45 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/src/particle.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace drake_external_examples { 12 | namespace particles { 13 | 14 | /// A linear 1DOF particle system. 15 | /// 16 | /// With very simple dynamics @f$ \ddot x = a @f$, this system can be 17 | /// described in terms of its: 18 | /// 19 | /// - Inputs: 20 | /// - linear acceleration (input index 0), in @f$ m/s^2 @f$ units. 21 | /// - States/Outputs: 22 | /// - linear position (state/output index 0), in @f$ m @f$ units. 23 | /// - linear velocity (state/output index 1), in @f$ m/s @f$ units. 24 | /// 25 | /// @tparam_double_only 26 | /// 27 | template 28 | class Particle final : public drake::systems::LeafSystem { 29 | public: 30 | DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Particle); 31 | 32 | /// A constructor that initializes the system. 33 | Particle(); 34 | 35 | protected: 36 | void CopyStateOut(const drake::systems::Context& context, 37 | drake::systems::BasicVector* output) const; 38 | 39 | void DoCalcTimeDerivatives( 40 | const drake::systems::Context& context, 41 | drake::systems::ContinuousState* derivatives) const override; 42 | }; 43 | 44 | } // namespace particles 45 | } // namespace drake_external_examples 46 | -------------------------------------------------------------------------------- /drake_bazel_download/apps/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | load("@rules_python//python:defs.bzl", "py_binary", "py_test") 4 | 5 | # Make a simple Python application. 6 | py_binary( 7 | name = "simple_logging_example", 8 | srcs = ["simple_logging_example.py"], 9 | deps = [ 10 | "@drake//:pydrake", 11 | ], 12 | ) 13 | 14 | # Check that third-party include paths work properly. 15 | cc_test( 16 | name = "include_paths_test", 17 | srcs = ["include_paths_test.cc"], 18 | deps = [ 19 | "@drake//:drake_shared_library", 20 | ], 21 | ) 22 | 23 | # This ensures that downstream Bazel projects can use Drake's `find_resource` 24 | # functionality without needing to resort to environment variables. 25 | py_test( 26 | name = "find_resource_py_test", 27 | main = "find_resource_test.py", 28 | srcs = ["find_resource_test.py"], 29 | deps = [ 30 | "@drake//:pydrake", 31 | ], 32 | ) 33 | 34 | cc_test( 35 | name = "find_resource_cc_test", 36 | srcs = ["find_resource_test.cc"], 37 | deps = [ 38 | "@drake//:drake_shared_library", 39 | ] 40 | ) 41 | 42 | sh_test( 43 | name = "simple_logging_example_test", 44 | size = "small", 45 | srcs = ["exec.sh"], 46 | args = ["$(location :simple_logging_example)"], 47 | data = [":simple_logging_example"], 48 | ) 49 | 50 | py_test( 51 | name = "import_all_py_test", 52 | main = "import_all_test.py", 53 | srcs = ["import_all_test.py"], 54 | deps = [ 55 | "@drake//:pydrake", 56 | ], 57 | ) 58 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/particle/particle.h: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace drake_external_examples { 12 | namespace particles { 13 | 14 | /// A linear 1DOF particle system. 15 | /// 16 | /// With very simple dynamics @f$ \ddot x = a @f$, this system can be 17 | /// described in terms of its: 18 | /// 19 | /// - Inputs: 20 | /// - linear acceleration (input index 0), in @f$ m/s^2 @f$ units. 21 | /// - States/Outputs: 22 | /// - linear position (state/output index 0), in @f$ m @f$ units. 23 | /// - linear velocity (state/output index 1), in @f$ m/s @f$ units. 24 | /// 25 | /// @tparam_double_only 26 | /// 27 | template 28 | class Particle final : public drake::systems::LeafSystem { 29 | public: 30 | DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Particle); 31 | 32 | /// A constructor that initializes the system. 33 | Particle(); 34 | 35 | protected: 36 | void CopyStateOut(const drake::systems::Context& context, 37 | drake::systems::BasicVector* output) const; 38 | 39 | void DoCalcTimeDerivatives( 40 | const drake::systems::Context& context, 41 | drake::systems::ContinuousState* derivatives) const override; 42 | }; 43 | 44 | } // namespace particles 45 | } // namespace drake_external_examples 46 | -------------------------------------------------------------------------------- /drake_cmake_installed/third_party/googletest/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /drake_bazel_download/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | --- 4 | name: ci 5 | on: 6 | push: 7 | branches: 8 | - main 9 | pull_request: 10 | branches: 11 | - main 12 | schedule: 13 | - cron: '0 12 * * *' 14 | workflow_dispatch: 15 | inputs: 16 | linux_noble_package_tar: 17 | description: 'Drake linux-noble-*-packaging .tar.gz artifact URL' 18 | required: false 19 | concurrency: 20 | # Cancel previous CI runs when additional commits are added to a pull request. 21 | # This will not cancel CI runs associated with `schedule` or `push`. 22 | group: ${{ github.head_ref || github.run_id }} 23 | cancel-in-progress: true 24 | jobs: 25 | ubuntu_noble_bazel_download: 26 | name: ubuntu 24.04 noble 27 | runs-on: ubuntu-latest 28 | container: ubuntu:noble 29 | steps: 30 | - name: checkout 31 | uses: actions/checkout@v6 32 | - name: setup 33 | working-directory: drake_bazel_download 34 | run: | 35 | args=() 36 | if [[ '${{ github.event.inputs.linux_noble_package_tar }}' != '' ]]; then 37 | args+=(--package-url ${{ github.event.inputs.linux_noble_package_tar }}) 38 | fi 39 | .github/ubuntu_setup "${args[@]}" 40 | shell: bash 41 | - name: install_bazelisk 42 | working-directory: drake_bazel_download 43 | run: setup/install_bazelisk 44 | shell: bash 45 | - name: bazel_download build and test 46 | working-directory: drake_bazel_download 47 | run: .github/ci_build_test 48 | shell: bash 49 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/third_party/googletest/1.10/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/simple_bindings/simple_bindings.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | /** 4 | * @file 5 | * Provides an example of creating a simple Drake C++ system and binding it in 6 | * pybind11, to be used with pydrake. 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace py = pybind11; 14 | 15 | using drake::systems::BasicVector; 16 | using drake::systems::Context; 17 | using drake::systems::LeafSystem; 18 | using drake::systems::kVectorValued; 19 | 20 | namespace drake_external_examples { 21 | namespace { 22 | 23 | /// Adds a constant to an input. 24 | template 25 | class SimpleAdder : public LeafSystem { 26 | public: 27 | explicit SimpleAdder(T add) 28 | : add_(add) { 29 | this->DeclareInputPort("in", kVectorValued, 1); 30 | this->DeclareVectorOutputPort( 31 | "out", BasicVector(1), &SimpleAdder::CalcOutput); 32 | } 33 | 34 | private: 35 | void CalcOutput(const Context& context, BasicVector* output) const { 36 | auto u = this->get_input_port(0).Eval(context); 37 | auto&& y = output->get_mutable_value(); 38 | y.array() = u.array() + add_; 39 | } 40 | 41 | const T add_{}; 42 | }; 43 | 44 | PYBIND11_MODULE(simple_bindings, m) { 45 | m.doc() = "Example module interfacing with pydrake and Drake C++"; 46 | 47 | py::module::import("pydrake.systems.framework"); 48 | 49 | using T = double; 50 | 51 | py::class_, LeafSystem>(m, "SimpleAdder") 52 | .def(py::init(), py::arg("add")); 53 | } 54 | 55 | } // namespace 56 | } // namespace drake_external_examples 57 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/.github/ubuntu_apt_setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | package_url= 7 | 8 | while [ "${1:-}" != "" ]; do 9 | case "$1" in 10 | --package-url) 11 | shift 12 | if [[ $# -eq 0 ]]; then 13 | echo 'No argument specified for --package-url' >&2 14 | exit 1 15 | fi 16 | package_url="$1" 17 | ;; 18 | *) 19 | echo 'Invalid command line argument' >&2 20 | exit 1 21 | esac 22 | shift 23 | done 24 | 25 | export DEBIAN_FRONTEND=noninteractive 26 | 27 | readonly apt_install=( 28 | apt-get 29 | -o Acquire::Retries=4 30 | -o Dpkg::Use-Pty=0 31 | -qy --no-install-recommends install 32 | ) 33 | 34 | apt-get -qq update || (sleep 30; apt-get -qq update) 35 | "${apt_install[@]}" \ 36 | build-essential \ 37 | ca-certificates \ 38 | cmake \ 39 | gnupg \ 40 | lsb-release \ 41 | python3-dev \ 42 | wget 43 | 44 | if [[ ! -z "${package_url}" ]]; then 45 | # Install a custom Drake package if specified. 46 | wget -O drake.deb ${package_url} 47 | trap 'rm -f drake.deb' EXIT 48 | 49 | "${apt_install[@]}" ./drake.deb 50 | else 51 | # Otherwise, install the latest released version. 52 | readonly codename="$(lsb_release -cs)" 53 | 54 | wget -qO- --retry-connrefused https://drake-apt.csail.mit.edu/drake.asc \ 55 | | gpg --dearmor - > /etc/apt/trusted.gpg.d/drake.gpg 56 | echo "deb [arch=amd64] https://drake-apt.csail.mit.edu/${codename} ${codename} main" \ 57 | > /etc/apt/sources.list.d/drake.list 58 | 59 | apt-get -qq update || (sleep 30; apt-get -qq update) 60 | "${apt_install[@]}" drake-dev 61 | fi 62 | -------------------------------------------------------------------------------- /.github/workflows/cmake_installed.yml: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | --- 4 | name: ci 5 | on: 6 | workflow_call: 7 | 8 | jobs: 9 | macos_sequoia_arm_cmake_installed: 10 | name: macos sequoia 15 arm 11 | runs-on: macos-15 12 | steps: 13 | - name: checkout 14 | uses: actions/checkout@v6 15 | - name: setup 16 | working-directory: drake_cmake_installed 17 | run: | 18 | args=() 19 | if [[ '${{ github.event.inputs.mac_arm_sequoia_package_tar }}' != '' ]]; then 20 | args+=(--package-url ${{ github.event.inputs.mac_arm_sequoia_package_tar }}) 21 | fi 22 | setup/install_prereqs "${args[@]}" 23 | shell: zsh -efuo pipefail {0} 24 | - name: cmake_installed build and test 25 | working-directory: drake_cmake_installed 26 | run: .github/ci_build_test 27 | shell: zsh -efuo pipefail {0} 28 | ubuntu_noble_cmake_installed: 29 | name: ubuntu 24.04 noble 30 | runs-on: ubuntu-latest 31 | container: ubuntu:noble 32 | steps: 33 | - name: checkout 34 | uses: actions/checkout@v6 35 | - name: setup 36 | working-directory: drake_cmake_installed 37 | run: | 38 | args=() 39 | if [[ '${{ github.event.inputs.linux_noble_package_tar }}' != '' ]]; then 40 | args+=(--package-url ${{ github.event.inputs.linux_noble_package_tar }}) 41 | fi 42 | .github/ubuntu_setup "${args[@]}" 43 | shell: bash 44 | - name: cmake_installed build and test 45 | working-directory: drake_cmake_installed 46 | run: .github/ci_build_test 47 | shell: bash 48 | -------------------------------------------------------------------------------- /private/drake_cmake_external_static/drake_external_examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | cmake_minimum_required(VERSION 3.16) 4 | project(drake_external_examples) 5 | 6 | find_package(drake CONFIG REQUIRED) 7 | 8 | add_executable(simple_continuous_time_system simple_continuous_time_system.cc) 9 | target_link_libraries(simple_continuous_time_system drake::drake) 10 | 11 | include(CTest) 12 | 13 | add_test(NAME simple_continuous_time_system 14 | COMMAND simple_continuous_time_system 15 | ) 16 | 17 | # Verify that drake::drake is a static library, as we've requested in 18 | # CMakeLists.txt. 19 | get_target_property(drake_type drake::drake TYPE) 20 | if (NOT drake_type STREQUAL "STATIC_LIBRARY") 21 | message(FATAL_ERROR 22 | "Expected drake::drake to be STATIC_LIBRARY, but got ${drake_type}." 23 | ) 24 | endif() 25 | 26 | # Verify that Python-related variables are not defined. 27 | if (DEFINED drake_PYTHON_VERSION OR DEFINED drake_PYTHON_DIR) 28 | message(FATAL_ERROR 29 | "Expected Python variables undefined, but got ${drake_PYTHON_VERSION} ${drake_PYTHON_DIR}." 30 | ) 31 | endif() 32 | 33 | # Verify that the pybind11 headers are not installed. 34 | include(CheckIncludeFileCXX) 35 | get_target_property(drake_include_dirs drake::drake INTERFACE_INCLUDE_DIRECTORIES) 36 | list(GET drake_include_dirs 0 drake_include_dir) 37 | file(GLOB pybind11_dir "${drake_include_dir}/pybind11") 38 | if(pybind11_dir) 39 | message(FATAL_ERROR "Found unexpected 'pybind11' in installed include directory.") 40 | endif() 41 | 42 | # Verify that the LCM runtime is disabled. 43 | add_executable(lcm_disabled lcm_disabled_test.cc) 44 | target_link_libraries(lcm_disabled drake::drake) 45 | add_test(NAME lcm_disabled_test COMMAND lcm_disabled) 46 | -------------------------------------------------------------------------------- /drake_bazel_external/README.md: -------------------------------------------------------------------------------- 1 | # Bazel Project with Drake as an External 2 | 3 | This pulls in Drake and builds it from source via Bazel's module mechanism. 4 | 5 | For an introduction to Bazel, refer to 6 | [Getting Started with Bazel](https://bazel.build/start). 7 | 8 | ## Instructions 9 | 10 | First, run the `install_prereqs` script to download 11 | the Drake source to `drake/` (from the current directory). 12 | This also runs Drake's setup script to install the required Ubuntu packages: 13 | 14 | ```bash 15 | setup/install_prereqs 16 | ``` 17 | 18 | Then, to build and test all apps: 19 | 20 | ```bash 21 | bazel test //... 22 | ``` 23 | 24 | As an example to run a binary directly: 25 | 26 | ```bash 27 | bazel run //apps:simple_logging_example 28 | ``` 29 | 30 | You may also run the binary directly per the `bazel-bin/...` path that the 31 | above command prints out; however, be aware that your working directories may 32 | cause differences. This is important when using tools like 33 | `drake::FindResource` / `pydrake.common.FindResource`. 34 | You may generally want to stick to using `bazel run` when able. 35 | 36 | ### Using a local checkout of Drake 37 | 38 | To use Drake sources on disk instead of downloaded from github, pass the flag 39 | ``--override_module=drake=/home/user/stuff/drake`` to bazel on the command line 40 | or add a line such as the following to ``user.bazelrc`` in the current directory: 41 | 42 | ```bash 43 | build --override_module=drake=/home/user/stuff/drake 44 | ``` 45 | 46 | ## Python Versions 47 | 48 | By default, Python 3 is the Python interpreter that Drake will use when built 49 | with Bazel. To see which Python versions are supported, see the 50 | [supported configurations](https://drake.mit.edu/developers.html#supported-configurations). 51 | -------------------------------------------------------------------------------- /.github/workflows/pip.yml: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | --- 4 | name: ci 5 | on: 6 | workflow_call: 7 | 8 | jobs: 9 | macos_sequoia_arm_pip: 10 | name: macos sequoia 15 arm 11 | runs-on: macos-15 12 | env: 13 | PYTHON_VERSION: '3.14' 14 | steps: 15 | - name: checkout 16 | uses: actions/checkout@v6 17 | - name: python setup 18 | uses: actions/setup-python@v6 19 | with: 20 | python-version: ${{ env.PYTHON_VERSION }} 21 | - name: venv setup and install 22 | working-directory: drake_pip 23 | run: | 24 | args=(--python-version $PYTHON_VERSION) 25 | if [[ '${{ github.event.inputs.mac_arm_sequoia_wheel }}' != '' ]]; then 26 | args+=(--wheel-url ${{ github.event.inputs.mac_arm_sequoia_wheel }}) 27 | fi 28 | setup/setup_env "${args[@]}" 29 | shell: zsh -eufo pipefail {0} 30 | - name: pip build and test 31 | working-directory: drake_pip 32 | run: .github/ci_build_test 33 | shell: zsh -efuo pipefail {0} 34 | ubuntu_noble_pip: 35 | name: ubuntu 24.04 noble 36 | runs-on: ubuntu-latest 37 | container: ubuntu:noble 38 | steps: 39 | - name: checkout 40 | uses: actions/checkout@v6 41 | - name: pip setup 42 | working-directory: drake_pip 43 | run: | 44 | args=() 45 | if [[ '${{ github.event.inputs.linux_noble_wheel }}' != '' ]]; then 46 | args+=(--wheel-url ${{ github.event.inputs.linux_noble_wheel }}) 47 | fi 48 | .github/ubuntu_setup "${args[@]}" 49 | shell: bash 50 | - name: pip build and test 51 | working-directory: drake_pip 52 | run: .github/ci_build_test 53 | shell: bash 54 | -------------------------------------------------------------------------------- /drake_bazel_external/apps/simple_adder_test.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | /** 4 | * @file 5 | * Provides an example of testing a custom C++ Drake system which will also 6 | * be bound in Python. 7 | */ 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "simple_adder.h" 18 | 19 | using drake::systems::Simulator; 20 | using drake::systems::DiagramBuilder; 21 | using drake::systems::ConstantVectorSource; 22 | using drake::systems::VectorLogSink; 23 | 24 | namespace drake_external_examples { 25 | namespace { 26 | 27 | int DoMain() { 28 | DiagramBuilder builder; 29 | auto source = builder.AddSystem>( 30 | Eigen::VectorXd::Constant(1, 10.)); 31 | auto adder = builder.AddSystem>(100.); 32 | builder.Connect(source->get_output_port(), adder->get_input_port(0)); 33 | auto logger = builder.AddSystem>(1); 34 | builder.Connect(adder->get_output_port(0), logger->get_input_port()); 35 | auto diagram = builder.Build(); 36 | 37 | Simulator simulator(*diagram); 38 | simulator.AdvanceTo(1); 39 | 40 | auto x = logger->FindLog(simulator.get_context()).data(); 41 | Eigen::VectorXd x_expected = Eigen::Vector2d(110., 110.); 42 | std::cout << "Output values: " << x << std::endl; 43 | DRAKE_DEMAND(x.isApprox(x_expected.transpose())); 44 | 45 | return 0; 46 | } 47 | 48 | } // namespace 49 | } // namespace drake_external_examples 50 | 51 | int main() { 52 | return drake_external_examples::DoMain(); 53 | } 54 | -------------------------------------------------------------------------------- /drake_bazel_download/.clang-format: -------------------------------------------------------------------------------- 1 | # -*- mode: yaml -*- 2 | # vi: set ft=yaml : 3 | # SPDX-License-Identifier: MIT-0 4 | 5 | --- 6 | BasedOnStyle: Google 7 | --- 8 | Language: Cpp 9 | DerivePointerAlignment: false 10 | PointerAlignment: Left 11 | 12 | IncludeCategories: 13 | - Regex: '^[<"](aio|arpa/inet|assert|complex|cpio|ctype|curses|dirent|dlfcn|errno|fcntl|fenv|float|fmtmsg|fnmatch|ftw|glob|grp|iconv|inttypes|iso646|langinfo|libgen|limits|locale|math|monetary|mqueue|ndbm|netdb|net/if|netinet/in|netinet/tcp|nl_types|poll|pthread|pwd|regex|sched|search|semaphore|setjmp|signal|spawn|stdalign|stdarg|stdatomic|stdbool|stddef|stdint|stdio|stdlib|stdnoreturn|string|strings|stropts|sys/ipc|syslog|sys/mman|sys/msg|sys/resource|sys/select|sys/sem|sys/shm|sys/socket|sys/stat|sys/statvfs|sys/time|sys/times|sys/types|sys/uio|sys/un|sys/utsname|sys/wait|tar|term|termios|tgmath|threads|time|trace|uchar|ulimit|uncntrl|unistd|utime|utmpx|wchar|wctype|wordexp)\.h[">]$' 14 | Priority: 10 15 | - Regex: '^[<"](algorithm|array|atomic|bitset|cassert|ccomplex|cctype|cerrno|cfenv|cfloat|chrono|cinttypes|ciso646|climits|clocale|cmath|codecvt|complex|condition_variable|csetjmp|csignal|cstdalign|cstdarg|cstdbool|cstddef|cstdint|cstdio|cstdlib|cstring|ctgmath|ctime|cuchar|cwchar|cwctype|deque|exception|forward_list|fstream|functional|future|initializer_list|iomanip|ios|iosfwd|iostream|istream|iterator|limits|list|locale|map|memory|mutex|new|numeric|ostream|queue|random|ratio|regex|scoped_allocator|set|shared_mutex|sstream|stack|stdexcept|streambuf|string|strstream|system_error|thread|tuple|type_traits|typeindex|typeinfo|unordered_map|unordered_set|utility|valarray|vector)[">]$' 16 | Priority: 20 17 | - Regex: '^<' 18 | Priority: 30 19 | - Regex: '^"(drake|drake_external_examples)' 20 | Priority: 50 21 | - Regex: '^"' 22 | Priority: 40 23 | -------------------------------------------------------------------------------- /drake_bazel_external/.clang-format: -------------------------------------------------------------------------------- 1 | # -*- mode: yaml -*- 2 | # vi: set ft=yaml : 3 | # SPDX-License-Identifier: MIT-0 4 | 5 | --- 6 | BasedOnStyle: Google 7 | --- 8 | Language: Cpp 9 | DerivePointerAlignment: false 10 | PointerAlignment: Left 11 | 12 | IncludeCategories: 13 | - Regex: '^[<"](aio|arpa/inet|assert|complex|cpio|ctype|curses|dirent|dlfcn|errno|fcntl|fenv|float|fmtmsg|fnmatch|ftw|glob|grp|iconv|inttypes|iso646|langinfo|libgen|limits|locale|math|monetary|mqueue|ndbm|netdb|net/if|netinet/in|netinet/tcp|nl_types|poll|pthread|pwd|regex|sched|search|semaphore|setjmp|signal|spawn|stdalign|stdarg|stdatomic|stdbool|stddef|stdint|stdio|stdlib|stdnoreturn|string|strings|stropts|sys/ipc|syslog|sys/mman|sys/msg|sys/resource|sys/select|sys/sem|sys/shm|sys/socket|sys/stat|sys/statvfs|sys/time|sys/times|sys/types|sys/uio|sys/un|sys/utsname|sys/wait|tar|term|termios|tgmath|threads|time|trace|uchar|ulimit|uncntrl|unistd|utime|utmpx|wchar|wctype|wordexp)\.h[">]$' 14 | Priority: 10 15 | - Regex: '^[<"](algorithm|array|atomic|bitset|cassert|ccomplex|cctype|cerrno|cfenv|cfloat|chrono|cinttypes|ciso646|climits|clocale|cmath|codecvt|complex|condition_variable|csetjmp|csignal|cstdalign|cstdarg|cstdbool|cstddef|cstdint|cstdio|cstdlib|cstring|ctgmath|ctime|cuchar|cwchar|cwctype|deque|exception|forward_list|fstream|functional|future|initializer_list|iomanip|ios|iosfwd|iostream|istream|iterator|limits|list|locale|map|memory|mutex|new|numeric|ostream|queue|random|ratio|regex|scoped_allocator|set|shared_mutex|sstream|stack|stdexcept|streambuf|string|strstream|system_error|thread|tuple|type_traits|typeindex|typeinfo|unordered_map|unordered_set|utility|valarray|vector)[">]$' 16 | Priority: 20 17 | - Regex: '^<' 18 | Priority: 30 19 | - Regex: '^"(drake|drake_external_examples)' 20 | Priority: 50 21 | - Regex: '^"' 22 | Priority: 40 23 | -------------------------------------------------------------------------------- /drake_cmake_external/.clang-format: -------------------------------------------------------------------------------- 1 | # -*- mode: yaml -*- 2 | # vi: set ft=yaml : 3 | # SPDX-License-Identifier: MIT-0 4 | 5 | --- 6 | BasedOnStyle: Google 7 | --- 8 | Language: Cpp 9 | DerivePointerAlignment: false 10 | PointerAlignment: Left 11 | 12 | IncludeCategories: 13 | - Regex: '^[<"](aio|arpa/inet|assert|complex|cpio|ctype|curses|dirent|dlfcn|errno|fcntl|fenv|float|fmtmsg|fnmatch|ftw|glob|grp|iconv|inttypes|iso646|langinfo|libgen|limits|locale|math|monetary|mqueue|ndbm|netdb|net/if|netinet/in|netinet/tcp|nl_types|poll|pthread|pwd|regex|sched|search|semaphore|setjmp|signal|spawn|stdalign|stdarg|stdatomic|stdbool|stddef|stdint|stdio|stdlib|stdnoreturn|string|strings|stropts|sys/ipc|syslog|sys/mman|sys/msg|sys/resource|sys/select|sys/sem|sys/shm|sys/socket|sys/stat|sys/statvfs|sys/time|sys/times|sys/types|sys/uio|sys/un|sys/utsname|sys/wait|tar|term|termios|tgmath|threads|time|trace|uchar|ulimit|uncntrl|unistd|utime|utmpx|wchar|wctype|wordexp)\.h[">]$' 14 | Priority: 10 15 | - Regex: '^[<"](algorithm|array|atomic|bitset|cassert|ccomplex|cctype|cerrno|cfenv|cfloat|chrono|cinttypes|ciso646|climits|clocale|cmath|codecvt|complex|condition_variable|csetjmp|csignal|cstdalign|cstdarg|cstdbool|cstddef|cstdint|cstdio|cstdlib|cstring|ctgmath|ctime|cuchar|cwchar|cwctype|deque|exception|forward_list|fstream|functional|future|initializer_list|iomanip|ios|iosfwd|iostream|istream|iterator|limits|list|locale|map|memory|mutex|new|numeric|ostream|queue|random|ratio|regex|scoped_allocator|set|shared_mutex|sstream|stack|stdexcept|streambuf|string|strstream|system_error|thread|tuple|type_traits|typeindex|typeinfo|unordered_map|unordered_set|utility|valarray|vector)[">]$' 16 | Priority: 20 17 | - Regex: '^<' 18 | Priority: 30 19 | - Regex: '^"(drake|drake_external_examples)' 20 | Priority: 50 21 | - Regex: '^"' 22 | Priority: 40 23 | -------------------------------------------------------------------------------- /drake_cmake_installed/.clang-format: -------------------------------------------------------------------------------- 1 | # -*- mode: yaml -*- 2 | # vi: set ft=yaml : 3 | # SPDX-License-Identifier: MIT-0 4 | 5 | --- 6 | BasedOnStyle: Google 7 | --- 8 | Language: Cpp 9 | DerivePointerAlignment: false 10 | PointerAlignment: Left 11 | 12 | IncludeCategories: 13 | - Regex: '^[<"](aio|arpa/inet|assert|complex|cpio|ctype|curses|dirent|dlfcn|errno|fcntl|fenv|float|fmtmsg|fnmatch|ftw|glob|grp|iconv|inttypes|iso646|langinfo|libgen|limits|locale|math|monetary|mqueue|ndbm|netdb|net/if|netinet/in|netinet/tcp|nl_types|poll|pthread|pwd|regex|sched|search|semaphore|setjmp|signal|spawn|stdalign|stdarg|stdatomic|stdbool|stddef|stdint|stdio|stdlib|stdnoreturn|string|strings|stropts|sys/ipc|syslog|sys/mman|sys/msg|sys/resource|sys/select|sys/sem|sys/shm|sys/socket|sys/stat|sys/statvfs|sys/time|sys/times|sys/types|sys/uio|sys/un|sys/utsname|sys/wait|tar|term|termios|tgmath|threads|time|trace|uchar|ulimit|uncntrl|unistd|utime|utmpx|wchar|wctype|wordexp)\.h[">]$' 14 | Priority: 10 15 | - Regex: '^[<"](algorithm|array|atomic|bitset|cassert|ccomplex|cctype|cerrno|cfenv|cfloat|chrono|cinttypes|ciso646|climits|clocale|cmath|codecvt|complex|condition_variable|csetjmp|csignal|cstdalign|cstdarg|cstdbool|cstddef|cstdint|cstdio|cstdlib|cstring|ctgmath|ctime|cuchar|cwchar|cwctype|deque|exception|forward_list|fstream|functional|future|initializer_list|iomanip|ios|iosfwd|iostream|istream|iterator|limits|list|locale|map|memory|mutex|new|numeric|ostream|queue|random|ratio|regex|scoped_allocator|set|shared_mutex|sstream|stack|stdexcept|streambuf|string|strstream|system_error|thread|tuple|type_traits|typeindex|typeinfo|unordered_map|unordered_set|utility|valarray|vector)[">]$' 16 | Priority: 20 17 | - Regex: '^<' 18 | Priority: 30 19 | - Regex: '^"(drake|drake_external_examples)' 20 | Priority: 50 21 | - Regex: '^"' 22 | Priority: 40 23 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/.clang-format: -------------------------------------------------------------------------------- 1 | # -*- mode: yaml -*- 2 | # vi: set ft=yaml : 3 | # SPDX-License-Identifier: MIT-0 4 | 5 | --- 6 | BasedOnStyle: Google 7 | --- 8 | Language: Cpp 9 | DerivePointerAlignment: false 10 | PointerAlignment: Left 11 | 12 | IncludeCategories: 13 | - Regex: '^[<"](aio|arpa/inet|assert|complex|cpio|ctype|curses|dirent|dlfcn|errno|fcntl|fenv|float|fmtmsg|fnmatch|ftw|glob|grp|iconv|inttypes|iso646|langinfo|libgen|limits|locale|math|monetary|mqueue|ndbm|netdb|net/if|netinet/in|netinet/tcp|nl_types|poll|pthread|pwd|regex|sched|search|semaphore|setjmp|signal|spawn|stdalign|stdarg|stdatomic|stdbool|stddef|stdint|stdio|stdlib|stdnoreturn|string|strings|stropts|sys/ipc|syslog|sys/mman|sys/msg|sys/resource|sys/select|sys/sem|sys/shm|sys/socket|sys/stat|sys/statvfs|sys/time|sys/times|sys/types|sys/uio|sys/un|sys/utsname|sys/wait|tar|term|termios|tgmath|threads|time|trace|uchar|ulimit|uncntrl|unistd|utime|utmpx|wchar|wctype|wordexp)\.h[">]$' 14 | Priority: 10 15 | - Regex: '^[<"](algorithm|array|atomic|bitset|cassert|ccomplex|cctype|cerrno|cfenv|cfloat|chrono|cinttypes|ciso646|climits|clocale|cmath|codecvt|complex|condition_variable|csetjmp|csignal|cstdalign|cstdarg|cstdbool|cstddef|cstdint|cstdio|cstdlib|cstring|ctgmath|ctime|cuchar|cwchar|cwctype|deque|exception|forward_list|fstream|functional|future|initializer_list|iomanip|ios|iosfwd|iostream|istream|iterator|limits|list|locale|map|memory|mutex|new|numeric|ostream|queue|random|ratio|regex|scoped_allocator|set|shared_mutex|sstream|stack|stdexcept|streambuf|string|strstream|system_error|thread|tuple|type_traits|typeindex|typeinfo|unordered_map|unordered_set|utility|valarray|vector)[">]$' 16 | Priority: 20 17 | - Regex: '^<' 18 | Priority: 30 19 | - Regex: '^"(drake|drake_external_examples)' 20 | Priority: 50 21 | - Regex: '^"' 22 | Priority: 40 23 | -------------------------------------------------------------------------------- /drake_poetry/setup/install_prereqs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | set -euxo pipefail 5 | 6 | wheel_url= 7 | python_version='3' 8 | 9 | while [ "${1:-}" != "" ]; do 10 | case "$1" in 11 | --wheel-url) 12 | shift 13 | if [[ $# -eq 0 ]]; then 14 | echo 'No argument specified for --wheel-url' >&2 15 | exit 1 16 | fi 17 | wheel_url="$1" 18 | ;; 19 | --python-version) 20 | shift 21 | if [[ $# -eq 0 ]]; then 22 | echo 'No argument specified for --python-version' >&2 23 | exit 1 24 | fi 25 | python_version="$1" 26 | ;; 27 | *) 28 | echo 'Invalid command line argument' >&2 29 | exit 1 30 | esac 31 | shift 32 | done 33 | 34 | maybe_sudo= 35 | if [[ "${EUID}" -ne 0 ]]; then 36 | maybe_sudo=sudo 37 | fi 38 | 39 | if [[ "$OSTYPE" == "linux"* ]]; then 40 | # Ubuntu-specific installations 41 | # See https://github.com/RobotLocomotion/drake/blob/master/tools/wheel/content/INSTALLATION 42 | # for a complete list of the required libraries to be installed. 43 | ${maybe_sudo} apt-get update 44 | ${maybe_sudo} apt-get install --no-install-recommends $(cat <&2 15 | exit 1 16 | fi 17 | package_url="$1" 18 | ;; 19 | *) 20 | echo 'Invalid command line argument' >&2 21 | exit 1 22 | esac 23 | shift 24 | done 25 | 26 | maybe_sudo= 27 | 28 | case "$OSTYPE" in 29 | darwin*) 30 | # Mac specific installations 31 | if [[ "${EUID}" -eq 0 ]]; then 32 | echo 'This script must NOT be run as root' >&2 33 | exit 1 34 | fi 35 | 36 | # Download the drake source 37 | curl -o drake.tar.gz "${package_url:-https://drake-packages.csail.mit.edu/drake/nightly/drake-latest-mac-arm64.tar.gz}" 38 | trap 'rm -f drake.tar.gz' EXIT 39 | tar -xf drake.tar.gz -C $HOME 40 | ;; 41 | 42 | linux*) 43 | # Ubuntu specific installations 44 | if [[ "${EUID}" -ne 0 ]]; then 45 | maybe_sudo=sudo 46 | fi 47 | 48 | ${maybe_sudo} apt-get update 49 | ${maybe_sudo} apt-get install --no-install-recommends lsb-release 50 | 51 | if [[ "$(lsb_release -sc)" != 'noble' ]]; then 52 | echo 'This script requires Ubuntu 24.04 (Noble)' >&2 53 | exit 3 54 | fi 55 | 56 | ${maybe_sudo} apt-get install --no-install-recommends $(cat <master.'), 19 | ]) 20 | 21 | if (env.BRANCH_NAME == 'main') { 22 | def triggers = [] 23 | triggers << cron('H H(7-8) * * *') 24 | props << pipelineTriggers(triggers) 25 | } 26 | 27 | properties(props) 28 | 29 | def examples = [ 30 | 'drake_bazel_external', 31 | 'drake_cmake_external', 32 | 'private/drake_cmake_external_static' 33 | ] 34 | def jobs = [:] 35 | 36 | for (example in examples) { 37 | def name = example 38 | jobs[name] = { 39 | node('linux-noble-unprovisioned') { 40 | timeout(600) { 41 | ansiColor('xterm') { 42 | try { 43 | dir('src') { 44 | stage('checkout') { 45 | checkout scm 46 | } 47 | } 48 | dir('src/' + name) { 49 | stage(name + ' setup') { 50 | sh ".github/setup --drake-commit-hash ${params.drakeSha}" 51 | } 52 | stage(name + ' build and test') { 53 | sh ".github/ci_build_test --drake-commit-hash ${params.drakeSha}" 54 | } 55 | } 56 | } catch (e) { 57 | if (env.BRANCH_NAME == 'main' && !is_downstream_build) { 58 | emailext ( 59 | subject: "Build failed in Jenkins: ${env.JOB_NAME} #${env.BUILD_NUMBER}", 60 | body: "See <${env.BUILD_URL}display/redirect?page=changes>", 61 | recipientProviders: [[$class: 'DevelopersRecipientProvider']], 62 | to: '$DEFAULT_RECIPIENTS', 63 | ) 64 | } 65 | throw e 66 | } 67 | } 68 | } 69 | } 70 | } 71 | } 72 | 73 | parallel jobs 74 | -------------------------------------------------------------------------------- /drake_pip/README.md: -------------------------------------------------------------------------------- 1 | # Python Project with Drake Installed from Pip 2 | 3 | This installs Drake using [`pip`](https://pypi.org/project/pip/), 4 | the Python package manager. 5 | 6 | # Instructions 7 | 8 | Follow the setup instructions for [Ubuntu](#ubuntu-setup) 9 | or [Mac OS](#mac-setup). 10 | 11 | See [Installation via Pip](https://drake.mit.edu/pip.html#stable-releases) 12 | for more information on installation. 13 | 14 | ## Ubuntu Setup 15 | 16 | If on Ubuntu, first install the required packages: 17 | 18 | ```bash 19 | setup/install_prereqs 20 | ``` 21 | 22 | This script will also run `setup/setup_env`, 23 | which creates the virtual environment for this project and installs Drake. 24 | 25 | To start programming, simply activate the environment by calling: 26 | 27 | ```bash 28 | source env/bin/activate 29 | ``` 30 | 31 | ## Mac Setup 32 | 33 | If on Mac OS X, simply ensure the correct version of Python 34 | is installed from Homebrew by referring to the 35 | [Supported Configurations](https://drake.mit.edu/installation.html#supported-configurations). 36 | 37 | Then, run the following script to create the virtual environment 38 | for this project and install Drake: 39 | 40 | ```bash 41 | setup/setup_env 42 | ``` 43 | 44 | *Note*: If you have multiple versions of Python installed, 45 | you can specify the correct version as an optional argument 46 | to the script. For example, to use `python3.14`, call: 47 | 48 | ```bash 49 | setup/setup_env --python-version 3.14 50 | ``` 51 | 52 | Refer to the 53 | [Drake installation documentation](https://drake.mit.edu/installation.html) 54 | for the versions of Python officially supported on each OS 55 | when installing via PyPI. 56 | 57 | To start programming, simply activate the environment by calling: 58 | 59 | ```bash 60 | source env/bin/activate 61 | ``` 62 | 63 | # Examples 64 | 65 | To run the particle example tests in this directory, 66 | navigate to `src` and call the test file to execute the unit tests: 67 | 68 | ```bash 69 | cd src 70 | python3 particle_test.py 71 | ``` 72 | 73 | For more information on what's available for Drake in Python, 74 | see [Using Drake from Python](https://drake.mit.edu/python_bindings.html) 75 | and the Python API [pydrake](https://drake.mit.edu/pydrake/index.html). 76 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/src/particle.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | #include "particle.h" 4 | 5 | #include 6 | #include 7 | 8 | namespace drake_external_examples { 9 | namespace particles { 10 | 11 | template 12 | Particle::Particle() { 13 | // A 1D input vector for acceleration. 14 | this->DeclareInputPort(drake::systems::kUseDefaultName, 15 | drake::systems::kVectorValued, 1); 16 | // Adding one generalized position and one generalized velocity. 17 | this->DeclareContinuousState(1, 1, 0); 18 | // A 2D output vector for position and velocity. 19 | this->DeclareVectorOutputPort(drake::systems::kUseDefaultName, 20 | drake::systems::BasicVector(2), 21 | &Particle::CopyStateOut); 22 | } 23 | 24 | template 25 | void Particle::CopyStateOut(const drake::systems::Context& context, 26 | drake::systems::BasicVector* output) const { 27 | // Get current state from context. 28 | const drake::systems::VectorBase& continuous_state_vector = 29 | context.get_continuous_state_vector(); 30 | // Write system output. 31 | output->set_value(continuous_state_vector.CopyToVector()); 32 | } 33 | 34 | template 35 | void Particle::DoCalcTimeDerivatives( 36 | const drake::systems::Context& context, 37 | drake::systems::ContinuousState* derivatives) const { 38 | // Get current state from context. 39 | const drake::systems::VectorBase& continuous_state_vector = 40 | context.get_continuous_state_vector(); 41 | // Obtain the structure we need to write into. 42 | drake::systems::VectorBase& derivatives_vector = 43 | derivatives->get_mutable_vector(); 44 | // Get current input acceleration value. 45 | const drake::systems::BasicVector* input_vector = 46 | this->EvalVectorInput(context, 0); 47 | // Set the derivatives. The first one is 48 | // velocity and the second one is acceleration. 49 | derivatives_vector.SetAtIndex(0, continuous_state_vector.GetAtIndex(1)); 50 | derivatives_vector.SetAtIndex(1, input_vector->GetAtIndex(0)); 51 | } 52 | 53 | template class Particle; 54 | 55 | } // namespace particles 56 | } // namespace drake_external_examples 57 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/particle/particle.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | #include "particle.h" 4 | 5 | #include 6 | #include 7 | 8 | namespace drake_external_examples { 9 | namespace particles { 10 | 11 | template 12 | Particle::Particle() { 13 | // A 1D input vector for acceleration. 14 | this->DeclareInputPort(drake::systems::kUseDefaultName, 15 | drake::systems::kVectorValued, 1); 16 | // Adding one generalized position and one generalized velocity. 17 | this->DeclareContinuousState(1, 1, 0); 18 | // A 2D output vector for position and velocity. 19 | this->DeclareVectorOutputPort(drake::systems::kUseDefaultName, 20 | drake::systems::BasicVector(2), 21 | &Particle::CopyStateOut); 22 | } 23 | 24 | template 25 | void Particle::CopyStateOut(const drake::systems::Context& context, 26 | drake::systems::BasicVector* output) const { 27 | // Get current state from context. 28 | const drake::systems::VectorBase& continuous_state_vector = 29 | context.get_continuous_state_vector(); 30 | // Write system output. 31 | output->set_value(continuous_state_vector.CopyToVector()); 32 | } 33 | 34 | template 35 | void Particle::DoCalcTimeDerivatives( 36 | const drake::systems::Context& context, 37 | drake::systems::ContinuousState* derivatives) const { 38 | // Get current state from context. 39 | const drake::systems::VectorBase& continuous_state_vector = 40 | context.get_continuous_state_vector(); 41 | // Obtain the structure we need to write into. 42 | drake::systems::VectorBase& derivatives_vector = 43 | derivatives->get_mutable_vector(); 44 | // Get current input acceleration value. 45 | const drake::systems::BasicVector* input_vector = 46 | this->EvalVectorInput(context, 0); 47 | // Set the derivatives. The first one is 48 | // velocity and the second one is acceleration. 49 | derivatives_vector.SetAtIndex(0, continuous_state_vector.GetAtIndex(1)); 50 | derivatives_vector.SetAtIndex(1, input_vector->GetAtIndex(0)); 51 | } 52 | 53 | template class Particle; 54 | 55 | } // namespace particles 56 | } // namespace drake_external_examples 57 | -------------------------------------------------------------------------------- /drake_cmake_installed/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | --- 4 | name: ci 5 | on: 6 | push: 7 | branches: 8 | - main 9 | pull_request: 10 | branches: 11 | - main 12 | schedule: 13 | - cron: '0 12 * * *' 14 | workflow_dispatch: 15 | inputs: 16 | linux_noble_package_tar: 17 | description: 'Drake linux-noble-*-packaging .tar.gz artifact URL' 18 | required: false 19 | mac_arm_sequoia_package_tar: 20 | description: 'Drake mac-arm-sequoia-*-packaging .tar.gz artifact URL' 21 | required: false 22 | concurrency: 23 | # Cancel previous CI runs when additional commits are added to a pull request. 24 | # This will not cancel CI runs associated with `schedule` or `push`. 25 | group: ${{ github.head_ref || github.run_id }} 26 | cancel-in-progress: true 27 | jobs: 28 | macos_sequoia_arm_cmake_installed: 29 | name: macos sequoia 15 arm 30 | runs-on: macos-15 31 | steps: 32 | - name: checkout 33 | uses: actions/checkout@v6 34 | - name: setup 35 | working-directory: drake_cmake_installed 36 | run: | 37 | args=() 38 | if [[ '${{ github.event.inputs.mac_arm_sequoia_package_tar }}' != '' ]]; then 39 | args+=(--package-url ${{ github.event.inputs.mac_arm_sequoia_package_tar }}) 40 | fi 41 | setup/install_prereqs "${args[@]}" 42 | shell: zsh -efuo pipefail {0} 43 | - name: cmake_installed build and test 44 | working-directory: drake_cmake_installed 45 | run: .github/ci_build_test 46 | shell: zsh -efuo pipefail {0} 47 | ubuntu_noble_cmake_installed: 48 | name: ubuntu 24.04 noble 49 | runs-on: ubuntu-latest 50 | container: ubuntu:noble 51 | steps: 52 | - name: checkout 53 | uses: actions/checkout@v6 54 | - name: setup 55 | working-directory: drake_cmake_installed 56 | run: | 57 | args=() 58 | if [[ '${{ github.event.inputs.linux_noble_package_tar }}' != '' ]]; then 59 | args+=(--package-url ${{ github.event.inputs.linux_noble_package_tar }}) 60 | fi 61 | .github/ubuntu_setup "${args[@]}" 62 | shell: bash 63 | - name: cmake_installed build and test 64 | working-directory: drake_cmake_installed 65 | run: .github/ci_build_test 66 | shell: bash 67 | -------------------------------------------------------------------------------- /drake_pip/src/particle_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | import unittest 4 | 5 | from particle import Particle 6 | 7 | 8 | class TestParticle(unittest.TestCase): 9 | """A test case for Particle systems.""" 10 | def setUp(self): 11 | # System (aka 'device under test') being tested. 12 | self.dut = Particle() 13 | # Context for the given dut. 14 | self.context = self.dut.CreateDefaultContext() 15 | # Outputs of the given dut. 16 | self.output = self.dut.AllocateOutput() 17 | # Derivatives of the given dut. 18 | self.derivatives = self.dut.AllocateTimeDerivatives() 19 | 20 | def test_output(self): 21 | """ 22 | Makes sure a Particle output is consistent with its state (position and 23 | velocity). 24 | """ 25 | # Initialize state. 26 | continuous_state_vector = \ 27 | self.context.get_mutable_continuous_state_vector() 28 | continuous_state_vector.SetAtIndex(0, 10.0) # x0 = 10 m. 29 | continuous_state_vector.SetAtIndex(1, 1.0) # x1 = 1 m/s. 30 | # Compute outputs. 31 | self.dut.CalcOutput(self.context, self.output) 32 | output_vector = self.output.get_vector_data(0) 33 | # Check results. 34 | self.assertEqual(output_vector.GetAtIndex(0), 10.0) # y0 == x0 35 | self.assertEqual(output_vector.GetAtIndex(1), 1.0) # y1 == x1 36 | 37 | def test_derivatives(self): 38 | """ 39 | Makes sure a Particle system state derivatives are consistent with its 40 | state and input (velocity and acceleration). 41 | """ 42 | # Set input. 43 | input_port = self.dut.get_input_port(0) 44 | input_port.FixValue(self.context, 1.0) # u0 = 1 m/s^2 45 | # Set state. 46 | continuous_state_vector = \ 47 | self.context.get_mutable_continuous_state_vector() 48 | continuous_state_vector.SetAtIndex(0, 0.0) # x0 = 0 m 49 | continuous_state_vector.SetAtIndex(1, 2.0) # x1 = 2 m/s 50 | # Compute derivatives. 51 | self.dut.CalcTimeDerivatives(self.context, self.derivatives) 52 | derivatives_vector = self.derivatives.get_vector() 53 | # Check results. 54 | self.assertEqual(derivatives_vector.GetAtIndex(0), 2.0) # x0dot == x1 55 | self.assertEqual(derivatives_vector.GetAtIndex(1), 1.0) # x1dot == u0 56 | 57 | 58 | if __name__ == '__main__': 59 | unittest.main() 60 | -------------------------------------------------------------------------------- /drake_poetry/src/particle_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | import unittest 4 | 5 | from particle import Particle 6 | 7 | 8 | class TestParticle(unittest.TestCase): 9 | """A test case for Particle systems.""" 10 | def setUp(self): 11 | # System (aka 'device under test') being tested. 12 | self.dut = Particle() 13 | # Context for the given dut. 14 | self.context = self.dut.CreateDefaultContext() 15 | # Outputs of the given dut. 16 | self.output = self.dut.AllocateOutput() 17 | # Derivatives of the given dut. 18 | self.derivatives = self.dut.AllocateTimeDerivatives() 19 | 20 | def test_output(self): 21 | """ 22 | Makes sure a Particle output is consistent with its state (position and 23 | velocity). 24 | """ 25 | # Initialize state. 26 | continuous_state_vector = \ 27 | self.context.get_mutable_continuous_state_vector() 28 | continuous_state_vector.SetAtIndex(0, 10.0) # x0 = 10 m. 29 | continuous_state_vector.SetAtIndex(1, 1.0) # x1 = 1 m/s. 30 | # Compute outputs. 31 | self.dut.CalcOutput(self.context, self.output) 32 | output_vector = self.output.get_vector_data(0) 33 | # Check results. 34 | self.assertEqual(output_vector.GetAtIndex(0), 10.0) # y0 == x0 35 | self.assertEqual(output_vector.GetAtIndex(1), 1.0) # y1 == x1 36 | 37 | def test_derivatives(self): 38 | """ 39 | Makes sure a Particle system state derivatives are consistent with its 40 | state and input (velocity and acceleration). 41 | """ 42 | # Set input. 43 | input_port = self.dut.get_input_port(0) 44 | input_port.FixValue(self.context, 1.0) # u0 = 1 m/s^2 45 | # Set state. 46 | continuous_state_vector = \ 47 | self.context.get_mutable_continuous_state_vector() 48 | continuous_state_vector.SetAtIndex(0, 0.0) # x0 = 0 m 49 | continuous_state_vector.SetAtIndex(1, 2.0) # x1 = 2 m/s 50 | # Compute derivatives. 51 | self.dut.CalcTimeDerivatives(self.context, self.derivatives) 52 | derivatives_vector = self.derivatives.get_vector() 53 | # Check results. 54 | self.assertEqual(derivatives_vector.GetAtIndex(0), 2.0) # x0dot == x1 55 | self.assertEqual(derivatives_vector.GetAtIndex(1), 1.0) # x1dot == u0 56 | 57 | 58 | if __name__ == '__main__': 59 | unittest.main() 60 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/src/particle_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | import unittest 4 | 5 | from particle import Particle 6 | 7 | 8 | class TestParticle(unittest.TestCase): 9 | """A test case for Particle systems.""" 10 | def setUp(self): 11 | # System (aka 'device under test') being tested. 12 | self.dut = Particle() 13 | # Context for the given dut. 14 | self.context = self.dut.CreateDefaultContext() 15 | # Outputs of the given dut. 16 | self.output = self.dut.AllocateOutput() 17 | # Derivatives of the given dut. 18 | self.derivatives = self.dut.AllocateTimeDerivatives() 19 | 20 | def test_output(self): 21 | """ 22 | Makes sure a Particle output is consistent with its state (position and 23 | velocity). 24 | """ 25 | # Initialize state. 26 | continuous_state_vector = \ 27 | self.context.get_mutable_continuous_state_vector() 28 | continuous_state_vector.SetAtIndex(0, 10.0) # x0 = 10 m. 29 | continuous_state_vector.SetAtIndex(1, 1.0) # x1 = 1 m/s. 30 | # Compute outputs. 31 | self.dut.CalcOutput(self.context, self.output) 32 | output_vector = self.output.get_vector_data(0) 33 | # Check results. 34 | self.assertEqual(output_vector.GetAtIndex(0), 10.0) # y0 == x0 35 | self.assertEqual(output_vector.GetAtIndex(1), 1.0) # y1 == x1 36 | 37 | def test_derivatives(self): 38 | """ 39 | Makes sure a Particle system state derivatives are consistent with its 40 | state and input (velocity and acceleration). 41 | """ 42 | # Set input. 43 | input_port = self.dut.get_input_port(0) 44 | input_port.FixValue(self.context, 1.0) # u0 = 1 m/s^2 45 | # Set state. 46 | continuous_state_vector = \ 47 | self.context.get_mutable_continuous_state_vector() 48 | continuous_state_vector.SetAtIndex(0, 0.0) # x0 = 0 m 49 | continuous_state_vector.SetAtIndex(1, 2.0) # x1 = 2 m/s 50 | # Compute derivatives. 51 | self.dut.CalcTimeDerivatives(self.context, self.derivatives) 52 | derivatives_vector = self.derivatives.get_vector() 53 | # Check results. 54 | self.assertEqual(derivatives_vector.GetAtIndex(0), 2.0) # x0dot == x1 55 | self.assertEqual(derivatives_vector.GetAtIndex(1), 1.0) # x1dot == u0 56 | 57 | 58 | if __name__ == '__main__': 59 | unittest.main() 60 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/particle/particle_test.py: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | import unittest 4 | 5 | from particle import Particle 6 | 7 | 8 | class TestParticle(unittest.TestCase): 9 | """A test case for Particle systems.""" 10 | def setUp(self): 11 | # System (aka 'device under test') being tested. 12 | self.dut = Particle() 13 | # Context for the given dut. 14 | self.context = self.dut.CreateDefaultContext() 15 | # Outputs of the given dut. 16 | self.output = self.dut.AllocateOutput() 17 | # Derivatives of the given dut. 18 | self.derivatives = self.dut.AllocateTimeDerivatives() 19 | 20 | def test_output(self): 21 | """ 22 | Makes sure a Particle output is consistent with its state (position and 23 | velocity). 24 | """ 25 | # Initialize state. 26 | continuous_state_vector = \ 27 | self.context.get_mutable_continuous_state_vector() 28 | continuous_state_vector.SetAtIndex(0, 10.0) # x0 = 10 m. 29 | continuous_state_vector.SetAtIndex(1, 1.0) # x1 = 1 m/s. 30 | # Compute outputs. 31 | self.dut.CalcOutput(self.context, self.output) 32 | output_vector = self.output.get_vector_data(0) 33 | # Check results. 34 | self.assertEqual(output_vector.GetAtIndex(0), 10.0) # y0 == x0 35 | self.assertEqual(output_vector.GetAtIndex(1), 1.0) # y1 == x1 36 | 37 | def test_derivatives(self): 38 | """ 39 | Makes sure a Particle system state derivatives are consistent with its 40 | state and input (velocity and acceleration). 41 | """ 42 | # Set input. 43 | input_port = self.dut.get_input_port(0) 44 | input_port.FixValue(self.context, 1.0) # u0 = 1 m/s^2 45 | # Set state. 46 | continuous_state_vector = \ 47 | self.context.get_mutable_continuous_state_vector() 48 | continuous_state_vector.SetAtIndex(0, 0.0) # x0 = 0 m 49 | continuous_state_vector.SetAtIndex(1, 2.0) # x1 = 2 m/s 50 | # Compute derivatives. 51 | self.dut.CalcTimeDerivatives(self.context, self.derivatives) 52 | derivatives_vector = self.derivatives.get_vector() 53 | # Check results. 54 | self.assertEqual(derivatives_vector.GetAtIndex(0), 2.0) # x0dot == x1 55 | self.assertEqual(derivatives_vector.GetAtIndex(1), 1.0) # x1dot == u0 56 | 57 | 58 | if __name__ == '__main__': 59 | unittest.main() 60 | -------------------------------------------------------------------------------- /drake_pip/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | --- 4 | name: ci 5 | on: 6 | push: 7 | branches: 8 | - main 9 | pull_request: 10 | branches: 11 | - main 12 | schedule: 13 | - cron: '0 12 * * *' 14 | workflow_dispatch: 15 | inputs: 16 | linux_noble_wheel: 17 | description: 'Drake linux-noble-*-wheel-*-release Python 3.12 artifact URL' 18 | required: false 19 | mac_arm_sequoia_wheel: 20 | description: 'Drake mac-arm-sequoia-*-wheel-*-release Python 3.14 artifact URL' 21 | required: false 22 | concurrency: 23 | # Cancel previous CI runs when additional commits are added to a pull request. 24 | # This will not cancel CI runs associated with `schedule` or `push`. 25 | group: ${{ github.head_ref || github.run_id }} 26 | cancel-in-progress: true 27 | jobs: 28 | macos_sequoia_arm_pip: 29 | name: macos sequoia 15 arm 30 | runs-on: macos-15 31 | env: 32 | PYTHON_VERSION: '3.14' 33 | steps: 34 | - name: checkout 35 | uses: actions/checkout@v6 36 | - name: python setup 37 | uses: actions/setup-python@v6 38 | with: 39 | python-version: ${{ env.PYTHON_VERSION }} 40 | - name: venv setup and install 41 | working-directory: drake_pip 42 | run: | 43 | args=(--python-version $PYTHON_VERSION) 44 | if [[ '${{ github.event.inputs.mac_arm_sequoia_wheel }}' != '' ]]; then 45 | args+=(--wheel-url ${{ github.event.inputs.mac_arm_sequoia_wheel }}) 46 | fi 47 | setup/setup_env "${args[@]}" 48 | shell: zsh -eufo pipefail {0} 49 | - name: pip build and test 50 | working-directory: drake_pip 51 | run: .github/ci_build_test 52 | shell: zsh -efuo pipefail {0} 53 | ubuntu_noble_pip: 54 | name: ubuntu 24.04 noble 55 | runs-on: ubuntu-latest 56 | container: ubuntu:noble 57 | steps: 58 | - name: checkout 59 | uses: actions/checkout@v6 60 | - name: pip setup 61 | working-directory: drake_pip 62 | run: | 63 | args=() 64 | if [[ '${{ github.event.inputs.linux_noble_wheel }}' != '' ]]; then 65 | args+=(--wheel-url ${{ github.event.inputs.linux_noble_wheel }}) 66 | fi 67 | .github/ubuntu_setup "${args[@]}" 68 | shell: bash 69 | - name: pip build and test 70 | working-directory: drake_pip 71 | run: .github/ci_build_test 72 | shell: bash 73 | -------------------------------------------------------------------------------- /private/drake_cmake_external_static/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | cmake_minimum_required(VERSION 3.22...4.0) 4 | project(drake_cmake_external) 5 | 6 | include(ExternalProject) 7 | 8 | set(CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE) 9 | set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/install" CACHE STRING "" FORCE) 10 | list(APPEND CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}") 11 | set(DRAKE_PREFIX "${PROJECT_BINARY_DIR}/drake-prefix") 12 | 13 | set(DRAKE_COMMIT_HASH "master" CACHE STRING "Commit hash for Drake") 14 | set(DRAKE_COMMIT_SHA256 CACHE STRING "SHA256 hash value for Drake commit archive") 15 | if (NOT "${DRAKE_COMMIT_SHA256}" STREQUAL "") 16 | string(PREPEND DRAKE_COMMIT_SHA256 "SHA256=") 17 | endif() 18 | 19 | ExternalProject_Add(drake 20 | URL https://github.com/RobotLocomotion/drake/archive/${DRAKE_COMMIT_HASH}.tar.gz 21 | URL_HASH ${DRAKE_COMMIT_SHA256} 22 | TLS_VERIFY ON 23 | CMAKE_ARGS 24 | -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} 25 | -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} 26 | -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} 27 | -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 28 | -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} 29 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} 30 | -DPYTHON_EXECUTABLE:FILEPATH=${Python3_EXECUTABLE} 31 | -DWITH_USER_EIGEN:BOOL=OFF 32 | -DWITH_USER_FMT:BOOL=OFF 33 | -DWITH_USER_SPDLOG:BOOL=OFF 34 | # Unlike the drake_cmake_external example, test the static library 35 | # installation and linking here. 36 | -DBUILD_SHARED_LIBS:BOOL=OFF 37 | -DDRAKE_INSTALL_PYTHON:BOOL=OFF 38 | -DWITH_LCM_RUNTIME:BOOL=OFF 39 | PREFIX "${DRAKE_PREFIX}" 40 | BINARY_DIR "${PROJECT_BINARY_DIR}/drake" 41 | BUILD_ALWAYS ON 42 | ) 43 | 44 | ExternalProject_Add(drake_external_examples 45 | DEPENDS drake 46 | SOURCE_DIR "${PROJECT_SOURCE_DIR}/drake_external_examples" 47 | CMAKE_ARGS 48 | -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} 49 | -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} 50 | -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} 51 | -DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS} 52 | -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 53 | -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} 54 | -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS} 55 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} 56 | BINARY_DIR "${PROJECT_BINARY_DIR}/drake_external_examples" 57 | BUILD_ALWAYS ON 58 | INSTALL_COMMAND : 59 | ) 60 | -------------------------------------------------------------------------------- /drake_bazel_external/apps/simple_continuous_time_system.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | // Simple Continuous Time System Example 4 | // 5 | // This is meant to be a sort of "hello world" example for the drake::system 6 | // classes. It defines a very simple continuous time system and simulates it 7 | // from a given initial condition. 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace drake_external_examples { 19 | namespace systems { 20 | 21 | // Simple Continuous Time System 22 | // xdot = -x + x³ 23 | // y = x 24 | class SimpleContinuousTimeSystem : public drake::systems::LeafSystem { 25 | public: 26 | SimpleContinuousTimeSystem() { 27 | DeclareVectorOutputPort("y", drake::systems::BasicVector(1), 28 | &SimpleContinuousTimeSystem::CopyStateOut); 29 | DeclareContinuousState(1); // One state variable. 30 | } 31 | 32 | private: 33 | // xdot = -x + x³ 34 | void DoCalcTimeDerivatives( 35 | const drake::systems::Context& context, 36 | drake::systems::ContinuousState* derivatives) const override { 37 | const double x = context.get_continuous_state()[0]; 38 | const double xdot = -x + std::pow(x, 3.0); 39 | (*derivatives)[0] = xdot; 40 | } 41 | 42 | // y = x 43 | void CopyStateOut(const drake::systems::Context& context, 44 | drake::systems::BasicVector* output) const { 45 | const double x = context.get_continuous_state()[0]; 46 | (*output)[0] = x; 47 | } 48 | }; 49 | 50 | } // namespace systems 51 | } // namespace drake_external_examples 52 | 53 | int main() { 54 | // Create the simple system. 55 | drake_external_examples::systems::SimpleContinuousTimeSystem system; 56 | 57 | // Create the simulator. 58 | drake::systems::Simulator simulator(system); 59 | 60 | // Set the initial conditions x(0). 61 | drake::systems::ContinuousState& state = 62 | simulator.get_mutable_context().get_mutable_continuous_state(); 63 | state[0] = 0.9; 64 | 65 | // Simulate for 10 seconds. 66 | simulator.AdvanceTo(10); 67 | 68 | // Make sure the simulation converges to the stable fixed point at x = 0. 69 | DRAKE_DEMAND(state[0] < 1.0e-4); 70 | 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /drake_cmake_external/drake_external_examples/simple_continuous_time_system.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | // Simple Continuous Time System Example 4 | // 5 | // This is meant to be a sort of "hello world" example for the drake::system 6 | // classes. It defines a very simple continuous time system and simulates it 7 | // from a given initial condition. 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace drake_external_examples { 19 | namespace systems { 20 | 21 | // Simple Continuous Time System 22 | // xdot = -x + x³ 23 | // y = x 24 | class SimpleContinuousTimeSystem : public drake::systems::LeafSystem { 25 | public: 26 | SimpleContinuousTimeSystem() { 27 | DeclareVectorOutputPort("y", drake::systems::BasicVector(1), 28 | &SimpleContinuousTimeSystem::CopyStateOut); 29 | DeclareContinuousState(1); // One state variable. 30 | } 31 | 32 | private: 33 | // xdot = -x + x³ 34 | void DoCalcTimeDerivatives( 35 | const drake::systems::Context& context, 36 | drake::systems::ContinuousState* derivatives) const override { 37 | const double x = context.get_continuous_state()[0]; 38 | const double xdot = -x + std::pow(x, 3.0); 39 | (*derivatives)[0] = xdot; 40 | } 41 | 42 | // y = x 43 | void CopyStateOut(const drake::systems::Context& context, 44 | drake::systems::BasicVector* output) const { 45 | const double x = context.get_continuous_state()[0]; 46 | (*output)[0] = x; 47 | } 48 | }; 49 | 50 | } // namespace systems 51 | } // namespace drake_external_examples 52 | 53 | int main() { 54 | // Create the simple system. 55 | drake_external_examples::systems::SimpleContinuousTimeSystem system; 56 | 57 | // Create the simulator. 58 | drake::systems::Simulator simulator(system); 59 | 60 | // Set the initial conditions x(0). 61 | drake::systems::ContinuousState& state = 62 | simulator.get_mutable_context().get_mutable_continuous_state(); 63 | state[0] = 0.9; 64 | 65 | // Simulate for 10 seconds. 66 | simulator.AdvanceTo(10); 67 | 68 | // Make sure the simulation converges to the stable fixed point at x = 0. 69 | DRAKE_DEMAND(state[0] < 1.0e-4); 70 | 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/simple_continuous_time_system/simple_continuous_time_system.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | // Simple Continuous Time System Example 4 | // 5 | // This is meant to be a sort of "hello world" example for the drake::system 6 | // classes. It defines a very simple continuous time system and simulates it 7 | // from a given initial condition. 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace drake_external_examples { 19 | namespace systems { 20 | 21 | // Simple Continuous Time System 22 | // xdot = -x + x³ 23 | // y = x 24 | class SimpleContinuousTimeSystem : public drake::systems::LeafSystem { 25 | public: 26 | SimpleContinuousTimeSystem() { 27 | DeclareVectorOutputPort("y", drake::systems::BasicVector(1), 28 | &SimpleContinuousTimeSystem::CopyStateOut); 29 | DeclareContinuousState(1); // One state variable. 30 | } 31 | 32 | private: 33 | // xdot = -x + x³ 34 | void DoCalcTimeDerivatives( 35 | const drake::systems::Context& context, 36 | drake::systems::ContinuousState* derivatives) const override { 37 | const double x = context.get_continuous_state()[0]; 38 | const double xdot = -x + std::pow(x, 3.0); 39 | (*derivatives)[0] = xdot; 40 | } 41 | 42 | // y = x 43 | void CopyStateOut(const drake::systems::Context& context, 44 | drake::systems::BasicVector* output) const { 45 | const double x = context.get_continuous_state()[0]; 46 | (*output)[0] = x; 47 | } 48 | }; 49 | 50 | } // namespace systems 51 | } // namespace drake_external_examples 52 | 53 | int main() { 54 | // Create the simple system. 55 | drake_external_examples::systems::SimpleContinuousTimeSystem system; 56 | 57 | // Create the simulator. 58 | drake::systems::Simulator simulator(system); 59 | 60 | // Set the initial conditions x(0). 61 | drake::systems::ContinuousState& state = 62 | simulator.get_mutable_context().get_mutable_continuous_state(); 63 | state[0] = 0.9; 64 | 65 | // Simulate for 10 seconds. 66 | simulator.AdvanceTo(10); 67 | 68 | // Make sure the simulation converges to the stable fixed point at x = 0. 69 | DRAKE_DEMAND(state[0] < 1.0e-4); 70 | 71 | return 0; 72 | } 73 | -------------------------------------------------------------------------------- /drake_bazel_external/.bazelrc: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | # Default to an optimized build. 4 | build --compilation_mode=opt 5 | build --features=prefer_pic_for_opt_binaries 6 | 7 | # Default build options. 8 | build --strip=never 9 | 10 | # Default test options. 11 | build --test_output=errors 12 | build --test_summary=terse 13 | 14 | # Use C++20. 15 | build --cxxopt=-std=c++20 16 | build --host_cxxopt=-std=c++20 17 | 18 | # Suppress warnings from module externals. 19 | build --per_file_copt=external/.*@-w 20 | build --host_per_file_copt=external/.*@-w 21 | 22 | # https://github.com/bazelbuild/bazel/issues/1164 23 | build --action_env=CCACHE_DISABLE=1 24 | 25 | # Use eigen, fmt, spdlog from the host OS via pkg-config, rather than bzlmod. 26 | # It's okay to remove this line if you'd rather use bzlmod. For details, see: 27 | # https://github.com/RobotLocomotion/drake/blob/master/tools/flags/BUILD.bazel 28 | build --@drake//tools/flags:public_repo_default=pkgconfig 29 | 30 | # Pass along the compiler major version to Drake. This doesn't actually set or 31 | # change the compiler used for the build, but tells Drake's CC rules what 32 | # version to expect to tweak compiler- and version-specific flags accordingly. 33 | # In particular, many warnings are suppressed when using gcc-13 (the default 34 | # on Ubuntu 24.04 Noble). Adapt this flag to your system's compiler major 35 | # version as necessary. 36 | # build --@drake//tools/cc_toolchain:compiler_major=13 37 | 38 | # Drake supports the use of proprietary solvers for mathematical programs. 39 | # See https://drake.mit.edu/bazel.html#proprietary-solvers for more info 40 | # and details on how to set them up. 41 | # They can be enabled for the build and tests as shown below. 42 | # Note that setting the --test_env below as 'build' flags is deliberate, 43 | # to keep the analysis cache intact when switching between build and test. 44 | 45 | # Enable Gurobi. 46 | # build --@drake//tools/flags:with_gurobi=True 47 | # Location of the Gurobi license key file, typically named "gurobi.lic". 48 | # build --test_env=GRB_LICENSE_FILE 49 | 50 | # Enable MOSEK. 51 | # build --@drake//tools/flags:with_mosek=True 52 | # Location of the MOSEK license file, typically named "mosek.lic". 53 | # build --test_env=MOSEKLM_LICENSE_FILE 54 | 55 | # Enable SNOPT. 56 | # build --@drake//tools/flags:with_snopt=True 57 | # Location of the SNOPT source archive. 58 | # build --repo_env=SNOPT_PATH 59 | 60 | # TODO(jwnimmer-tri) We should see if we can reuse more of Drake's 61 | # customizations somehow. 62 | 63 | # Try to import user-specific configuration local to workspace. 64 | try-import %workspace%/user.bazelrc 65 | -------------------------------------------------------------------------------- /drake_poetry/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | --- 4 | name: ci 5 | on: 6 | push: 7 | branches: 8 | - main 9 | pull_request: 10 | branches: 11 | - main 12 | schedule: 13 | - cron: '0 12 * * *' 14 | workflow_dispatch: 15 | inputs: 16 | linux_noble_wheel: 17 | description: 'Drake linux-noble-*-wheel-*-release Python 3.12 artifact URL' 18 | required: false 19 | mac_arm_sequoia_wheel: 20 | description: 'Drake mac-arm-sequoia-*-wheel-*-release Python 3.14 artifact URL' 21 | required: false 22 | concurrency: 23 | # Cancel previous CI runs when additional commits are added to a pull request. 24 | # This will not cancel CI runs associated with `schedule` or `push`. 25 | group: ${{ github.head_ref || github.run_id }} 26 | cancel-in-progress: true 27 | jobs: 28 | macos_sequoia_arm_poetry: 29 | name: macos sequoia 15 arm 30 | runs-on: macos-15 31 | env: 32 | PYTHON_VERSION: '3.14' 33 | steps: 34 | - name: checkout 35 | uses: actions/checkout@v6 36 | - name: python setup 37 | uses: actions/setup-python@v6 38 | with: 39 | python-version: ${{ env.PYTHON_VERSION }} 40 | - name: poetry setup 41 | working-directory: drake_poetry 42 | run: | 43 | .github/setup 44 | args=(--python-version $PYTHON_VERSION) 45 | if [[ '${{ github.event.inputs.mac_arm_sequoia_wheel }}' != '' ]]; then 46 | args+=(--wheel-url ${{ github.event.inputs.mac_arm_sequoia_wheel }}) 47 | fi 48 | setup/install_prereqs "${args[@]}" 49 | shell: zsh -efuo pipefail {0} 50 | - name: poetry test 51 | working-directory: drake_poetry 52 | run: .github/ci_build_test 53 | shell: zsh -efuo pipefail {0} 54 | ubuntu_noble_poetry: 55 | name: ubuntu 24.04 noble 56 | runs-on: ubuntu-latest 57 | container: ubuntu:noble 58 | steps: 59 | - name: checkout 60 | uses: actions/checkout@v6 61 | # setup and test must occur in one step 62 | # because when poetry is installed, the update to PATH 63 | # does not persist between steps on GHA 64 | - name: poetry setup and test 65 | working-directory: drake_poetry 66 | run: | 67 | .github/setup 68 | source $HOME/.profile 69 | args=() 70 | if [[ '${{ github.event.inputs.linux_noble_wheel }}' != '' ]]; then 71 | args+=(--wheel-url ${{ github.event.inputs.linux_noble_wheel }}) 72 | fi 73 | setup/install_prereqs "${args[@]}" 74 | .github/ci_build_test 75 | shell: bash 76 | -------------------------------------------------------------------------------- /drake_bazel_external/MODULE.bazel: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | module(name = "drake_external_examples") 4 | 5 | # If you don't want to support building on macOS, you may remove the next line. 6 | # Note that it must appear prior to loading "rules_cc", per the documentation: 7 | # https://github.com/bazelbuild/apple_support?tab=readme-ov-file#bazel-7-setup 8 | bazel_dep(name = "apple_support", version = "2.0.0") 9 | 10 | # Add the Bazel rules we need. 11 | bazel_dep(name = "rules_cc", version = "0.2.16") 12 | bazel_dep(name = "rules_python", version = "1.7.0") 13 | 14 | # Here we introduce Drake as a module dependency, but note that Drake is not 15 | # published to any Bazel registry. Below, we'll override it with a github 16 | # source archive. 17 | bazel_dep(name = "drake") 18 | 19 | # By default, this example always uses the latest Drake master branch. 20 | DRAKE_COMMIT = "master" 21 | DRAKE_CHECKSUM = None 22 | 23 | # You can choose a specific revision of Drake to use, e.g.: 24 | # DRAKE_COMMIT = "19bb4703fdf4950d4b3530d496d8a0ff1ca5fc22" 25 | # DRAKE_CHECKSUM = "489d255db3cb1c8ff7a91ae0f961d76b6083a1d4a3f58150371b4b359683adb6" 26 | # 27 | # You can also use DRAKE_COMMIT to choose a Drake release; e.g.: 28 | # DRAKE_COMMIT = "v0.15.0" 29 | # DRAKE_CHECKSUM = "... TBD ..." 30 | # 31 | # Before changing the COMMIT, temporarily uncomment the next line so that Bazel 32 | # displays the suggested new value for the CHECKSUM. 33 | # DRAKE_CHECKSUM = "0" * 64 34 | 35 | # This declares the `@drake` module as a source code archive from github. 36 | # See README.md for instructions to use a local path, instead. 37 | archive_override( 38 | module_name = "drake", 39 | urls = [x.format(DRAKE_COMMIT) for x in [ 40 | "https://github.com/RobotLocomotion/drake/archive/{}.tar.gz", 41 | ]], 42 | sha256 = DRAKE_CHECKSUM, 43 | strip_prefix = "drake-{}".format(DRAKE_COMMIT.lstrip("v")), 44 | ) 45 | 46 | # Use the host system /usr/bin/python3. 47 | python_repository = use_repo_rule( 48 | "@drake//tools/workspace/python:repository.bzl", 49 | "python_repository", 50 | ) 51 | 52 | python_repository( 53 | name = "python", 54 | linux_interpreter_path = "/usr/bin/python3", 55 | requirements_flavor = "build", 56 | ) 57 | 58 | register_toolchains("@python//:all") 59 | 60 | # If you would like to re-use one of Drake's public dependencies, you can do so 61 | # via the `drake_dep_repositories` module extension. For a list of available 62 | # dependencies, refer to Drake's MODULE.bazel file. 63 | drake_dep_repositories = use_extension( 64 | "@drake//tools/workspace:default.bzl", 65 | "drake_dep_repositories", 66 | ) 67 | use_repo( 68 | drake_dep_repositories, 69 | "eigen", 70 | ) 71 | -------------------------------------------------------------------------------- /drake_bazel_download/setup/install_prereqs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2020, Massachusetts Institute of Technology. 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions are met: 8 | # 9 | # * Redistributions of source code must retain the above copyright notice, this 10 | # list of conditions and the following disclaimer. 11 | # 12 | # * Redistributions in binary form must reproduce the above copyright notice, 13 | # this list of conditions and the following disclaimer in the documentation 14 | # and/or other materials provided with the distribution. 15 | # 16 | # * Neither the name of the copyright holder nor the names of its contributors 17 | # may be used to endorse or promote products derived from this software 18 | # without specific prior written permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | # POSSIBILITY OF SUCH DAMAGE. 31 | 32 | set -euxo pipefail 33 | 34 | package_url= 35 | 36 | while [ "${1:-}" != "" ]; do 37 | case "$1" in 38 | --package-url) 39 | shift 40 | if [[ $# -eq 0 ]]; then 41 | echo 'No argument specified for --package-url' >&2 42 | exit 1 43 | fi 44 | package_url="$1" 45 | ;; 46 | *) 47 | echo 'Invalid command line argument' >&2 48 | exit 1 49 | esac 50 | shift 51 | done 52 | 53 | maybe_sudo= 54 | if [[ "${EUID}" -ne 0 ]]; then 55 | maybe_sudo=sudo 56 | fi 57 | 58 | ${maybe_sudo} apt-get update 59 | ${maybe_sudo} apt-get install --no-install-recommends lsb-release 60 | 61 | if [[ "$(lsb_release -sc)" != 'noble' ]]; then 62 | echo 'This script requires Ubuntu 24.04 (Noble)' >&2 63 | exit 3 64 | fi 65 | 66 | ${maybe_sudo} apt-get install --no-install-recommends $(cat < 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace drake_external_examples { 16 | namespace particles { 17 | namespace { 18 | 19 | /// 20 | /// A test fixture class for Particle systems. 21 | /// 22 | /// @tparam T must be a valid Eigen ScalarType. 23 | /// 24 | template 25 | class ParticleTest : public ::testing::Test { 26 | protected: 27 | /// Arrange a Particle as the Device Under Test. 28 | void SetUp() override { 29 | this->dut_ = std::make_unique>(); 30 | this->context_ = this->dut_->CreateDefaultContext(); 31 | this->output_ = this->dut_->AllocateOutput(); 32 | this->derivatives_ = this->dut_->AllocateTimeDerivatives(); 33 | } 34 | 35 | /// System (aka Device Under Test) being tested. 36 | std::unique_ptr> dut_; 37 | /// Context for the given @p dut_. 38 | std::unique_ptr> context_; 39 | /// Outputs of the given @p dut_. 40 | std::unique_ptr> output_; 41 | /// Derivatives of the given @p dut_. 42 | std::unique_ptr> derivatives_; 43 | }; 44 | 45 | TYPED_TEST_SUITE_P(ParticleTest); 46 | 47 | /// Makes sure a Particle output is consistent with its 48 | /// state (position and velocity). 49 | TYPED_TEST_P(ParticleTest, OutputTest) { 50 | // Initialize state. 51 | drake::systems::VectorBase& continuous_state_vector = 52 | this->context_->get_mutable_continuous_state_vector(); 53 | continuous_state_vector.SetAtIndex( 54 | 0, static_cast(10.0)); // x0 = 10 m. 55 | continuous_state_vector.SetAtIndex( 56 | 1, static_cast(1.0)); // x1 = 1 m/s. 57 | // Compute outputs. 58 | this->dut_->CalcOutput(*this->context_, this->output_.get()); 59 | drake::systems::BasicVector* output_vector = 60 | this->output_->GetMutableVectorData(0); 61 | // Check results. 62 | EXPECT_EQ(output_vector->GetAtIndex(0), 63 | static_cast(10.0)); // y0 == x0 64 | EXPECT_EQ(output_vector->GetAtIndex(1), 65 | static_cast(1.0)); // y1 == x1 66 | } 67 | 68 | /// Makes sure a Particle system state derivatives are 69 | /// consistent with its state and input (velocity and acceleration). 70 | TYPED_TEST_P(ParticleTest, DerivativesTest) { 71 | // Set input. 72 | const drake::systems::InputPort& input_port = 73 | this->dut_->get_input_port(0); 74 | drake::VectorX u0(input_port.size()); 75 | u0 << 1.0; // m/s^2 76 | input_port.FixValue(this->context_.get(), u0); 77 | // Set state. 78 | drake::systems::VectorBase& continuous_state_vector = 79 | this->context_->get_mutable_continuous_state_vector(); 80 | continuous_state_vector.SetAtIndex( 81 | 0, static_cast(0.0)); // x0 = 0 m 82 | continuous_state_vector.SetAtIndex( 83 | 1, static_cast(2.0)); // x1 = 2 m/s 84 | // Compute derivatives. 85 | this->dut_->CalcTimeDerivatives(*this->context_, this->derivatives_.get()); 86 | const drake::systems::VectorBase& derivatives_vector = 87 | this->derivatives_->get_vector(); 88 | // Check results. 89 | EXPECT_EQ(derivatives_vector.GetAtIndex(0), 90 | static_cast(2.0)); // x0dot == x1 91 | EXPECT_EQ(derivatives_vector.GetAtIndex(1), 92 | static_cast(1.0)); // x1dot == u0 93 | } 94 | 95 | REGISTER_TYPED_TEST_SUITE_P(ParticleTest, OutputTest, DerivativesTest); 96 | 97 | INSTANTIATE_TYPED_TEST_SUITE_P(WithDoubles, ParticleTest, double); 98 | 99 | } // namespace 100 | } // namespace particles 101 | } // namespace drake_external_examples 102 | 103 | int main(int argc, char** argv) { 104 | ::testing::InitGoogleTest(&argc, argv); 105 | return RUN_ALL_TESTS(); 106 | } 107 | -------------------------------------------------------------------------------- /drake_cmake_installed/src/particle/particle_test.cc: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT-0 2 | 3 | #include "particle.h" // IWYU pragma: associated 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace drake_external_examples { 16 | namespace particles { 17 | namespace { 18 | 19 | /// 20 | /// A test fixture class for Particle systems. 21 | /// 22 | /// @tparam T must be a valid Eigen ScalarType. 23 | /// 24 | template 25 | class ParticleTest : public ::testing::Test { 26 | protected: 27 | /// Arrange a Particle as the Device Under Test. 28 | void SetUp() override { 29 | this->dut_ = std::make_unique>(); 30 | this->context_ = this->dut_->CreateDefaultContext(); 31 | this->output_ = this->dut_->AllocateOutput(); 32 | this->derivatives_ = this->dut_->AllocateTimeDerivatives(); 33 | } 34 | 35 | /// System (aka Device Under Test) being tested. 36 | std::unique_ptr> dut_; 37 | /// Context for the given @p dut_. 38 | std::unique_ptr> context_; 39 | /// Outputs of the given @p dut_. 40 | std::unique_ptr> output_; 41 | /// Derivatives of the given @p dut_. 42 | std::unique_ptr> derivatives_; 43 | }; 44 | 45 | TYPED_TEST_SUITE_P(ParticleTest); 46 | 47 | /// Makes sure a Particle output is consistent with its 48 | /// state (position and velocity). 49 | TYPED_TEST_P(ParticleTest, OutputTest) { 50 | // Initialize state. 51 | drake::systems::VectorBase& continuous_state_vector = 52 | this->context_->get_mutable_continuous_state_vector(); 53 | continuous_state_vector.SetAtIndex( 54 | 0, static_cast(10.0)); // x0 = 10 m. 55 | continuous_state_vector.SetAtIndex( 56 | 1, static_cast(1.0)); // x1 = 1 m/s. 57 | // Compute outputs. 58 | this->dut_->CalcOutput(*this->context_, this->output_.get()); 59 | drake::systems::BasicVector* output_vector = 60 | this->output_->GetMutableVectorData(0); 61 | // Check results. 62 | EXPECT_EQ(output_vector->GetAtIndex(0), 63 | static_cast(10.0)); // y0 == x0 64 | EXPECT_EQ(output_vector->GetAtIndex(1), 65 | static_cast(1.0)); // y1 == x1 66 | } 67 | 68 | /// Makes sure a Particle system state derivatives are 69 | /// consistent with its state and input (velocity and acceleration). 70 | TYPED_TEST_P(ParticleTest, DerivativesTest) { 71 | // Set input. 72 | const drake::systems::InputPort& input_port = 73 | this->dut_->get_input_port(0); 74 | drake::VectorX u0(input_port.size()); 75 | u0 << 1.0; // m/s^2 76 | input_port.FixValue(this->context_.get(), u0); 77 | // Set state. 78 | drake::systems::VectorBase& continuous_state_vector = 79 | this->context_->get_mutable_continuous_state_vector(); 80 | continuous_state_vector.SetAtIndex( 81 | 0, static_cast(0.0)); // x0 = 0 m 82 | continuous_state_vector.SetAtIndex( 83 | 1, static_cast(2.0)); // x1 = 2 m/s 84 | // Compute derivatives. 85 | this->dut_->CalcTimeDerivatives(*this->context_, this->derivatives_.get()); 86 | const drake::systems::VectorBase& derivatives_vector = 87 | this->derivatives_->get_vector(); 88 | // Check results. 89 | EXPECT_EQ(derivatives_vector.GetAtIndex(0), 90 | static_cast(2.0)); // x0dot == x1 91 | EXPECT_EQ(derivatives_vector.GetAtIndex(1), 92 | static_cast(1.0)); // x1dot == u0 93 | } 94 | 95 | REGISTER_TYPED_TEST_SUITE_P(ParticleTest, OutputTest, DerivativesTest); 96 | 97 | INSTANTIATE_TYPED_TEST_SUITE_P(WithDoubles, ParticleTest, double); 98 | 99 | } // namespace 100 | } // namespace particles 101 | } // namespace drake_external_examples 102 | 103 | int main(int argc, char** argv) { 104 | ::testing::InitGoogleTest(&argc, argv); 105 | return RUN_ALL_TESTS(); 106 | } 107 | -------------------------------------------------------------------------------- /drake_cmake_installed/README.md: -------------------------------------------------------------------------------- 1 | # CMake Project with an Installed Drake 2 | 3 | This uses the CMake `find_package(drake)` 4 | mechanism to find an installed instance of Drake. 5 | 6 | # Instructions 7 | 8 | ## Download and Install Prerequisites 9 | 10 | First, run the `install_prereqs` script to download the 11 | Drake source to `$HOME/drake/`. This also run's Drake's 12 | setup script to install the required packages depending 13 | on your operating system: 14 | 15 | ```bash 16 | setup/install_prereqs 17 | ``` 18 | 19 | See [below](#alternative-versions) for alternative versions of 20 | Drake to download. 21 | 22 | ## Build Everything 23 | 24 | Then run the following to build using CMake from the current directory 25 | (`drake-external-examples/drake_cmake_installed`): 26 | 27 | ```bash 28 | mkdir build && cd build 29 | cmake -DCMAKE_PREFIX_PATH=$HOME/drake .. 30 | make 31 | ``` 32 | 33 | You can also optionally run the tests by calling `make test`. 34 | 35 | ## Alternative Versions 36 | 37 | By default, `install_prereqs` script gets the latest version 38 | of Drake (usually last night's build). Ignore this if that 39 | version is desired. Otherwise, the following are alternative 40 | options for which version of Drake to download. 41 | 42 | To use any of these options, instead of running `install_prereqs`, 43 | run the code for whichever option you prefer below. Each option 44 | downloads Drake to the `$HOME` directory. 45 | 46 | 1. A specific version (date-stamped) 47 | 48 | Replace `noble` (for Ubuntu 24.04) with `jammy` or `mac-arm64` 49 | to download the version needed for your operating system. 50 | 51 | ```bash 52 | curl -O https://drake-packages.csail.mit.edu/drake/nightly/drake-0.0.20250131-noble.tar.gz 53 | tar -xvzf drake-0.0.20250131-noble.tar.gz -C $HOME 54 | $HOME/drake/share/drake/setup/install_prereqs 55 | ``` 56 | 57 | See [Installation via Direct Download](https://drake.mit.edu/from_binary.html) 58 | for more information. 59 | 60 | 2. Manual installation 61 | 62 | ```bash 63 | git clone https://github.com/RobotLocomotion/drake.git 64 | cd drake 65 | setup/install_prereqs 66 | (mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=$HOME/drake .. && make) 67 | ``` 68 | 69 | 3. Manual installation w/ licensed Gurobi 70 | Install & setup gurobi (http://drake.mit.edu/bazel.html?highlight=gurobi#install-on-ubuntu) 71 | 72 | ```bash 73 | git clone https://github.com/RobotLocomotion/drake.git 74 | cd drake 75 | setup/install_prereqs 76 | (mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=$HOME/drake -DWITH_GUROBI=ON .. && make) 77 | ``` 78 | 79 | Finally, for the code in this example, ensure you have `python3-dev` 80 | installed if on Ubuntu: 81 | 82 | ```bash 83 | sudo apt-get update 84 | sudo apt-get --no-install-recommends install python3-dev 85 | ``` 86 | 87 | # Examples 88 | 89 | Drake-specific examples: 90 | 91 | * [Simple Continuous Time System](src/simple_continuous_time_system/README.md) 92 | * [Particle System](src/particle) 93 | * [Find Resources](src/find_resource/README.md) 94 | 95 | # Developer Testing 96 | 97 | If you are a Drake Developer making build or API changes that may affect the 98 | downstream interface, please test this locally on your system. 99 | 100 | These build instructions are adapted from those above, but will use an existing 101 | source tree of Drake (but *not* installing it to `$HOME/drake`), 102 | build this project, and then run all available tests: 103 | 104 | ```bash 105 | # Build development version of Drake, ensuring no old artifacts are present. 106 | cd drake # Where you are developing. 107 | rm -rf build && mkdir build && cd build 108 | cmake .. # Configure Gurobi, Mosek, etc, if needed. 109 | # Build locally. 110 | make 111 | # Record the build's install directory. 112 | drake_install=${PWD}/install 113 | 114 | # Build this project using a development version of Drake. 115 | cd .. 116 | # Clone this repository if you have not already. 117 | git clone https://github.com/RobotLocomotion/drake-external-examples.git 118 | cd drake-external-examples/drake_cmake_installed 119 | # Follow "Install Prerequisites" in the instructions linked above if you 120 | # have not already. 121 | mkdir build && cd build 122 | cmake -DCMAKE_PREFIX_PATH=${drake_install} .. 123 | make 124 | ctest 125 | ``` 126 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/third_party/cmake/3.12/Copyright.txt: -------------------------------------------------------------------------------- 1 | CMake - Cross Platform Makefile Generator 2 | Copyright 2000-2018 Kitware, Inc. and Contributors 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | * Neither the name of Kitware, Inc. nor the names of Contributors 17 | may be used to endorse or promote products derived from this 18 | software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | ------------------------------------------------------------------------------ 33 | 34 | The following individuals and institutions are among the Contributors: 35 | 36 | * Aaron C. Meadows 37 | * Adriaan de Groot 38 | * Aleksey Avdeev 39 | * Alexander Neundorf 40 | * Alexander Smorkalov 41 | * Alexey Sokolov 42 | * Alex Turbov 43 | * Andreas Pakulat 44 | * Andreas Schneider 45 | * André Rigland Brodtkorb 46 | * Axel Huebl, Helmholtz-Zentrum Dresden - Rossendorf 47 | * Benjamin Eikel 48 | * Bjoern Ricks 49 | * Brad Hards 50 | * Christopher Harvey 51 | * Christoph Grüninger 52 | * Clement Creusot 53 | * Daniel Blezek 54 | * Daniel Pfeifer 55 | * Enrico Scholz 56 | * Eran Ifrah 57 | * Esben Mose Hansen, Ange Optimization ApS 58 | * Geoffrey Viola 59 | * Google Inc 60 | * Gregor Jasny 61 | * Helio Chissini de Castro 62 | * Ilya Lavrenov 63 | * Insight Software Consortium 64 | * Jan Woetzel 65 | * Kelly Thompson 66 | * Konstantin Podsvirov 67 | * Mario Bensi 68 | * Mathieu Malaterre 69 | * Matthaeus G. Chajdas 70 | * Matthias Kretz 71 | * Matthias Maennich 72 | * Michael Stürmer 73 | * Miguel A. Figueroa-Villanueva 74 | * Mike Jackson 75 | * Mike McQuaid 76 | * Nicolas Bock 77 | * Nicolas Despres 78 | * Nikita Krupen'ko 79 | * NVIDIA Corporation 80 | * OpenGamma Ltd. 81 | * Patrick Stotko 82 | * Per Øyvind Karlsen 83 | * Peter Collingbourne 84 | * Petr Gotthard 85 | * Philip Lowman 86 | * Philippe Proulx 87 | * Raffi Enficiaud, Max Planck Society 88 | * Raumfeld 89 | * Roger Leigh 90 | * Rolf Eike Beer 91 | * Roman Donchenko 92 | * Roman Kharitonov 93 | * Ruslan Baratov 94 | * Sebastian Holtermann 95 | * Stephen Kelly 96 | * Sylvain Joubert 97 | * Thomas Sondergaard 98 | * Tobias Hunger 99 | * Todd Gamblin 100 | * Tristan Carel 101 | * University of Dundee 102 | * Vadim Zhukov 103 | * Will Dicharry 104 | 105 | See version control history for details of individual contributions. 106 | 107 | The above copyright and license notice applies to distributions of 108 | CMake in source and binary form. Third-party software packages supplied 109 | with CMake under compatible licenses provide their own copyright notices 110 | documented in corresponding subdirectories or source files. 111 | 112 | ------------------------------------------------------------------------------ 113 | 114 | CMake was initially developed by Kitware with the following sponsorship: 115 | 116 | * National Library of Medicine at the National Institutes of Health 117 | as part of the Insight Segmentation and Registration Toolkit (ITK). 118 | 119 | * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel 120 | Visualization Initiative. 121 | 122 | * National Alliance for Medical Image Computing (NAMIC) is funded by the 123 | National Institutes of Health through the NIH Roadmap for Medical Research, 124 | Grant U54 EB005149. 125 | 126 | * Kitware, Inc. 127 | -------------------------------------------------------------------------------- /drake_cmake_installed_apt/third_party/cmake/3.12/Modules/FindPython.cmake: -------------------------------------------------------------------------------- 1 | # Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 | # file Copyright.txt or https://cmake.org/licensing for details. 3 | 4 | #[=======================================================================[.rst: 5 | FindPython 6 | ---------- 7 | 8 | Find Python interpreter, compiler and development environment (include 9 | directories and libraries). 10 | 11 | Three components are supported: 12 | 13 | * ``Interpreter``: search for Python interpreter. 14 | * ``Compiler``: search for Python compiler. Only offered by IronPython. 15 | * ``Development``: search for development artifacts (include directories and 16 | libraries). 17 | 18 | If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed. 19 | 20 | To ensure consistent versions between components ``Interpreter``, ``Compiler`` 21 | and ``Development``, specify all components at the same time:: 22 | 23 | find_package (Python COMPONENTS Interpreter Development) 24 | 25 | This module looks preferably for version 3 of Python. If not found, version 2 26 | is searched. 27 | To manage concurrent versions 3 and 2 of Python, use :module:`FindPython3` and 28 | :module:`FindPython2` modules rather than this one. 29 | 30 | Imported Targets 31 | ^^^^^^^^^^^^^^^^ 32 | 33 | This module defines the following :ref:`Imported Targets `: 34 | 35 | ``Python::Interpreter`` 36 | Python interpreter. Target defined if component ``Interpreter`` is found. 37 | ``Python::Compiler`` 38 | Python compiler. Target defined if component ``Compiler`` is found. 39 | ``Python::Python`` 40 | Python library. Target defined if component ``Development`` is found. 41 | 42 | Result Variables 43 | ^^^^^^^^^^^^^^^^ 44 | 45 | This module will set the following variables in your project 46 | (see :ref:`Standard Variable Names `): 47 | 48 | ``Python_FOUND`` 49 | System has the Python requested components. 50 | ``Python_Interpreter_FOUND`` 51 | System has the Python interpreter. 52 | ``Python_EXECUTABLE`` 53 | Path to the Python interpreter. 54 | ``Python_INTERPRETER_ID`` 55 | A short string unique to the interpreter. Possible values include: 56 | * Python 57 | * ActivePython 58 | * Anaconda 59 | * Canopy 60 | * IronPython 61 | ``Python_STDLIB`` 62 | Standard platform independent installation directory. 63 | 64 | Information returned by 65 | ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``. 66 | ``Python_STDARCH`` 67 | Standard platform dependent installation directory. 68 | 69 | Information returned by 70 | ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``. 71 | ``Python_SITELIB`` 72 | Third-party platform independent installation directory. 73 | 74 | Information returned by 75 | ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``. 76 | ``Python_SITEARCH`` 77 | Third-party platform dependent installation directory. 78 | 79 | Information returned by 80 | ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``. 81 | ``Python_Compiler_FOUND`` 82 | System has the Python compiler. 83 | ``Python_COMPILER`` 84 | Path to the Python compiler. Only offered by IronPython. 85 | ``Python_COMPILER_ID`` 86 | A short string unique to the compiler. Possible values include: 87 | * IronPython 88 | ``Python_Development_FOUND`` 89 | System has the Python development artifacts. 90 | ``Python_INCLUDE_DIRS`` 91 | The Python include directories. 92 | ``Python_LIBRARIES`` 93 | The Python libraries. 94 | ``Python_LIBRARY_DIRS`` 95 | The Python library directories. 96 | ``Python_RUNTIME_LIBRARY_DIRS`` 97 | The Python runtime library directories. 98 | ``Python_VERSION`` 99 | Python version. 100 | ``Python_VERSION_MAJOR`` 101 | Python major version. 102 | ``Python_VERSION_MINOR`` 103 | Python minor version. 104 | ``Python_VERSION_PATCH`` 105 | Python patch version. 106 | 107 | Hints 108 | ^^^^^ 109 | 110 | ``Python_ROOT_DIR`` 111 | Define the root directory of a Python installation. 112 | 113 | ``Python_USE_STATIC_LIBS`` 114 | * If not defined, search for shared libraries and static libraries in that 115 | order. 116 | * If set to TRUE, search **only** for static libraries. 117 | * If set to FALSE, search **only** for shared libraries. 118 | 119 | Commands 120 | ^^^^^^^^ 121 | 122 | This module defines the command ``Python_add_library`` which have the same 123 | semantic as :command:`add_library` but take care of Python module naming rules 124 | (only applied if library is of type ``MODULE``) and add dependency to target 125 | ``Python::Python``:: 126 | 127 | Python_add_library (my_module MODULE src1.cpp) 128 | 129 | If library type is not specified, ``MODULE`` is assumed. 130 | #]=======================================================================] 131 | 132 | 133 | set (_PYTHON_PREFIX Python) 134 | 135 | if (DEFINED Python_FIND_VERSION) 136 | set (_Python_REQUIRED_VERSION_MAJOR ${Python_FIND_VERSION_MAJOR}) 137 | 138 | include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake) 139 | else() 140 | # iterate over versions in quiet and NOT required modes to avoid multiple 141 | # "Found" messages and prematurally failure. 142 | set (_Python_QUIETLY ${Python_FIND_QUIETLY}) 143 | set (_Python_REQUIRED ${Python_FIND_REQUIRED}) 144 | set (Python_FIND_QUIETLY TRUE) 145 | set (Python_FIND_REQUIRED FALSE) 146 | 147 | set (_Python_REQUIRED_VERSIONS 3 2) 148 | set (_Python_REQUIRED_VERSION_LAST 2) 149 | 150 | foreach (_Python_REQUIRED_VERSION_MAJOR IN LISTS _Python_REQUIRED_VERSIONS) 151 | set (Python_FIND_VERSION ${_Python_REQUIRED_VERSION_MAJOR}) 152 | include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake) 153 | if (Python_FOUND OR 154 | _Python_REQUIRED_VERSION_MAJOR EQUAL _Python_REQUIRED_VERSION_LAST) 155 | break() 156 | endif() 157 | # clean-up some CACHE variables to ensure look-up restart from scratch 158 | foreach (_Python_ITEM IN LISTS _Python_CACHED_VARS) 159 | unset (${_Python_ITEM} CACHE) 160 | endforeach() 161 | endforeach() 162 | 163 | unset (Python_FIND_VERSION) 164 | 165 | set (Python_FIND_QUIETLY ${_Python_QUIETLY}) 166 | set (Python_FIND_REQUIRED ${_Python_REQUIRED}) 167 | if (Python_FIND_REQUIRED OR NOT Python_FIND_QUIETLY) 168 | # call again validation command to get "Found" or error message 169 | find_package_handle_standard_args (Python HANDLE_COMPONENTS 170 | REQUIRED_VARS ${_Python_REQUIRED_VARS} 171 | VERSION_VAR Python_VERSION) 172 | endif() 173 | endif() 174 | 175 | if (COMMAND __Python_add_library) 176 | macro (Python_add_library) 177 | __Python_add_library (Python ${ARGV}) 178 | endmacro() 179 | endif() 180 | 181 | unset (_PYTHON_PREFIX) 182 | -------------------------------------------------------------------------------- /drake_cmake_external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-License-Identifier: MIT-0 2 | 3 | # TODO(eric.cousineau): Link to documentation on superproject example pending 4 | # resolution of: https://gitlab.kitware.com/cmake/cmake/issues/18336 5 | 6 | # See https://drake.mit.edu/from_source.html for the versions of CMake 7 | # officially supported by Drake when building from source. 8 | cmake_minimum_required(VERSION 3.22...4.0) 9 | project(drake_cmake_external) 10 | 11 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 12 | set(CMAKE_BUILD_TYPE Release CACHE STRING 13 | "Choose the type of build, options are None Debug Release RelWithDebInfo MinSizeRel" 14 | FORCE 15 | ) 16 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY 17 | STRINGS None Debug Release RelWithDebInfo MinSizeRel 18 | ) 19 | endif() 20 | 21 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 22 | set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/install" CACHE STRING 23 | "Install path prefix, prepended onto install directories" FORCE 24 | ) 25 | endif() 26 | 27 | list(APPEND CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}") 28 | 29 | include(ExternalProject) 30 | 31 | # This shows how to fetch Eigen from source as part of Drake's CMake build. 32 | # If you'd rather just use your operating system's Eigen, then this stanza could 33 | # be removed (as well as removing -DWITH_USER_EIGEN:BOOL=ON, below). 34 | ExternalProject_Add(eigen 35 | URL https://gitlab.com/libeigen/eigen/-/archive/5.0.1/eigen-5.0.1.tar.gz 36 | URL_HASH SHA256=e9c326dc8c05cd1e044c71f30f1b2e34a6161a3b6ecf445d56b53ff1669e3dec 37 | TLS_VERIFY ON 38 | CMAKE_ARGS 39 | -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} 40 | -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} 41 | -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} 42 | -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 43 | -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} 44 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} 45 | # Eigen's default option is to build vendored dependencies and other 46 | # development tools (tests, documentation, etc.) when building from source 47 | # via `ExternalProject_Add`. Since these tools aren't needed for this 48 | # example, we'll disable them explicitly. 49 | -DEIGEN_BUILD_BLAS:BOOL=OFF 50 | -DEIGEN_BUILD_LAPACK:BOOL=OFF 51 | -DEIGEN_BUILD_TESTING:BOOL=OFF 52 | -DEIGEN_BUILD_DOC:BOOL=OFF 53 | -DEIGEN_BUILD_DEMOS:BOOL=OFF 54 | BUILD_ALWAYS ON 55 | ) 56 | 57 | # This shows how to rebuild fmt from source as part of Drake's CMake build. 58 | # If you'd rather just use your operating system's fmt, then this stanza could 59 | # be removed (as well as removing -DWITH_USER_FMT:BOOL=ON, below). 60 | # If you rebuild fmt from source, then you must also rebuild spdlog from source. 61 | ExternalProject_Add(fmt 62 | URL https://github.com/fmtlib/fmt/archive/refs/tags/12.1.0.tar.gz 63 | URL_HASH SHA256=ea7de4299689e12b6dddd392f9896f08fb0777ac7168897a244a6d6085043fea 64 | TLS_VERIFY ON 65 | CMAKE_ARGS 66 | -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} 67 | -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} 68 | -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} 69 | -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 70 | -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} 71 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} 72 | -DBUILD_SHARED_LIBS=ON 73 | -DCMAKE_CXX_FLAGS:STRING=-fPIC 74 | -DFMT_INC_DIR:PATH=include/fmt 75 | -DFMT_TEST=OFF 76 | BUILD_ALWAYS ON 77 | ) 78 | 79 | # This shows how to rebuild spdlog from source as part of Drake's CMake build. 80 | # If you'd rather just use your operating system's fmt, then this stanza could 81 | # be removed (as well as removing -DWITH_USER_SPDLOG:BOOL=ON, below). 82 | # If you rebuild spdlog from source, then you must also rebuild fmt from source. 83 | ExternalProject_Add(spdlog 84 | DEPENDS fmt 85 | URL https://github.com/gabime/spdlog/archive/refs/tags/v1.16.0.tar.gz 86 | URL_HASH SHA256=8741753e488a78dd0d0024c980e1fb5b5c85888447e309d9cb9d949bdb52aa3e 87 | TLS_VERIFY ON 88 | CMAKE_ARGS 89 | -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} 90 | -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} 91 | -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} 92 | -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 93 | -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} 94 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} 95 | -DSPDLOG_BUILD_SHARED=ON 96 | -DCMAKE_CXX_FLAGS:STRING=-fPIC 97 | -DSPDLOG_FMT_EXTERNAL:BOOL=ON 98 | -Dfmt_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/fmt 99 | ) 100 | 101 | # This is the external project PREFIX (not to be confused with the install 102 | # prefix) which will contain, among other things, the checkout of Drake's 103 | # source. This should match the default value, but for paranoia's sake, we'll 104 | # also pass this explicitly to ExternalProject_Add. 105 | set(DRAKE_PREFIX "${PROJECT_BINARY_DIR}/drake-prefix") 106 | 107 | # Options to override Drake's latest source on master with a specific commit. 108 | # See README.md for details. 109 | set(DRAKE_COMMIT_HASH "master" CACHE STRING "Commit hash for Drake") 110 | set(DRAKE_COMMIT_SHA256 CACHE STRING "SHA256 hash value for Drake commit archive") 111 | 112 | if (NOT "${DRAKE_COMMIT_SHA256}" STREQUAL "") 113 | string(PREPEND DRAKE_COMMIT_SHA256 "SHA256=") 114 | endif() 115 | 116 | ExternalProject_Add(drake 117 | DEPENDS eigen fmt spdlog 118 | URL https://github.com/RobotLocomotion/drake/archive/${DRAKE_COMMIT_HASH}.tar.gz 119 | URL_HASH ${DRAKE_COMMIT_SHA256} 120 | TLS_VERIFY ON 121 | CMAKE_ARGS 122 | -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} 123 | -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} 124 | -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} 125 | -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 126 | -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} 127 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} 128 | -DPYTHON_EXECUTABLE:FILEPATH=${Python3_EXECUTABLE} 129 | -DWITH_USER_EIGEN:BOOL=ON 130 | -DWITH_USER_FMT:BOOL=ON 131 | -DWITH_USER_SPDLOG:BOOL=ON 132 | # The Drake build has options to turn features on/off. For the full list, 133 | # see https://drake.mit.edu/from_source.html. Here, we demonstrate how to 134 | # set an arbitrary option for one of the open-source dependencies. 135 | -DWITH_CSDP:BOOL=OFF 136 | # The Drake build also supports installing a static drake::drake library, 137 | # instead of shared (the default). This is incompatible with certain other 138 | # options, and as a result, changes their default values; see 139 | # https://drake.mit.edu/from_source.html for the full details. To enable 140 | # this option, and disable incompatible installation options, uncomment the 141 | # following line. 142 | # -DBUILD_SHARED_LIBS:BOOL=OFF 143 | PREFIX "${DRAKE_PREFIX}" 144 | BINARY_DIR "${PROJECT_BINARY_DIR}/drake" 145 | BUILD_ALWAYS ON 146 | ) 147 | 148 | ExternalProject_Add(drake_external_examples 149 | DEPENDS drake 150 | SOURCE_DIR "${PROJECT_SOURCE_DIR}/drake_external_examples" 151 | CMAKE_ARGS 152 | -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} 153 | -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} 154 | -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS} 155 | -DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS} 156 | -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 157 | -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH} 158 | -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS} 159 | -DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE} 160 | BINARY_DIR "${PROJECT_BINARY_DIR}/drake_external_examples" 161 | BUILD_ALWAYS ON 162 | INSTALL_COMMAND : 163 | ) 164 | -------------------------------------------------------------------------------- /private/test/file_sync_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # SPDX-License-Identifier: MIT-0 3 | 4 | """This regression test checks that files which are supposed to be copies of 5 | each other are actually so. 6 | """ 7 | 8 | from io import StringIO 9 | from itertools import chain 10 | import logging 11 | import os 12 | import re 13 | import sys 14 | from pathlib import Path 15 | import ruamel.yaml 16 | 17 | COPIES = ( 18 | ( 19 | "drake_bazel_download/.clang-format", 20 | "drake_bazel_external/.clang-format", 21 | "drake_cmake_external/.clang-format", 22 | "drake_cmake_installed/.clang-format", 23 | "drake_cmake_installed_apt/.clang-format", 24 | ), 25 | ( 26 | "drake_bazel_download/.github/ubuntu_setup", 27 | "drake_cmake_installed/.github/ubuntu_setup", 28 | ), 29 | ( 30 | "drake_bazel_download/CPPLINT.cfg", 31 | "drake_bazel_external/CPPLINT.cfg", 32 | "drake_cmake_external/CPPLINT.cfg", 33 | "drake_cmake_installed/CPPLINT.cfg", 34 | "drake_cmake_installed_apt/CPPLINT.cfg", 35 | ), 36 | ( 37 | "LICENSE", 38 | "drake_bazel_download/LICENSE", 39 | "drake_bazel_external/LICENSE", 40 | "drake_cmake_external/LICENSE", 41 | "drake_cmake_installed/LICENSE", 42 | "drake_cmake_installed_apt/LICENSE", 43 | "drake_pip/LICENSE", 44 | "drake_poetry/LICENSE", 45 | ), 46 | ( 47 | "drake_bazel_external/.github/ubuntu_setup", 48 | "drake_cmake_external/.github/ubuntu_setup", 49 | ), 50 | ( 51 | "drake_bazel_download/.bazelversion", 52 | "drake_bazel_external/.bazelversion", 53 | ), 54 | ) + tuple([ 55 | ( 56 | f"drake_cmake_installed/src/particle/{path}", 57 | f"drake_cmake_installed_apt/src/{path}", 58 | ) 59 | for path in [ 60 | "CMakeLists.txt", 61 | "particle.cc", 62 | "particle.h", 63 | "particle_test.cc", 64 | ] 65 | ]) + tuple([ 66 | ( 67 | f"drake_cmake_installed/src/particle/{path}", 68 | f"drake_cmake_installed_apt/src/{path}", 69 | f"drake_pip/src/{path}", 70 | f"drake_poetry/src/{path}", 71 | ) 72 | for path in [ 73 | "particle.py", 74 | "particle_test.py", 75 | ] 76 | ]) 77 | 78 | GITHUB_WORKFLOWS = ( 79 | "bazel_download", 80 | "cmake_installed", 81 | "cmake_installed_apt", 82 | "pip", 83 | "poetry" 84 | ) 85 | 86 | GITHUB_WORKFLOW_OPTS = { 87 | "bazel_download": ( 88 | "linux_noble_package_tar", 89 | ), 90 | "cmake_installed": ( 91 | "linux_noble_package_tar", 92 | "mac_arm_sequoia_package_tar" 93 | ), 94 | "cmake_installed_apt": ( 95 | "linux_noble_package_deb", 96 | ), 97 | "pip": ( 98 | "linux_noble_wheel", 99 | "mac_arm_sequoia_wheel" 100 | ), 101 | "poetry": ( 102 | "linux_noble_wheel", 103 | "mac_arm_sequoia_wheel" 104 | ) 105 | } 106 | 107 | found_errors = False 108 | 109 | 110 | def _ordinalize(number: int) -> str: 111 | if (number % 100) // 10 == 1: 112 | return f"{number}th" 113 | 114 | SUFFIXES = {1: "st", 2: "nd", 3: "rd"} 115 | return f"{number}{SUFFIXES.get(number % 10, 'th')}" 116 | 117 | 118 | def error(message: str): 119 | logging.error(message) 120 | global found_errors 121 | found_errors = True 122 | 123 | 124 | def check(index: int, paths: tuple[str]): 125 | # For readability, enforce that the lists are sorted. 126 | first_name = Path(paths[0]).name 127 | prologue = (f"The {_ordinalize(index + 1)} list of files" 128 | f" (containing {first_name})") 129 | if list(paths) != sorted(paths): 130 | error(f"{prologue} is not alpha-sorted; fix the file_sync_test code.") 131 | 132 | # Read all of the files into memory. 133 | content = {} 134 | for path in paths: 135 | try: 136 | with open(path, "rb") as f: 137 | content[path] = f.read() 138 | except IOError: 139 | error(f"{prologue} refers to a missing file {path}") 140 | paths = list(content.keys()) 141 | 142 | # Check for matching. 143 | all_match = all( 144 | content[a] == content[b] 145 | for a, b in zip(paths, paths[1:]) 146 | ) 147 | if not all_match: 148 | error(f"{prologue} do not all match") 149 | 150 | def gha_workflow_check(workflow_name: str): 151 | """Enforces the following contents of root_ci and subdir_ci: 152 | 1. subdir_ci and root_ci match until 'workflow_dispatch:' 153 | 2. root_ci and subdir_ workflow match from 'workflow_dispatch:' until 'concurrency:', 154 | for only the options corresponding to the given workflow 155 | 3. subdir_ci and root_ci match from 'concurrency:' until 'jobs:' 156 | 4. subdir_ci and subdir_ workflow match after 'jobs:' 157 | """ 158 | root_ci_path = ".github/workflows/ci.yml" 159 | subdir_workflow_path = f".github/workflows/{workflow_name}.yml" 160 | subdir_ci_path = f"drake_{workflow_name}/.github/workflows/ci.yml" 161 | paths = [ root_ci_path, subdir_workflow_path, subdir_ci_path ] 162 | seps = { 163 | "dispatch": "\n workflow_dispatch:\n inputs:\n", 164 | "conc": "\nconcurrency:\n", 165 | "jobs": "\njobs:\n" 166 | } 167 | 168 | # Read all files into memory. 169 | content = {} 170 | for path in paths: 171 | try: 172 | with open(path, "r", encoding="utf-8") as f: 173 | content[path] = f.read() 174 | except IOError: 175 | error(f"Missing {workflow_name} file {path}") 176 | exit(1) 177 | 178 | # Check that seps occur once in each file. 179 | def check_sep(paths, sep): 180 | for path in paths: 181 | if len(re.findall(sep, content[path])) != 1: 182 | error(f"{workflow_name}'s {path} contents are invalid: does not include {sep}") 183 | exit(1) 184 | check_sep([root_ci_path, subdir_ci_path], seps["dispatch"]) 185 | check_sep([root_ci_path, subdir_ci_path], seps["conc"]) 186 | check_sep(paths, seps["jobs"]) 187 | 188 | # Workflow check. See above for steps. 189 | root_events = content[root_ci_path].split(seps["dispatch"])[0] 190 | subdir_events = content[subdir_ci_path].split(seps["dispatch"])[0] 191 | if root_events != subdir_events: 192 | error(f"{workflow_name} subdir CI events do not match") 193 | 194 | root_dispatch = content[root_ci_path].split(seps["dispatch"])[1].split(seps["conc"])[0] 195 | subdir_dispatch = content[subdir_ci_path].split(seps["dispatch"])[1].split(seps["conc"])[0] 196 | subdir_dispatch = re.sub(r"[^\S\r\n]{6}", "", subdir_dispatch) # Remove leading indentation. 197 | 198 | # Check that the root workflow defines no extra options 199 | # beyond what is configured here. 200 | all_dispatch_options = set(chain(*GITHUB_WORKFLOW_OPTS.values())) 201 | root_dispatch_options = set([line.lstrip().rstrip(':') for line in root_dispatch.splitlines() if len(line) - len(line.lstrip()) == 6]) 202 | if root_dispatch_options != all_dispatch_options: 203 | error(f"Root CI workflow_dispatch does not define the expected options. Please add them to the file_sync_test.") 204 | exit(1) 205 | 206 | # Load root workflow as yaml, delete the unused options, and check 207 | # dumped string for equality to subdir workflow. 208 | yaml = ruamel.yaml.YAML() 209 | yaml.preserve_quotes = True # Enforce use of '' for quoted strings. 210 | root_dispatch_yaml = yaml.load(root_dispatch) 211 | unused_options = set.difference(all_dispatch_options, GITHUB_WORKFLOW_OPTS[workflow_name]) 212 | for unused in unused_options: 213 | del root_dispatch_yaml[unused] 214 | with StringIO() as string_stream: 215 | yaml.dump(root_dispatch_yaml, string_stream) 216 | root_dispatch_parsed = string_stream.getvalue().rstrip('\n') 217 | if root_dispatch_parsed != subdir_dispatch: 218 | error(f"{workflow_name} subdir CI workflow_dispatch does not match") 219 | 220 | root_conc = content[root_ci_path].split(seps["conc"])[1].split(seps["jobs"])[0] 221 | subdir_conc = content[subdir_ci_path].split(seps["conc"])[1].split(seps["jobs"])[0] 222 | if root_conc != subdir_conc: 223 | error(f"{workflow_name} subdir CI concurrency does not match") 224 | 225 | subdir_jobs = content[subdir_ci_path].split(seps["jobs"])[1] 226 | subdir_workflow_jobs = content[subdir_workflow_path].split(seps["jobs"])[1] 227 | if subdir_jobs != subdir_workflow_jobs: 228 | error(f"{workflow_name} subdir CI jobs do not match") 229 | 230 | 231 | def main(): 232 | logging.basicConfig(format="%(levelname)s: %(message)s") 233 | os.chdir(Path(__file__).parent.parent.parent) 234 | for i, paths in enumerate(COPIES): 235 | check(i, paths) 236 | for workflow in GITHUB_WORKFLOWS: 237 | gha_workflow_check(workflow) 238 | sys.exit(1 if found_errors else 0) 239 | 240 | 241 | if __name__ == "__main__": 242 | main() 243 | --------------------------------------------------------------------------------