Skip to content

Commit

Permalink
[PN-126] Combine spot_driver and spot_driver_cpp (bdaiinstitute#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrooks-bdai authored Feb 6, 2024
1 parent 6d62ab8 commit bc7fb4b
Show file tree
Hide file tree
Showing 82 changed files with 248 additions and 250 deletions.
27 changes: 26 additions & 1 deletion spot_driver_cpp/CMakeLists.txt → spot_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.22)

list(APPEND CMAKE_PREFIX_PATH /opt/spot-cpp-sdk)

project(spot_driver_cpp)
project(spot_driver)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
Expand All @@ -22,6 +22,7 @@ set(THIS_PACKAGE_INCLUDE_ROS_DEPENDS
)

find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(bosdyn REQUIRED)
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_ROS_DEPENDS})
find_package(${Dependency} REQUIRED)
Expand Down Expand Up @@ -100,6 +101,25 @@ rclcpp_components_register_node(
PLUGIN "spot_ros2::kinematic::KinematicNode"
EXECUTABLE kinematic_node_component)

ament_python_install_package(${PROJECT_NAME})
install(
PROGRAMS
spot_driver/command_spot_driver.py
DESTINATION lib/${PROJECT_NAME}
RENAME command_spot
)
install(
PROGRAMS
spot_driver/publish_cameras.py
DESTINATION lib/${PROJECT_NAME}
RENAME spot_publish_cameras
)
install(
PROGRAMS
spot_driver/spot_ros2.py
DESTINATION lib/${PROJECT_NAME}
RENAME spot_ros2
)
# Install Libraries
install(
TARGETS
Expand Down Expand Up @@ -128,6 +148,11 @@ install(
# Install include directory
install(DIRECTORY include/ DESTINATION include)

# Install launch and configurations
install(DIRECTORY config DESTINATION share/${PROJECT_NAME})
install(DIRECTORY launch DESTINATION share/${PROJECT_NAME})
install(DIRECTORY rviz DESTINATION share/${PROJECT_NAME})

ament_export_targets(${PROJECT_NAME}Targets HAS_LIBRARY_TARGET)
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})

Expand Down
23 changes: 23 additions & 0 deletions spot_driver/LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
MIT License

Copyright (c) 2023 Boston Dynamics AI Institute

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


BSD 3-Clause License

Copyright (c) 2021, Clearpath Robotics Inc.
Expand Down
20 changes: 20 additions & 0 deletions spot_driver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# spot_driver

This package provides ROS 2 nodes to interact with Spot through its SDK.

## Why Python?
Being known for it's ease of use and flexibility, the Spot Python SDK is used for many operations.
There are several entry points, though it is recommended to use the provided launch files.

- `spot_ros2` is the node used to connect to the spot and creates ROS 2 action servers and services.
- `command_spot` provides a command line interface with ROS 2 clients to send simple commands.
- `spot_publish_cameras` publishes camera images from spot cameras to ROS topics.
> :warning: **Warning:** For performance reasons, `spot_publish_cameras` is being rewritten in C++.
## Why C++?

The Spot C++ SDK is more performant than the Spot Python SDK for some operations.

For example, the Spot C++ SDK's image client can retrieve images from all Spot's RGB and depth cameras at close to their native refresh rate of 15Hz.

In constrast, the Spot Python SDK's image client slows substantially when requesting images from multiple depth cameras at once, and it can only maintain around 1Hz when requesting images from all RGB and depth cameras at once.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

#include <bosdyn/client/image/image_client.h>
#include <bosdyn/client/sdk/client_sdk.h>
#include <spot_driver_cpp/api/spot_image_sources.hpp>
#include <spot_driver_cpp/api/time_sync_api.hpp>
#include <spot_driver_cpp/interfaces/image_client_interface.hpp>
#include <spot_driver/api/spot_image_sources.hpp>
#include <spot_driver/api/time_sync_api.hpp>
#include <spot_driver/interfaces/image_client_interface.hpp>

#include <memory>
#include <string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#pragma once

#include <spot_driver_cpp/api/kinematic_api.hpp>
#include <spot_driver/api/kinematic_api.hpp>

#include <tl_expected/expected.hpp>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#pragma once

#include <spot_driver_cpp/api/spot_api.hpp>
#include <spot_driver/api/spot_api.hpp>

#include <bosdyn/client/robot/robot.h>
#include <bosdyn/client/sdk/client_sdk.h>
#include <spot_driver_cpp/api/time_sync_api.hpp>
#include <spot_driver/api/time_sync_api.hpp>

#include <memory>
#include <string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <google/protobuf/duration.pb.h>
#include <google/protobuf/timestamp.pb.h>
#include <builtin_interfaces/msg/time.hpp>
#include <spot_driver_cpp/api/time_sync_api.hpp>
#include <spot_driver/api/time_sync_api.hpp>
#include <tl_expected/expected.hpp>

#include <memory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#pragma once

#include <spot_driver_cpp/api/kinematic_api.hpp>
#include <spot_driver_cpp/interfaces/image_client_interface.hpp>
#include <spot_driver/api/kinematic_api.hpp>
#include <spot_driver/interfaces/image_client_interface.hpp>
#include <tl_expected/expected.hpp>

#include <memory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#pragma once

#include <bosdyn/client/image/image_client.h>
#include <spot_driver_cpp/types.hpp>
#include <spot_driver/types.hpp>
#include <tl_expected/expected.hpp>

#include <map>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
#include <memory>
#include <rclcpp/node.hpp>
#include <set>
#include <spot_driver_cpp/images/spot_image_publisher.hpp>
#include <spot_driver_cpp/interfaces/rclcpp_logger_interface.hpp>
#include <spot_driver_cpp/interfaces/rclcpp_parameter_interface.hpp>
#include <spot_driver_cpp/interfaces/rclcpp_tf_interface.hpp>
#include <spot_driver_cpp/interfaces/rclcpp_wall_timer_interface.hpp>
#include <spot_driver/images/spot_image_publisher.hpp>
#include <spot_driver/interfaces/rclcpp_logger_interface.hpp>
#include <spot_driver/interfaces/rclcpp_parameter_interface.hpp>
#include <spot_driver/interfaces/rclcpp_tf_interface.hpp>
#include <spot_driver/interfaces/rclcpp_wall_timer_interface.hpp>
#include <string>
#include <tl_expected/expected.hpp>
#include <unordered_map>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
#include <sensor_msgs/msg/camera_info.hpp>
#include <sensor_msgs/msg/image.hpp>
#include <set>
#include <spot_driver_cpp/api/spot_image_sources.hpp>
#include <spot_driver_cpp/interfaces/image_client_interface.hpp>
#include <spot_driver_cpp/interfaces/logger_interface_base.hpp>
#include <spot_driver_cpp/interfaces/parameter_interface_base.hpp>
#include <spot_driver_cpp/interfaces/tf_interface_base.hpp>
#include <spot_driver_cpp/interfaces/timer_interface_base.hpp>
#include <spot_driver_cpp/types.hpp>
#include <spot_driver/api/spot_image_sources.hpp>
#include <spot_driver/interfaces/image_client_interface.hpp>
#include <spot_driver/interfaces/logger_interface_base.hpp>
#include <spot_driver/interfaces/parameter_interface_base.hpp>
#include <spot_driver/interfaces/tf_interface_base.hpp>
#include <spot_driver/interfaces/timer_interface_base.hpp>
#include <spot_driver/types.hpp>
#include <string>
#include <unordered_map>
#include <vector>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#include <rclcpp/node_interfaces/node_base_interface.hpp>
#include <rclcpp/node_options.hpp>
#include <spot_driver_cpp/api/spot_api.hpp>
#include <spot_driver_cpp/images/spot_image_publisher.hpp>
#include <spot_driver_cpp/interfaces/logger_interface_base.hpp>
#include <spot_driver_cpp/interfaces/parameter_interface_base.hpp>
#include <spot_driver/api/spot_api.hpp>
#include <spot_driver/images/spot_image_publisher.hpp>
#include <spot_driver/interfaces/logger_interface_base.hpp>
#include <spot_driver/interfaces/parameter_interface_base.hpp>

#include <memory>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <builtin_interfaces/msg/time.hpp>
#include <geometry_msgs/msg/transform_stamped.hpp>
#include <spot_driver_cpp/api/spot_image_sources.hpp>
#include <spot_driver/api/spot_image_sources.hpp>
#include <tl_expected/expected.hpp>

#include <map>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#pragma once

#include <rclcpp/logger.hpp>
#include <spot_driver_cpp/interfaces/logger_interface_base.hpp>
#include <spot_driver/interfaces/logger_interface_base.hpp>

#include <string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#pragma once

#include <rclcpp/node.hpp>
#include <spot_driver_cpp/interfaces/parameter_interface_base.hpp>
#include <spot_driver/interfaces/parameter_interface_base.hpp>

#include <memory>
#include <string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <tf2_ros/static_transform_broadcaster.h>
#include <rclcpp/node.hpp>
#include <spot_driver_cpp/interfaces/tf_interface_base.hpp>
#include <spot_driver/interfaces/tf_interface_base.hpp>

#include <memory>
#include <set>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <rclcpp/node.hpp>
#include <rclcpp/timer.hpp>
#include <spot_driver_cpp/interfaces/timer_interface_base.hpp>
#include <spot_driver/interfaces/timer_interface_base.hpp>

#include <chrono>
#include <memory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.

#include <spot_driver_cpp/kinematic/kinematic_service.hpp>
#include <spot_driver/kinematic/kinematic_service.hpp>

#include <memory>
#include <rclcpp/node.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#pragma once

#include <spot_driver_cpp/kinematic/kinematic_service.hpp>
#include <spot_driver/kinematic/kinematic_service.hpp>

#include <spot_driver_cpp/api/spot_api.hpp>
#include <spot_driver_cpp/interfaces/logger_interface_base.hpp>
#include <spot_driver_cpp/interfaces/parameter_interface_base.hpp>
#include <spot_driver/api/spot_api.hpp>
#include <spot_driver/interfaces/logger_interface_base.hpp>
#include <spot_driver/interfaces/parameter_interface_base.hpp>

#include <rclcpp/node.hpp>
#include <rclcpp/node_interfaces/node_base_interface.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#pragma once

#include <spot_driver_cpp/api/kinematic_api.hpp>
#include <spot_driver/api/kinematic_api.hpp>

#include <spot_driver_cpp/interfaces/logger_interface_base.hpp>
#include <spot_driver/interfaces/logger_interface_base.hpp>

#include <spot_msgs/srv/get_inverse_kinematic_solutions.hpp>

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions spot_driver/launch/spot_driver.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def launch_setup(context: LaunchContext, ld: LaunchDescription) -> None:
spot_image_publisher_params.update({"publish_depth_registered": False})

spot_image_publisher_node = launch_ros.actions.Node(
package="spot_driver_cpp",
package="spot_driver",
executable="spot_image_publisher_node",
output="screen",
parameters=[config_file, spot_image_publisher_params],
Expand All @@ -211,7 +211,7 @@ def launch_setup(context: LaunchContext, ld: LaunchDescription) -> None:

kinematc_node_params = {"spot_name": spot_name}
kinematic_node = launch_ros.actions.Node(
package="spot_driver_cpp",
package="spot_driver",
executable="kinematic_node",
output="screen",
parameters=[config_file, kinematc_node_params],
Expand Down
51 changes: 28 additions & 23 deletions spot_driver/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,42 @@
<package format="3">
<name>spot_driver</name>
<version>0.0.0</version>
<description>This is a ROS2 package for Boston Dynamics' Spot.</description>
<maintainer email="maximillian.kirsch@alumni.fh-aachen.de">max</maintainer>
<description>ROS 2 driver nodes for Spot.</description>
<maintainer email="engineering@theaiinstitute.com">BD AI Institute</maintainer>
<license>MIT</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_python</buildtool_depend>
<buildtool_depend>rosidl_default_generators</buildtool_depend>

<exec_depend>bdai_ros2_wrappers</exec_depend>
<exec_depend>common_interfaces</exec_depend>
<exec_depend>depth_image_proc</exec_depend>
<exec_depend>nav_msgs</exec_depend>
<exec_depend>protobuf</exec_depend>
<exec_depend>python3-protobuf</exec_depend>
<exec_depend>rclcpp_components</exec_depend>
<exec_depend>robot_state_publisher</exec_depend>
<exec_depend>rosidl_default_runtime</exec_depend>
<exec_depend>rviz2</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>spot_description</exec_depend>
<exec_depend>spot_driver_cpp</exec_depend>
<exec_depend>spot_msgs</exec_depend>
<exec_depend>spot_wrapper</exec_depend>
<exec_depend>xacro</exec_depend>
<depend>bdai_ros2_wrappers</depend>
<depend>bosdyn</depend>
<depend>common_interfaces</depend>
<depend>depth_image_proc</depend>
<depend>geometry_msgs</depend>
<depend>nav_msgs</depend>
<depend>protobuf</depend>
<depend>python3-protobuf</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>rclpy</depend>
<depend>robot_state_publisher</depend>
<depend>rosidl_default_runtime</depend>
<depend>rviz2</depend>
<depend>sensor_msgs</depend>
<depend>spot_description</depend>
<depend>spot_msgs</depend>
<depend>spot_wrapper</depend>
<depend>tf2_ros</depend>
<depend>tl_expected</depend>
<depend>xacro</depend>

<test_depend>ament_copyright</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>ament_cmake_pytest</test_depend>

<member_of_group>rosidl_interface_packages</member_of_group>
<!-- Support for gtest and gmock-based tests in the ament buildsystem in CMake. -->
<test_depend>ament_cmake_gmock</test_depend>
<test_depend>ament_cmake_pytest</test_depend>

<export>
<build_type>ament_python</build_type>
<build_type>ament_cmake</build_type>
</export>
</package>
Empty file removed spot_driver/resource/spot_driver
Empty file.
4 changes: 0 additions & 4 deletions spot_driver/setup.cfg

This file was deleted.

Loading

0 comments on commit bc7fb4b

Please sign in to comment.