Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.5
hooks:
- id: ruff
args:
- --fix
- --exit-non-zero-on-fix
- id: ruff-format

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- id: cmake-lint

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v19.1.7
hooks:
- id: clang-format
types_or: [c++, c]
args:
- --style=Google

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: pretty-format-json
- id: trailing-whitespace
- id: check-yaml

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
Expand Down
66 changes: 23 additions & 43 deletions robotiq_hande_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,51 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

set(HW_IF_INCLUDE_DEPENDS
fmt
hardware_interface
pluginlib
rclcpp
rclcpp_lifecycle
rcpputils
)
set(HW_IF_INCLUDE_DEPENDS fmt hardware_interface pluginlib rclcpp
rclcpp_lifecycle rcpputils)

find_package(ament_cmake REQUIRED)
foreach(Dependency IN ITEMS ${HW_IF_INCLUDE_DEPENDS})
find_package(${Dependency} REQUIRED)
foreach(dependency IN ITEMS ${HW_IF_INCLUDE_DEPENDS})
find_package(${dependency} REQUIRED)
endforeach()

add_library(${PROJECT_NAME}
SHARED
hardware/src/hande_hardware_interface.cpp
)
add_library(${PROJECT_NAME} SHARED hardware/src/hande_hardware_interface.cpp)

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
target_include_directories(robotiq_hande_driver PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hardware/include>
$<INSTALL_INTERFACE:include>
)
ament_target_dependencies(
${PROJECT_NAME} PUBLIC
${HW_IF_INCLUDE_DEPENDS}
)
target_include_directories(
robotiq_hande_driver
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hardware/include>
$<INSTALL_INTERFACE:include>)
ament_target_dependencies(${PROJECT_NAME} PUBLIC ${HW_IF_INCLUDE_DEPENDS})

pluginlib_export_plugin_description_file(hardware_interface ros2_control_plugin.xml)
pluginlib_export_plugin_description_file(hardware_interface
ros2_control_plugin.xml)

install(
DIRECTORY hardware/include/
DESTINATION include/
)
install(
DIRECTORY bringup
DESTINATION share/${PROJECT_NAME}
)
install(DIRECTORY hardware/include/ DESTINATION include/)
install(DIRECTORY bringup DESTINATION share/${PROJECT_NAME})


install(TARGETS ${PROJECT_NAME}
install(
TARGETS ${PROJECT_NAME}
EXPORT export_${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
RUNTIME DESTINATION bin)

if(BUILD_TESTING)
find_package(ament_cmake_gmock REQUIRED)
# find_package(ament_cmake_pytest REQUIRED)
find_package(hardware_interface REQUIRED)

ament_add_gmock(test_load_hw_interface
test/test_load_hw_interface.cpp
)
ament_add_gmock(test_load_hw_interface test/test_load_hw_interface.cpp)
target_link_libraries(test_load_hw_interface ${PROJECT_NAME})

# TODO: investigate
# ament_add_pytest_test(example_7_urdf_xacro test/test_urdf_xacro.py)
# ament_add_pytest_test(view_example_7_launch test/test_view_robot_launch.py)
# ament_add_pytest_test(run_example_7_launch test/test_r6bot_controller_launch.py)
# TODO: investigate ament_add_pytest_test(example_7_urdf_xacro
# test/test_urdf_xacro.py) ament_add_pytest_test(view_example_7_launch
# test/test_view_robot_launch.py) ament_add_pytest_test(run_example_7_launch
# test/test_r6bot_controller_launch.py)
endif()

## EXPORTS
# EXPORTS
ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
ament_export_dependencies(${HW_IF_INCLUDE_DEPENDS})
ament_package()
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ def generate_launch_description():


def launch_setup(context: LaunchContext) -> list[IncludeLaunchDescription]:

# tf_prefix is implicitly used in robot_state_publisher (in URDF substitution)
tf_prefix = LaunchConfiguration("tf_prefix", default="")
tf_prefix = LaunchConfiguration("tf_prefix", default="") # noqa: F841

return [
preapre_control_node(),
Expand Down Expand Up @@ -105,7 +104,8 @@ def preapre_control_node() -> Node:


def prepare_robot_state_publisher_node() -> Node:
tf_prefix = LaunchConfiguration("tf_prefix", default="")
# tf_prefix is implicitly used in ParameterValue()
tf_prefix = LaunchConfiguration("tf_prefix", default="") # noqa: F841
use_fake_hardware = LaunchConfiguration("use_fake_hardware")

robot_description_str = Command(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef ROBOTIQ_HANDE_DRIVER__HANDE_HARDWARE_INTERFACE_HPP_
#define ROBOTIQ_HANDE_DRIVER__HANDE_HARDWARE_INTERFACE_HPP_

#include <string>
#include <hardware_interface/system_interface.hpp>
#include <rclcpp/rclcpp.hpp>
#include <string>

namespace robotiq_hande_driver {

Expand All @@ -12,37 +12,43 @@ namespace rlccp_lc = rclcpp_lifecycle;

constexpr int LEFT_FINGER_JOINT_ID = 0;

class RobotiqHandeHardwareInterface : public HWI::SystemInterface
{
public:
RobotiqHandeHardwareInterface();

HWI::CallbackReturn on_init(const HWI::HardwareInfo& info) override;
HWI::CallbackReturn on_configure(const rlccp_lc::State& previous_state) override;
HWI::CallbackReturn on_cleanup(const rlccp_lc::State& previous_state) override;
std::vector<HWI::StateInterface> export_state_interfaces() override;
std::vector<HWI::CommandInterface> export_command_interfaces() override;

HWI::CallbackReturn on_activate(const rlccp_lc::State& previous_state) override;
HWI::CallbackReturn on_deactivate(const rlccp_lc::State& previous_state) override;

HWI::CallbackReturn on_shutdown(const rlccp_lc::State& previous_state) override;
HWI::CallbackReturn on_error(const rlccp_lc::State& previous_state) override;

HWI::return_type read(const rclcpp::Time& time, const rclcpp::Duration& period) override;
HWI::return_type write(const rclcpp::Time& time, const rclcpp::Duration& period) override;

rclcpp::Logger get_logger() const { return *logger_; }

private:
//TODO(modbus integration): composition of the modbus communication
std::shared_ptr<rclcpp::Logger> logger_;

std::string tty_port_;
double state_position_;
double state_velocity_;
double cmd_position_;
class RobotiqHandeHardwareInterface : public HWI::SystemInterface {
public:
RobotiqHandeHardwareInterface();

HWI::CallbackReturn on_init(const HWI::HardwareInfo& info) override;
HWI::CallbackReturn on_configure(
const rlccp_lc::State& previous_state) override;
HWI::CallbackReturn on_cleanup(
const rlccp_lc::State& previous_state) override;
std::vector<HWI::StateInterface> export_state_interfaces() override;
std::vector<HWI::CommandInterface> export_command_interfaces() override;

HWI::CallbackReturn on_activate(
const rlccp_lc::State& previous_state) override;
HWI::CallbackReturn on_deactivate(
const rlccp_lc::State& previous_state) override;

HWI::CallbackReturn on_shutdown(
const rlccp_lc::State& previous_state) override;
HWI::CallbackReturn on_error(const rlccp_lc::State& previous_state) override;

HWI::return_type read(const rclcpp::Time& time,
const rclcpp::Duration& period) override;
HWI::return_type write(const rclcpp::Time& time,
const rclcpp::Duration& period) override;

rclcpp::Logger get_logger() const { return *logger_; }

private:
// TODO(modbus integration): composition of the modbus communication
std::shared_ptr<rclcpp::Logger> logger_;

std::string tty_port_;
double state_position_;
double state_velocity_;
double cmd_position_;
};

} // namespace robotiq_hande_driver
} // namespace robotiq_hande_driver
#endif // ROBOTIQ_HANDE_DRIVER__HANDE_HARDWARE_INTERFACE_HPP_
Loading