Skip to content

Commit 7b139fc

Browse files
committed
FIX: merge issues
2 parents 891e5b0 + 8733050 commit 7b139fc

File tree

8 files changed

+125
-89
lines changed

8 files changed

+125
-89
lines changed

.clang-format

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
5+
ColumnLimit: 100
6+
IndentWidth: 4
7+
8+
AccessModifierOffset: -1
9+
AlignAfterOpenBracket: AlwaysBreak
10+
AllowShortFunctionsOnASingleLine: Empty
11+
BinPackArguments: false
12+
BinPackParameters: false
13+
BreakBeforeBinaryOperators: NonAssignment
14+
DerivePointerAlignment: false
15+
IncludeBlocks: Preserve
16+
IndentPPDirectives: BeforeHash
17+
PenaltyBreakAssignment: 21
18+
19+
SpaceBeforeParens: Custom
20+
SpaceBeforeParensOptions:
21+
AfterControlStatements: false
22+
AfterForeachMacros: false
23+
AfterFunctionDeclarationName: false
24+
AfterFunctionDefinitionName: false
25+
AfterIfMacros: false
26+
AfterOverloadedOperator: false
27+
AfterPlacementOperator: true
28+
AfterRequiresInClause: false
29+
AfterRequiresInExpression: false
30+
BeforeNonEmptyParentheses: false

.cmake-format.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
with section("format"): # noqa F821
2+
line_width = 100
3+
tab_size = 2
4+
command_case = "lower"
5+
max_subgroups_hwrap = 2
6+
max_pargs_hwrap = 4

.pre-commit-config.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
11
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.9.5
4+
hooks:
5+
- id: ruff
6+
args:
7+
- --fix
8+
- --exit-non-zero-on-fix
9+
- id: ruff-format
10+
11+
- repo: https://github.com/cheshirekow/cmake-format-precommit
12+
rev: v0.6.13
13+
hooks:
14+
- id: cmake-format
15+
- id: cmake-lint
16+
17+
- repo: https://github.com/pre-commit/mirrors-clang-format
18+
rev: v19.1.7
19+
hooks:
20+
- id: clang-format
21+
types_or: [c++, c]
22+
args:
23+
- --style=file
24+
225
- repo: https://github.com/pre-commit/pre-commit-hooks
326
rev: v5.0.0
427
hooks:
528
- id: check-added-large-files
29+
- id: check-ast
630
- id: check-case-conflict
31+
- id: check-executables-have-shebangs
732
- id: check-json
833
- id: check-merge-conflict
934
- id: check-symlinks
1035
- id: check-toml
1136
- id: check-xml
37+
- id: check-yaml
1238
- id: debug-statements
1339
- id: destroyed-symlinks
1440
- id: detect-private-key
1541
- id: end-of-file-fixer
42+
- id: fix-byte-order-marker
1643
- id: mixed-line-ending
1744
- id: pretty-format-json
1845
- id: trailing-whitespace
19-
- id: check-yaml
2046

2147
- repo: https://github.com/codespell-project/codespell
2248
rev: v2.2.6

robotiq_hande_driver/CMakeLists.txt

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.16)
22
project(robotiq_hande_driver)
33

44
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
5+
# TODO(issue#5) Fix warnings to enable the -Werror flag
56
add_compile_options(-Wall -Wextra -Wpedantic)
67
endif()
78

@@ -13,13 +14,12 @@ set(DEPENDS
1314
)
1415

1516
set(HW_IF_INCLUDE_DEPENDS
16-
fmt
17-
hardware_interface
18-
pluginlib
19-
rclcpp
20-
rclcpp_lifecycle
21-
rcpputils
22-
)
17+
fmt
18+
hardware_interface
19+
pluginlib
20+
rclcpp
21+
rclcpp_lifecycle
22+
rcpputils)
2323

2424
find_package(ament_cmake REQUIRED)
2525

@@ -44,33 +44,22 @@ add_executable(communication_test test/communication_test.cpp)
4444
target_link_libraries(communication_test ${catkin_LIBRARIES} ${DEPENDS})
4545

4646
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
47-
target_include_directories(robotiq_hande_driver PUBLIC
48-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hardware/include>
49-
$<INSTALL_INTERFACE:include>
50-
)
51-
ament_target_dependencies(
52-
${PROJECT_NAME} PUBLIC
53-
${HW_IF_INCLUDE_DEPENDS}
54-
)
47+
target_include_directories(
48+
robotiq_hande_driver PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/hardware/include>
49+
$<INSTALL_INTERFACE:include>)
50+
ament_target_dependencies(${PROJECT_NAME} PUBLIC ${HW_IF_INCLUDE_DEPENDS})
5551

5652
pluginlib_export_plugin_description_file(hardware_interface ros2_control_plugin.xml)
5753

58-
install(
59-
DIRECTORY hardware/include/
60-
DESTINATION include/
61-
)
62-
install(
63-
DIRECTORY bringup
64-
DESTINATION share/${PROJECT_NAME}
65-
)
66-
54+
install(DIRECTORY hardware/include/ DESTINATION include/)
55+
install(DIRECTORY bringup DESTINATION share/${PROJECT_NAME})
6756

68-
install(TARGETS ${PROJECT_NAME}
57+
install(
58+
TARGETS ${PROJECT_NAME}
6959
EXPORT export_${PROJECT_NAME}
7060
ARCHIVE DESTINATION lib
7161
LIBRARY DESTINATION lib
72-
RUNTIME DESTINATION bin
73-
)
62+
RUNTIME DESTINATION bin)
7463

7564
# include_directories(hardware/include/robotiq_hande_driver)
7665
# add_executable(application_test test/application_test.cpp hardware/src/application.cpp hardware/src/communication.cpp hardware/src/protocol_logic.cpp)
@@ -81,23 +70,21 @@ if(BUILD_TESTING)
8170
# find_package(ament_cmake_pytest REQUIRED)
8271
find_package(hardware_interface REQUIRED)
8372

84-
ament_add_gmock(test_load_hw_interface
85-
test/test_load_hw_interface.cpp
86-
)
73+
ament_add_gmock(test_load_hw_interface test/test_load_hw_interface.cpp)
8774
target_link_libraries(test_load_hw_interface ${PROJECT_NAME})
8875

8976
# ament_add_gmock(application_test
9077
# test/application_test.cpp
9178
# )
9279
# target_link_libraries(application_test ${PROJECT_NAME})
9380

94-
# TODO: investigate
95-
# ament_add_pytest_test(example_7_urdf_xacro test/test_urdf_xacro.py)
81+
# TODO: investigate ament_add_pytest_test(example_7_urdf_xacro test/test_urdf_xacro.py)
82+
9683
# ament_add_pytest_test(view_example_7_launch test/test_view_robot_launch.py)
9784
# ament_add_pytest_test(run_example_7_launch test/test_r6bot_controller_launch.py)
9885
endif()
9986

100-
## EXPORTS
87+
# EXPORTS
10188
ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET)
10289
ament_export_dependencies(${HW_IF_INCLUDE_DEPENDS})
10390
ament_package()

robotiq_hande_driver/bringup/launch/gripper_controller_preview.launch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ def generate_launch_description():
4848

4949

5050
def launch_setup(context: LaunchContext) -> list[IncludeLaunchDescription]:
51-
5251
# tf_prefix is implicitly used in robot_state_publisher (in URDF substitution)
53-
tf_prefix = LaunchConfiguration("tf_prefix", default="")
52+
tf_prefix = LaunchConfiguration("tf_prefix", default="") # noqa: F841
5453

5554
return [
5655
preapre_control_node(),
@@ -105,7 +104,8 @@ def preapre_control_node() -> Node:
105104

106105

107106
def prepare_robot_state_publisher_node() -> Node:
108-
tf_prefix = LaunchConfiguration("tf_prefix", default="")
107+
# tf_prefix is implicitly used in ParameterValue()
108+
tf_prefix = LaunchConfiguration("tf_prefix", default="") # noqa: F841
109109
use_fake_hardware = LaunchConfiguration("use_fake_hardware")
110110

111111
robot_description_str = Command(

robotiq_hande_driver/hardware/include/robotiq_hande_driver/hande_hardware_interface.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef ROBOTIQ_HANDE_DRIVER__HANDE_HARDWARE_INTERFACE_HPP_
22
#define ROBOTIQ_HANDE_DRIVER__HANDE_HARDWARE_INTERFACE_HPP_
33

4-
#include <string>
54
#include <hardware_interface/system_interface.hpp>
65
#include <rclcpp/rclcpp.hpp>
6+
#include <string>
77

88
#include "application.hpp"
99

@@ -14,9 +14,8 @@ namespace rlccp_lc = rclcpp_lifecycle;
1414

1515
constexpr int LEFT_FINGER_JOINT_ID = 0;
1616

17-
class RobotiqHandeHardwareInterface : public HWI::SystemInterface
18-
{
19-
public:
17+
class RobotiqHandeHardwareInterface : public HWI::SystemInterface {
18+
public:
2019
RobotiqHandeHardwareInterface();
2120

2221
HWI::CallbackReturn on_init(const HWI::HardwareInfo& info) override;
@@ -34,10 +33,11 @@ class RobotiqHandeHardwareInterface : public HWI::SystemInterface
3433
HWI::return_type read(const rclcpp::Time& time, const rclcpp::Duration& period) override;
3534
HWI::return_type write(const rclcpp::Time& time, const rclcpp::Duration& period) override;
3635

37-
rclcpp::Logger get_logger() const { return *logger_; }
36+
rclcpp::Logger get_logger() const {
37+
return *logger_;
38+
}
3839

3940
private:
40-
//--TODO(modbus integration): composition of the modbus communication
4141
GripperApplication application_layer_;
4242
std::shared_ptr<rclcpp::Logger> logger_;
4343

@@ -56,5 +56,5 @@ class RobotiqHandeHardwareInterface : public HWI::SystemInterface
5656
double cmd_force_;
5757
};
5858

59-
} // namespace robotiq_hande_driver
59+
} // namespace robotiq_hande_driver
6060
#endif // ROBOTIQ_HANDE_DRIVER__HANDE_HARDWARE_INTERFACE_HPP_

robotiq_hande_driver/hardware/src/hande_hardware_interface.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace robotiq_hande_driver {
88
RobotiqHandeHardwareInterface::RobotiqHandeHardwareInterface() {}
99

1010
HWI::CallbackReturn RobotiqHandeHardwareInterface::on_init(const HWI::HardwareInfo& info) {
11-
if (HWI::SystemInterface::on_init(info) != CallbackReturn::SUCCESS) {
11+
if(HWI::SystemInterface::on_init(info) != CallbackReturn::SUCCESS) {
1212
return HWI::CallbackReturn::ERROR;
1313
}
1414

@@ -27,17 +27,16 @@ HWI::CallbackReturn RobotiqHandeHardwareInterface::on_init(const HWI::HardwareIn
2727
state_position_ = gripper_position_max_;
2828

2929
logger_ = std::make_shared<rclcpp::Logger>(
30-
rclcpp::get_logger("controller_manager.resource_manager.hardware_component.system.RobotiqHandeHardwareInterface"));
30+
rclcpp::get_logger("controller_manager.resource_manager.hardware_"
31+
"component.system.RobotiqHandeHardwareInterface"));
3132

32-
//--TODO(modbus integration): Set parameters for the modbus communication
3333
application_layer_.initialize(gripper_position_min_, gripper_position_max_, tty_port_, baudrate_, parity_, data_bits_, stop_bit_, slave_id_);
3434

3535
RCLCPP_INFO(get_logger(), "Initialized ModbusRTU for %s", tty_port_.c_str());
3636
return HWI::CallbackReturn::SUCCESS;
3737
}
3838

3939
HWI::CallbackReturn RobotiqHandeHardwareInterface::on_configure(const rlccp_lc::State& /*previous_state*/){
40-
//--TODO(modbus integration): Initialize the ModbusRTU communication session
4140
int result;
4241

4342
result = application_layer_.configure();
@@ -48,7 +47,6 @@ HWI::CallbackReturn RobotiqHandeHardwareInterface::on_configure(const rlccp_lc::
4847
}
4948

5049
HWI::CallbackReturn RobotiqHandeHardwareInterface::on_cleanup(const rlccp_lc::State& /*previous_state*/){
51-
//--TODO(modbus integration): Deinitalize the ModbusRTU session
5250
application_layer_.cleanup();
5351

5452
RCLCPP_INFO(get_logger(), "cleanup()");
@@ -59,9 +57,13 @@ std::vector<HWI::StateInterface> RobotiqHandeHardwareInterface::export_state_int
5957
std::vector<HWI::StateInterface> state_interfaces;
6058

6159
state_interfaces.emplace_back(hardware_interface::StateInterface(
62-
info_.joints[LEFT_FINGER_JOINT_ID].name, hardware_interface::HW_IF_POSITION, &state_position_));
60+
info_.joints[LEFT_FINGER_JOINT_ID].name,
61+
hardware_interface::HW_IF_POSITION,
62+
&state_position_));
6363
state_interfaces.emplace_back(hardware_interface::StateInterface(
64-
info_.joints[LEFT_FINGER_JOINT_ID].name, hardware_interface::HW_IF_VELOCITY, &state_velocity_));
64+
info_.joints[LEFT_FINGER_JOINT_ID].name,
65+
hardware_interface::HW_IF_VELOCITY,
66+
&state_velocity_));
6567

6668
RCLCPP_INFO(get_logger(), "export_state_interfaces()");
6769
return state_interfaces;
@@ -80,39 +82,33 @@ std::vector<HWI::CommandInterface> RobotiqHandeHardwareInterface::export_command
8082
}
8183

8284
HWI::CallbackReturn RobotiqHandeHardwareInterface::on_activate(const rlccp_lc::State& /*previous_state*/){
83-
//--TODO(modbus integration): Power on the gripper (activation)
8485
application_layer_.activate();
8586

8687
RCLCPP_INFO(get_logger(), "activate()");
8788
return HWI::CallbackReturn::SUCCESS;
8889
}
8990

9091
HWI::CallbackReturn RobotiqHandeHardwareInterface::on_deactivate(const rlccp_lc::State& /*previous_state*/){
91-
//--TODO(modbus integration): Deactiavte the gripper (set the reset flag)
9292
application_layer_.deactivate();
9393

9494
RCLCPP_INFO(get_logger(), "deactivate()");
9595
return HWI::CallbackReturn::SUCCESS;
9696
}
9797

9898
HWI::CallbackReturn RobotiqHandeHardwareInterface::on_shutdown(const rlccp_lc::State& /*previous_state*/){
99-
//--TODO(modbus integration): Deactivate the gripper, deinitalize the modbus RTU session,
10099
application_layer_.shutdown();
101100

102101
RCLCPP_INFO(get_logger(), "shutdown()");
103102
return HWI::CallbackReturn::SUCCESS;
104103
}
105104

106105
HWI::CallbackReturn RobotiqHandeHardwareInterface::on_error(const rlccp_lc::State& /*previous_state*/){
107-
//--TODO(modbus integration): Placeholder for error handling
108106
RCLCPP_INFO(get_logger(), "Handled error with FAILURE on purpose - check logs");
109-
// return HWI::CallbackReturn::SUCCESS;
110107
return HWI::CallbackReturn::FAILURE;
111108
}
112109

113110
HWI::return_type RobotiqHandeHardwareInterface::read(const rclcpp::Time& /*time*/,
114111
const rclcpp::Duration& /*period*/) {
115-
//--TODO(modbus integration): data = driver_->receive_data();
116112
application_layer_.read();
117113
state_position_ = application_layer_.get_position();
118114

@@ -121,17 +117,16 @@ HWI::return_type RobotiqHandeHardwareInterface::read(const rclcpp::Time& /*time*
121117
}
122118
HWI::return_type RobotiqHandeHardwareInterface::write(const rclcpp::Time& /*time*/,
123119
const rclcpp::Duration& /*period*/) {
124-
//--TODO(modbus integration): driver_->send_data(cmd_position_);
125120
application_layer_.set_position(cmd_position_, cmd_force_);
126121
application_layer_.write();
127122

128123
RCLCPP_DEBUG(get_logger(), "write()");
124+
129125
return hardware_interface::return_type::OK;
130126
}
131127

132-
133-
} // namespace robotiq_hande_driver
128+
} // namespace robotiq_hande_driver
134129

135130
#include "pluginlib/class_list_macros.hpp"
136131
PLUGINLIB_EXPORT_CLASS(
137-
robotiq_hande_driver::RobotiqHandeHardwareInterface, hardware_interface::SystemInterface)
132+
robotiq_hande_driver::RobotiqHandeHardwareInterface, hardware_interface::SystemInterface)

0 commit comments

Comments
 (0)