{"id":9704,"library":"drake","title":"Drake","description":"Drake is an open-source C++ toolbox with extensive Python bindings for robot design, simulation, and analysis, emphasizing model-based design and formal verification. It provides tools for dynamics, control, planning, and visualization. As of version 1.52.0, Drake maintains a monthly release cycle, offering continuous improvements and new features.","status":"active","version":"1.52.0","language":"en","source_language":"en","source_url":"https://github.com/RobotLocomotion/drake","tags":["robotics","simulation","control","optimization","dynamics"],"install":[{"cmd":"pip install drake","lang":"bash","label":"Install Python bindings"}],"dependencies":[],"imports":[{"symbol":"DiagramBuilder","correct":"from pydrake.systems.framework import DiagramBuilder"},{"symbol":"Simulator","correct":"from pydrake.systems.framework import Simulator"},{"symbol":"MultibodyPlant","correct":"from pydrake.multibody.plant import MultibodyPlant"},{"symbol":"SceneGraph","correct":"from pydrake.geometry import SceneGraph"},{"symbol":"AcrobotPlant","correct":"from pydrake.examples.acrobot import AcrobotPlant"},{"symbol":"LogVectorOutput","correct":"from pydrake.systems.primitives import LogVectorOutput"},{"note":"Python bindings are under the 'pydrake' namespace, not 'drake'.","wrong":"import drake","symbol":"all","correct":"from pydrake.all import *"}],"quickstart":{"code":"import numpy as np\nfrom pydrake.systems.framework import DiagramBuilder, Simulator\nfrom pydrake.examples.acrobot import AcrobotPlant\nfrom pydrake.systems.primitives import LogVectorOutput\n\n# Create a DiagramBuilder\nbuilder = DiagramBuilder()\n\n# Add the Acrobot plant (a classic underactuated system)\nacrobot = builder.AddSystem(AcrobotPlant())\n\n# Add a logger to record the state of the Acrobot\nlogger = LogVectorOutput(acrobot.get_output_port(0), builder)\n\n# Build the diagram, connecting the components\ndiagram = builder.Build()\n\n# Create a simulator for the diagram\nsimulator = Simulator(diagram)\ncontext = simulator.get_mutable_context()\n\n# Set initial state: (theta1, theta2, theta1_dot, theta2_dot)\n# e.g., inverted upright with a small perturbation\ncontext.SetContinuousState([np.pi/2, 0.1, 0.0, 0.0])\n\n# Simulate for 2 seconds\nsimulator.AdvanceTo(2.0)\n\n# Retrieve and print some logged data (optional verification)\nlog = logger.FindLog(context)\ntime = log.sample_times()\npositions = log.data()[:2, :]\nvelocities = log.data()[2:, :]\n\nprint(f\"Simulation finished. Logged {len(time)} time steps.\")\nprint(f\"Initial positions: {positions[:, 0]}, Final positions: {positions[:, -1]}\")","lang":"python","description":"This quickstart demonstrates a basic simulation of an Acrobot (a two-link pendulum) using Drake's `DiagramBuilder` and `Simulator`. It sets up the system, defines an initial state, simulates its dynamics, and logs the output."},"warnings":[{"fix":"Upgrade your Python environment to 3.12 or newer. Consider using `pyenv` or `conda` for isolated environment management.","message":"Drake 1.52.0 and newer officially requires Python >= 3.12. Users on older Python versions will encounter installation errors or runtime issues.","severity":"breaking","affected_versions":">= 1.52.0"},{"fix":"For full functionality, including visualizers and C++ development, install Drake via pre-compiled binaries (recommended) or build from source as described on `drake.mit.edu/installation.html`.","message":"The `pip install drake` package provides only a subset of Drake's functionality (Python bindings and core C++ libraries). It explicitly *does not* include visualization tools (like `drake-visualizer` or `meshcat-server`), C++ headers, or command-line utilities.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the release notes (drake.mit.edu/release_notes.html) for your specific version. When upgrading, regularly review code against the latest API documentation.","message":"Drake's API undergoes frequent changes, especially between monthly releases, due to active development. Code written for older versions (e.g., a few months old) may encounter `AttributeError` or `TypeError` due to renamed classes, modified function signatures, or deprecated methods.","severity":"breaking","affected_versions":"All versions"},{"fix":"Refer to the Drake documentation on 'Solvers' (drake.mit.edu/solvers.html) for installation and configuration instructions specific to the solvers you intend to use.","message":"Many advanced Drake functionalities, particularly those involving mathematical programming and optimization (e.g., `MathematicalProgram`, `DirectCollocation`), require specific third-party solvers (e.g., Mosek, Gurobi, SNOPT, IPOPT). These solvers often need to be installed and configured separately, as they are not bundled with Drake or `pip install`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure `drake` is installed in your active environment: `pip install drake`. If using a virtual environment, activate it first.","cause":"The `drake` package or its Python bindings (`pydrake`) are not installed or not accessible in the current Python environment.","error":"ModuleNotFoundError: No module named 'pydrake'"},{"fix":"If using a system-level installation, ensure your shell environment variables are correctly configured to point to Drake's `lib` directory (e.g., by sourcing the setup script). If using `pip install drake`, this error is less common but may indicate a corrupted installation or a missing system dependency.","cause":"The operating system cannot locate Drake's shared C++ libraries at runtime. This often happens if Drake was installed in a non-standard location, or environment variables like `LD_LIBRARY_PATH` (Linux) / `DYLD_LIBRARY_PATH` (macOS) are not correctly set.","error":"ImportError: libdrake.so: cannot open shared object file: No such file or directory"},{"fix":"Install and configure a compatible solver (e.g., IPOPT, SNOPT, Mosek, Gurobi) according to the Drake documentation (drake.mit.edu/solvers.html). This often involves a system-level installation or specific build flags for Drake.","cause":"Your Drake installation does not have access to any configured mathematical programming solvers required by the optimization problem you are trying to solve. `pip install drake` does not include proprietary solvers.","error":"RuntimeError: There are no solvers available for the specified mathematical program. You must build/install at least one supported solver."},{"fix":"Replace `builder.AddLeafSystem(...)` with `builder.AddSystem(...)`.","cause":"You are attempting to use an outdated method `AddLeafSystem` on `DiagramBuilder`. The correct method for adding a system to the builder is `AddSystem`.","error":"AttributeError: 'DiagramBuilder' object has no attribute 'AddLeafSystem'"},{"fix":"The `pip install drake` package does *not* include C++ tools like `drake-visualizer`. To use such tools, you must install Drake via its pre-compiled binaries or build from source, then ensure your environment variables are correctly sourced to make the installation discoverable.","cause":"You are attempting to use a C++ utility (like `drake-visualizer` or `meshcat-server`) that is not included with `pip install drake`, or your system-level Drake installation path is not discoverable.","error":"RuntimeError: Failed to find Drake installation at conventional locations..."}]}