Skip to main content
Article
roboticspythonsdksimulationboston-dynamicsagent-controllocomotion

Develop for Boston Dynamics Robots Using the SDK

While direct access to Boston Dynamics Atlas is unavailable, you can start developing for their ecosystem. This guide uses the official Boston Dynamics SDK (for Spot) and a simulator to write and test robot control logic, preparing you for future humanoid platforms.

intermediate1 hour5 steps
The play
  1. Understand the Developer Ecosystem
    Directly programming a Boston Dynamics Atlas is reserved for partners. However, the public Boston Dynamics SDK, created for the Spot robot, is the official entry point for developers. Mastering this SDK is the first step toward working with their advanced robotic platforms, as the core principles of authentication, leasing, and commanding are shared.
  2. Install the SDK and Examples
    The SDK is available as a Python package. Install it using pip. We also recommend cloning the examples repository, which contains helpful starter scripts for common tasks.
  3. Configure for the Simulator
    Since most users don't have a physical robot, you'll connect to a simulator (e.g., a virtual machine or Docker container provided by Boston Dynamics). Set environment variables for the simulator's address and credentials. For this example, we'll use placeholder values.
  4. Run a 'Hello, Spot' Example
    Navigate to the cloned SDK examples directory and run the `hello_spot.py` script. This script connects to the robot, obtains a lease, powers it on, makes it stand up, and then powers it off. It's the 'hello world' of robot control and verifies your setup.
  5. Send a Basic Mobility Command
    Use the RobotCommandBuilder to issue specific poses. The code below commands the robot to stand with its body level (zero roll, pitch, and yaw). This is the fundamental building block for more complex locomotion tasks relevant to Boston Dynamics Atlas.
Starter code
import sys
import time
import os
import bosdyn.client
import bosdyn.client.util
from bosdyn.client.robot_state import RobotStateClient
from bosdyn.client.robot_command import RobotCommandClient, RobotCommandBuilder, blocking_stand
from bosdyn.client.lease import LeaseClient, LeaseKeepAlive

def main():
    """Full example of connecting, leasing, powering on, standing, and powering off a robot."""
    
    # Get hostname, username, and password from environment variables
    hostname = os.getenv('BOSDYN_CLIENT_HOSTNAME')
    username = os.getenv('BOSDYN_CLIENT_USERNAME')
    password = os.getenv('BOSDYN_CLIENT_PASSWORD')

    if not all([hostname, username, password]):
        print('Error: Please set BOSDYN_CLIENT_HOSTNAME, BOSDYN_CLIENT_USERNAME, and BOSDYN_CLIENT_PASSWORD environment variables.')
        return

    sdk = bosdyn.client.create_standard_sdk('StandClient')
    robot = sdk.create_robot(hostname)
    
    try:
        bosdyn.client.util.authenticate(robot, username, password)
        robot.time_sync.wait_for_sync()

        assert not robot.is_estopped(), 'Robot is estopped. Please clear operator exit before proceeding.'

        lease_client = robot.ensure_client(LeaseClient.default_service_name)
        command_client = robot.ensure_client(RobotCommandClient.default_service_name)

        with LeaseKeepAlive(lease_client, must_acquire=True, return_at_exit=True):
            print('Powering on robot...')
            robot.power_on(timeout_sec=20)
            assert robot.is_powered_on(), 'Robot power on failed.'
            print('Robot powered on.')

            print('Commanding robot to stand...')
            blocking_stand(command_client, timeout_sec=10)
            print('Robot is standing.')
            
            time.sleep(3) # Keep standing for 3 seconds

            print('Powering off robot...')
            robot.power_off(cut_immediately=False, timeout_sec=20)
            print('Robot powered off.')

    except Exception as exc:
        print(f'An error occurred: {exc}')

if __name__ == '__main__':
    main()
Develop for Boston Dynamics Robots Using the SDK — Action Pack