Skip to content

Commit

Permalink
Add SLATE Base ROS 2 Drivers (#35)
Browse files Browse the repository at this point in the history
* [ros_slate] Add the Interbotix Slate ROS 2 driver

* Reconfigure base services

* Don't install launch directory

* Remove unneeded install directive

* Lint

* Add logging to service callbacks

* Return service success

* Swap base_node and base files

* Add COLCON_IGNORE to ros_xseries

* Update SLATE driver function docstrings

* Update some language in SLATE base node

* Add SLATE base humble workflow

* Modify ROS 2 workflows to remove new COLCON_IGNORE

* Fix workflow syntax

* Remove broken dependency

* Fix xs-humble CI steps

* Revert change to galactic workflow
  • Loading branch information
lukeschmitt-tr committed Apr 22, 2024
1 parent bd0c28e commit 6f72b6a
Show file tree
Hide file tree
Showing 23 changed files with 1,106 additions and 2 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/slate-humble.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: build-slate-humble

on:
push:
branches:
- humble
pull_request:
branches:
- humble
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
slate-humble:
strategy:
matrix:
env:
- {ROS_DISTRO: humble, ROS_REPO: main}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
path: src/interbotix_ros_core
- name: Prepare Workspace
run: |
rm src/interbotix_ros_core/interbotix_ros_slate/COLCON_IGNORE
- uses: 'ros-industrial/industrial_ci@master'
env: ${{matrix.env}}
5 changes: 4 additions & 1 deletion .github/workflows/xs-humble.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive
path: src
path: src/interbotix_ros_core
- name: Prepare Workspace
run: |
rm src/interbotix_ros_core/interbotix_ros_xseries/COLCON_IGNORE
- uses: 'ros-industrial/industrial_ci@master'
env: ${{matrix.env}}
5 changes: 4 additions & 1 deletion .github/workflows/xs-rolling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: recursive
path: src
path: src/interbotix_ros_core
- name: Prepare Workspace
run: |
rm src/interbotix_ros_core/interbotix_ros_xseries/COLCON_IGNORE
- uses: 'ros-industrial/industrial_ci@master'
env: ${{matrix.env}}
Empty file.
11 changes: 11 additions & 0 deletions interbotix_ros_slate/interbotix_ros_slate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.5)
project(interbotix_ros_slate)
find_package(ament_cmake REQUIRED)
unset(CATKIN_INSTALL_INTO_PREFIX_ROOT)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
1 change: 1 addition & 0 deletions interbotix_ros_slate/interbotix_ros_slate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# interbotix_ros_slate
21 changes: 21 additions & 0 deletions interbotix_ros_slate/interbotix_ros_slate/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>interbotix_ros_slate</name>
<version>0.0.0</version>
<description>The interbotix_ros_slate metapackage</description>
<maintainer email="trsupport@trossenrobotics.com">Trossen Robotics</maintainer>
<license>BSD-3-Clause</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>interbotix_slate_driver</depend>
<depend>interbotix_slate_msgs</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
88 changes: 88 additions & 0 deletions interbotix_ros_slate/interbotix_slate_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
cmake_minimum_required(VERSION 3.10.0)
project(interbotix_slate_driver)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()

if(CMAKE_COMPILER_IS_GNUXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(CMAKE_BUILD_TYPE "Release")

set(serial_driver "chassis_driver")

find_package(ament_cmake REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(interbotix_slate_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(tf2_ros REQUIRED)

include_directories(include)

set(ROS_DEPENDENCIES
geometry_msgs
interbotix_slate_msgs
nav_msgs
rclcpp
sensor_msgs
std_msgs
std_srvs
tf2_geometry_msgs
tf2_ros
)

link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)

add_library(slate_base
src/slate_base.cpp
src/base_driver.cpp
)

ament_target_dependencies(slate_base ${ROS_DEPENDENCIES})

target_link_libraries(slate_base
${serial_driver}
)

add_executable(slate_base_node
src/slate_base_node.cpp
)

target_link_libraries(slate_base_node
slate_base
)

install(
TARGETS slate_base
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(
TARGETS
slate_base_node
RUNTIME DESTINATION
lib/${PROJECT_NAME}
)

install(
FILES
lib/lib${serial_driver}.so
DESTINATION
lib
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
1 change: 1 addition & 0 deletions interbotix_ros_slate/interbotix_slate_driver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# interbotix_slate_driver
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright 2024 Trossen Robotics
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

#ifndef INTERBOTIX_SLATE_DRIVER__BASE_DRIVER_HPP_
#define INTERBOTIX_SLATE_DRIVER__BASE_DRIVER_HPP_

#include <string>

#include "interbotix_slate_driver/od_index.hpp"

namespace base_driver
{

bool chassisInit(std::string & dev);
bool chassisControl(float aim_x_vel, float aim_z_omega);
bool getChassisInfo(float & x_vel, float & z_omega);
bool getChassisOdom(float & odom_x, float & odom_y, float & odom_theta);

bool getBatteryInfo(float & vol, float & cur, int & percent);
bool getChassisState(SystemState & state);
bool getChassisCollision(int & collision);
bool getVersion(char * text);
bool getJoyState(int & state);

// Limited to 100 characters
bool setText(const char * text);

// 0 / 1
bool setCharge(int charge);

// 0 / 1
bool setAlarm(int alarm);

bool motorCtrl(int v);

bool setIo(int io);

bool getIo(int & io_state);

// 0 ~ 100
bool setLight(int light);

bool setStateLight(int light);

} // namespace base_driver

#endif // INTERBOTIX_SLATE_DRIVER__BASE_DRIVER_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright 2024 Trossen Robotics
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

#ifndef INTERBOTIX_SLATE_DRIVER__OD_INDEX_HPP_
#define INTERBOTIX_SLATE_DRIVER__OD_INDEX_HPP_

#define PORT "chassis"

typedef enum
{
SYS_INIT = 0x00,
SYS_NORMAL,
SYS_REMOTE,
SYS_ESTOP,
SYS_CALIB,
SYS_TEST,
SYS_CHARGING,

SYS_ERR = 0x10,
SYS_ERR_ID,
SYS_ERR_COM,
SYS_ERR_ENC,
SYS_ERR_COLLISION,
SYS_ERR_LOW_VOLTAGE,
SYS_ERR_OVER_VOLTAGE,
SYS_ERR_OVER_CURRENT,
SYS_ERR_OVER_TEMP,

SYS_STATE_LEN,
} SystemState;

typedef enum
{
INDEX_SYS_STATE = 0,
INDEX_SYS_POWER_PERCENTAGE = 1,

INDEX_CHASSIS_VEL = 2,
INDEX_CHASSIS_POS_OR_OMEGA = 3,
INDEX_CHASSIS_ODOM_X = 4,
INDEX_CHASSIS_ODOM_Y = 5,
INDEX_CHASSIS_ODOM_THETA = 6,

INDEX_SYS_VOLTAGE = 7,
INDEX_SYS_CURRENT = 8,

INDEX_AIM_CHASSIS_VEL = 9,
INDEX_AIM_CHASSIS_POS_OR_OMEGA = 10,

INDEX_SYS_CHARGE = 11,
INDEX_SYS_ALARM = 12,
INDEX_SYS_TEXT = 13,
INDEX_SYS_LIGHT = 14,
INDEX_SYS_COLLISION = 15,
INDEX_SYS_VERSION = 16,
INDEX_STATE_LIGHT = 17,
INDEX_STATE_JOY = 18,
INDEX_STATE_IO = 21,
INDEX_SYS_CMD = 22,
} OdIndex;

#endif // INTERBOTIX_SLATE_DRIVER__OD_INDEX_HPP_
Loading

0 comments on commit 6f72b6a

Please sign in to comment.