This guide will help you set up your programming environment to successfully command and control the Boston Dynamics Spot robot using the Spot C++ SDK. The guide defaults to a Linux setup.
Windows users: Please find notes like this to help you where Windows may differ from Linux.
- System setup
- Install the C++ SDK
- Verify you can command and query Spot
- Run Hello Spot example
- Next steps
The Boston Dynamics Spot C++ SDK works with most operating systems including:
- Linux Ubuntu 22.04 LTS
- gcc version 7+
- Windows 10
- Microsoft Visual Studio 2017+
- cmake version 3.10.2+, 3.14+ for CORE I/O
On Linux, install all the system requirements with the command:
sudo apt-get update && apt-get -y install build-essential git g++ pkg-config curl tar zip unzip zlib1g-dev libssl-dev
On Windows, install Microsoft Visual Studio and git manually.
Spot C++ SDK works with gcc and Microsoft Visual Studio.
The C++ SDK depends on gRPC, Protobuf, Eigen and CLI11. Protobuf is included in gRPC. The instructions below use vcpkg
to install these dependencies. All commands need to be run on a Linux/Windows terminal.
- Clone vcpkg. The checkout hash below specifies the one used for testing internally. This version of vcpkg installs the dependency versions:
- gRPC 1.51.1
- Protobuf 3.21.12
- Eigen 3.4.0#2
- CLI11 2.3.1
It also downloads cmake in the location downloads/tools/{CMAKE_VERSION}/{CMAKE_VERSION}/bin/cmake
, which is needed to build the SDK. Please add that folder to your PATH to simplify running cmake on the terminal.
git clone https://github.com/microsoft/vcpkg
cd vcpkg
git checkout 3b213864579b6fa686e38715508f7cd41a50900f
- On x86-64 Linux:
./bootstrap-vcpkg.sh
./vcpkg install grpc:x64-linux
./vcpkg install eigen3:x64-linux
./vcpkg install cli11:x64-linux
- On arm64 Linux, such as CORE I/O:
./bootstrap-vcpkg.sh
export VCPKG_FORCE_SYSTEM_BINARIES=arm
./vcpkg install grpc:arm64-linux
./vcpkg install eigen3:arm64-linux
./vcpkg install cli11:arm64-linux
- On Windows, add
set(VCPKG_PLATFORM_TOOLSET v142)
in filevcpkg\triplets\x64-windows.cmake
to get Visual Studio 2019 builds.
> .\bootstrap-vcpkg.bat
> .\vcpkg.exe install grpc:x64-windows
> .\vcpkg.exe install eigen3:x64-windows
> .\vcpkg.exe install cli11:x64-windows
The Spot C++ SDK contains cmake files with instructions to configure, build and install the SDK. The cmake system also auto-generates the C++ protobuf classes from the protobuf definitions in the Spot API.
Developers need to clone or download the Spot C++ SDK distribution from github. The distribution contains client code, programming examples, protobuf definitions and API documentation.
The Spot C++ SDK distribution is available at https://github.com/boston-dynamics/spot-cpp-sdk.
Users can either:
git clone https://github.com/boston-dynamics/spot-cpp-sdk.git (recommended)
Or download a zipfile distribution:
- Select green box "Clone or download" from the webpage.
- Select "Download ZIP."
- Unzip the file to your home directory.
- Rename the top-level directory
spot-sdk-cpp-master
tospot-cpp-sdk
. (Not required: only for consistency with this document.)
To install the C++ SDK in a folder <SDK_install_path>, follow the steps below. Replace <vcpkg_install_path> with the folder where vcpkg
is installed and <SDK_clone_path> with the folder where the SDK is cloned.
cd <SDK_clone_path>
cd cpp
mkdir build
cd build
cmake ../ -DCMAKE_TOOLCHAIN_FILE=<vcpkg_absolute_install_path>/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=<SDK_absolute_install_path> -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE
The cmake
commands need the flag -DCMAKE_FIND_PACKAGE_PREFER_CONFIG=TRUE
, which instructs cmake to use its own version of find package instructions, instead of the one provided by the dependency. This is necessary for the protobuf dependency, which generates three versions of the find package instructions:
- The cmake version, which we need to use
- The Protobuf version, which is included in the Protobuf vcpkg installation
- The gRPC version, which is included in the gRPC vcpkg installation, and it might be identical to the version above.
The cmake
command can also overwrite the following variables by passing them to the cmake
command line with a -D
prefix:
CMAKE_BUILD_TYPE
: String variable to determine build type. The default value for this variable is "Release".BUILD_SHARED_LIBS
: Boolean ON/OFF variable to turn on the build of shared libraries. The default value for this variable is ON. Shared libraries currently are only supported on Linux. This limitation is temporary and will be addressed in future releases.BUILD_CHOREOGRAPHY_LIBS
: Boolean ON/OFF variable to turn on the build of choreography libraries. The default value for this variable is ON.
On Linux:
Build the SDK using the make
command below.
make -j6 install
The make
command generates a lot of deprecation warnings during the compiling of the classes generated from the protobuf definitions. This is expected as the protobuf definitions contain deprecated
flags for fields that will not be supported in future versions of the SDK.
On Windows:
- Open the
sln
file in the build folder in Microsoft Visual Studio. - Remove
libprotobuf.dll
library dependencies in the targets example executableshello_spot
,basic_robot_command
,get_image
andspot_cam
. Go to the properties of each target, then selectConfiguration Properties
, thenLinker
, thenInput
and then edit theAdditional Dependencies
and remove thelibprotobuf.dll
entry from the list. - Right click on INSTALL target and select
Build
.
To verify your packages work correctly with Spot, you need:
- A Spot robot on the same version as your packages
- A user account on the robot
Contact [email protected] to get a Spot robot.
If you have just unboxed your Spot robot, you will find a sticker inside the battery cavity with wifi, admin, and username "user" credentials. Please note however that Boston Dynamics recommends that you first have your designated robot administrator log onto the robot with admin credentials and change passwords to increase security.
NOTE: The following examples assume username "user" and password "password."
After creating the login credentials, store them in environment variables BOSDYN_CLIENT_USERNAME
and BOSDYN_CLIENT_PASSWORD
. You can also pass the credentials to the SDK example applications using the command-line arguments --username
and --password
.
- Power on Spot by holding the power button down until the fans start. Wait for the fans to turn off (10-20 seconds).
- Connect to Spot via wifi.
- Ping spot at 192.168.80.3.
$ ping 192.168.80.3
Issue the following command to run the hello_spot example from the SDK install bin/
folder:
# with `BOSDYN_CLIENT_USERNAME` and `BOSDYN_CLIENT_PASSWORD` environment variables set:
$ ./hello_spot 192.168.80.3
# without `BOSDYN_CLIENT_USERNAME` and `BOSDYN_CLIENT_PASSWORD` environment variables set:
$ ./hello_spot 192.168.80.3 --username {USER} --password {PASSWORD}
If this worked for you, SUCCESS! You are now successfully communicating with Spot via C++! Note that the output returned shows your Spot robot's unique serial number, its nickname and robot type (Boston Dynamics has multiple robots), software version, and install date.
-
Read our next section, Spot Programming. Highly recommended!
-
Take time to explore the programming examples which all launch in essentially the same manner as hello_spot.
- Try making simple modifications to the code.
- NOTE: If you installed the SDK using a zipfile, be careful to understand what changes you've made, as users sometimes inject errors into the SDK code unintentionally. Git users can simply use
git diff
to understand all changes they have made.
-
Read through the protocol buffer definitions and the Spot C++ SDK source code documentation to understand even more.
If you have any questions, please reach out to Support.