Skip to content

Commit 0c0282e

Browse files
MarqRazzJafarAbdi
andauthored
Update controller compatibility to latest ros2_controllers (#71)
* update Black version to pass CI Co-authored-by: JafarAbdi <[email protected]>
1 parent 279b2d4 commit 0c0282e

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

fault_controller/kortex2_controllers/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ find_package(controller_interface REQUIRED)
1212
find_package(geometry_msgs REQUIRED)
1313
find_package(example_interfaces REQUIRED)
1414
find_package(rclcpp REQUIRED)
15+
find_package(realtime_tools REQUIRED)
1516

1617
set(THIS_PACKAGE_INCLUDE_DEPENDS
1718
controller_interface
1819
geometry_msgs
1920
example_interfaces
21+
realtime_tools
2022
)
2123

2224
include_directories(include)

fault_controller/kortex2_controllers/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<depend>geometry_msgs</depend>
1414
<depend>example_interfaces</depend>
1515
<depend>rclcpp</depend>
16+
<depend>realtime_tools</depend>
1617

1718
<export>
1819
<build_type>ament_cmake</build_type>

fault_controller/kortex2_controllers/src/fault_controller.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ CallbackReturn FaultController::on_activate(const rclcpp_lifecycle::State & /*pr
8282
command_interfaces_[CommandInterfaces::RESET_FAULT_ASYNC_SUCCESS].set_value(NO_CMD);
8383
try
8484
{
85-
fault_pub_ = node_->create_publisher<FbkType>("~/internal_fault", 1);
85+
fault_pub_ = get_node()->create_publisher<FbkType>("~/internal_fault", 1);
8686
realtime_publisher_ = std::make_unique<StatePublisher>(fault_pub_);
8787
}
8888
catch (const std::exception & e)
@@ -92,7 +92,7 @@ CallbackReturn FaultController::on_activate(const rclcpp_lifecycle::State & /*pr
9292
e.what());
9393
return CallbackReturn::ERROR;
9494
}
95-
trigger_command_srv_ = node_->create_service<example_interfaces::srv::Trigger>(
95+
trigger_command_srv_ = get_node()->create_service<example_interfaces::srv::Trigger>(
9696
"~/reset_fault",
9797
std::bind(&FaultController::resetFault, this, std::placeholders::_1, std::placeholders::_2));
9898

@@ -114,7 +114,7 @@ bool FaultController::resetFault(
114114
command_interfaces_[CommandInterfaces::RESET_FAULT_ASYNC_SUCCESS].set_value(ASYNC_WAITING);
115115
command_interfaces_[CommandInterfaces::RESET_FAULT_CMD].set_value(ISSUE_CMD);
116116

117-
RCLCPP_INFO(node_->get_logger(), "Trying to reset faults on kinova controller.");
117+
RCLCPP_INFO(get_node()->get_logger(), "Trying to reset faults on kinova controller.");
118118

119119
while (command_interfaces_[CommandInterfaces::RESET_FAULT_ASYNC_SUCCESS].get_value() ==
120120
ASYNC_WAITING)
@@ -126,7 +126,7 @@ bool FaultController::resetFault(
126126
command_interfaces_[CommandInterfaces::RESET_FAULT_ASYNC_SUCCESS].get_value());
127127

128128
RCLCPP_INFO(
129-
node_->get_logger(), "Resetting fault on kinova controller '%s'!",
129+
get_node()->get_logger(), "Resetting fault on kinova controller '%s'!",
130130
resp->success ? "succeeded" : "failed");
131131

132132
return resp->success;

fault_controller/kortex2_controllers/src/twist_controller.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ CallbackReturn TwistController::on_init()
8080

8181
CallbackReturn TwistController::on_configure(const rclcpp_lifecycle::State & /*previous_state*/)
8282
{
83-
joint_name_ = node_->get_parameter("joint").as_string();
83+
joint_name_ = get_node()->get_parameter("joint").as_string();
8484

8585
if (joint_name_.empty())
8686
{
@@ -91,7 +91,7 @@ CallbackReturn TwistController::on_configure(const rclcpp_lifecycle::State & /*p
9191
// Specialized, child controllers set interfaces before calling configure function.
9292
if (interface_names_.empty())
9393
{
94-
interface_names_ = node_->get_parameter("interface_names").as_string_array();
94+
interface_names_ = get_node()->get_parameter("interface_names").as_string_array();
9595
}
9696

9797
if (interface_names_.empty())
@@ -136,7 +136,7 @@ controller_interface::return_type TwistController::update(
136136
if (command_interfaces_.size() != 6)
137137
{
138138
RCLCPP_ERROR_THROTTLE(
139-
get_node()->get_logger(), *node_->get_clock(), 1000,
139+
get_node()->get_logger(), *get_node()->get_clock(), 1000,
140140
"Twist controller needs does not match number of interfaces needed 6, given (%zu) interfaces",
141141
command_interfaces_.size());
142142
return controller_interface::return_type::ERROR;

0 commit comments

Comments
 (0)