Skip to content

Commit 5a74f29

Browse files
authored
fix(parallel_gripper): rename variables for consistency (#2314)
1 parent 799f93e commit 5a74f29

2 files changed

Lines changed: 24 additions & 24 deletions

File tree

parallel_gripper_controller/include/parallel_gripper_controller/parallel_gripper_action_controller.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class GripperActionController : public controller_interface::ControllerInterface
6262
struct Commands
6363
{
6464
double position_cmd_; // Commanded position
65-
double max_velocity_; // Desired max gripper velocity
66-
double max_effort_; // Desired max allowed effort
65+
double velocity_cmd_; // Commanded velocity
66+
double effort_cmd_; // Commanded effort
6767
};
6868
GripperActionController();
6969

@@ -112,11 +112,11 @@ class GripperActionController : public controller_interface::ControllerInterface
112112

113113
std::string name_; ///< Controller name.
114114
std::optional<std::reference_wrapper<hardware_interface::LoanedCommandInterface>>
115-
joint_command_interface_;
115+
joint_position_command_interface_;
116116
std::optional<std::reference_wrapper<hardware_interface::LoanedCommandInterface>>
117-
effort_interface_;
117+
joint_effort_command_interface_;
118118
std::optional<std::reference_wrapper<hardware_interface::LoanedCommandInterface>>
119-
speed_interface_;
119+
joint_speed_command_interface_;
120120
std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>>
121121
joint_position_state_interface_;
122122
std::optional<std::reference_wrapper<hardware_interface::LoanedStateInterface>>

parallel_gripper_controller/include/parallel_gripper_controller/parallel_gripper_action_controller_impl.hpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,25 @@ controller_interface::return_type GripperActionController::update(
8383
check_for_success(
8484
get_node()->now(), error_position, current_position_op.value(), current_velocity_op.value());
8585

86-
if (!joint_command_interface_->get().set_value(command_struct_rt_.position_cmd_))
86+
if (!joint_position_command_interface_->get().set_value(command_struct_rt_.position_cmd_))
8787
{
8888
RCLCPP_WARN(
8989
logger, "Unable to set the joint position command to: %f", command_struct_rt_.position_cmd_);
9090
return controller_interface::return_type::OK;
9191
}
9292
if (
93-
speed_interface_.has_value() &&
94-
!speed_interface_->get().set_value(command_struct_rt_.max_velocity_))
93+
joint_speed_command_interface_.has_value() &&
94+
!joint_speed_command_interface_->get().set_value(command_struct_rt_.velocity_cmd_))
9595
{
96-
RCLCPP_WARN(logger, "Unable to set the speed command to: %f", command_struct_rt_.max_velocity_);
96+
RCLCPP_WARN(logger, "Unable to set the speed command to: %f", command_struct_rt_.velocity_cmd_);
9797

9898
return controller_interface::return_type::OK;
9999
}
100100
if (
101-
effort_interface_.has_value() &&
102-
!effort_interface_->get().set_value(command_struct_rt_.max_effort_))
101+
joint_effort_command_interface_.has_value() &&
102+
!joint_effort_command_interface_->get().set_value(command_struct_rt_.effort_cmd_))
103103
{
104-
RCLCPP_WARN(logger, "Unable to set the effort command to: %f", command_struct_rt_.max_effort_);
104+
RCLCPP_WARN(logger, "Unable to set the effort command to: %f", command_struct_rt_.effort_cmd_);
105105
return controller_interface::return_type::OK;
106106
}
107107

@@ -140,19 +140,19 @@ void GripperActionController::accepted_callback(
140140
command_struct_.position_cmd_ = goal_handle->get_goal()->command.position[0];
141141
if (!params_.max_velocity_interface.empty() && !goal_handle->get_goal()->command.velocity.empty())
142142
{
143-
command_struct_.max_velocity_ = goal_handle->get_goal()->command.velocity[0];
143+
command_struct_.velocity_cmd_ = goal_handle->get_goal()->command.velocity[0];
144144
}
145145
else
146146
{
147-
command_struct_.max_velocity_ = params_.max_velocity;
147+
command_struct_.velocity_cmd_ = params_.max_velocity;
148148
}
149149
if (!params_.max_effort_interface.empty() && !goal_handle->get_goal()->command.effort.empty())
150150
{
151-
command_struct_.max_effort_ = goal_handle->get_goal()->command.effort[0];
151+
command_struct_.effort_cmd_ = goal_handle->get_goal()->command.effort[0];
152152
}
153153
else
154154
{
155-
command_struct_.max_effort_ = params_.max_effort;
155+
command_struct_.effort_cmd_ = params_.max_effort;
156156
}
157157
command_.set(command_struct_);
158158

@@ -206,8 +206,8 @@ void GripperActionController::set_hold_position()
206206
RCLCPP_DEBUG(get_node()->get_logger(), "Unable to retrieve data of joint position");
207207
}
208208
command_struct_.position_cmd_ = position_op.value();
209-
command_struct_.max_effort_ = params_.max_effort;
210-
command_struct_.max_velocity_ = params_.max_velocity;
209+
command_struct_.effort_cmd_ = params_.max_effort;
210+
command_struct_.velocity_cmd_ = params_.max_velocity;
211211
command_.set(command_struct_);
212212
}
213213

@@ -347,19 +347,19 @@ controller_interface::CallbackReturn GripperActionController::on_activate(
347347
return controller_interface::CallbackReturn::ERROR;
348348
}
349349

350-
joint_command_interface_ = *command_interface_it;
350+
joint_position_command_interface_ = *command_interface_it;
351351
joint_position_state_interface_ = *position_state_interface_it;
352352
joint_velocity_state_interface_ = *velocity_state_interface_it;
353353

354354
for (auto & interface : command_interfaces_)
355355
{
356356
if (interface.get_interface_name() == "set_gripper_max_effort")
357357
{
358-
effort_interface_ = interface;
358+
joint_effort_command_interface_ = interface;
359359
}
360360
else if (interface.get_interface_name() == "set_gripper_max_velocity")
361361
{
362-
speed_interface_ = interface;
362+
joint_speed_command_interface_ = interface;
363363
}
364364
}
365365

@@ -373,8 +373,8 @@ controller_interface::CallbackReturn GripperActionController::on_activate(
373373
{
374374
command_struct_.position_cmd_ = position_op.value();
375375
}
376-
command_struct_.max_effort_ = params_.max_effort;
377-
command_struct_.max_velocity_ = params_.max_velocity;
376+
command_struct_.effort_cmd_ = params_.max_effort;
377+
command_struct_.velocity_cmd_ = params_.max_velocity;
378378
command_.try_set(command_struct_);
379379

380380
// Result
@@ -401,7 +401,7 @@ controller_interface::CallbackReturn GripperActionController::on_activate(
401401
controller_interface::CallbackReturn GripperActionController::on_deactivate(
402402
const rclcpp_lifecycle::State &)
403403
{
404-
joint_command_interface_ = std::nullopt;
404+
joint_position_command_interface_ = std::nullopt;
405405
joint_position_state_interface_ = std::nullopt;
406406
joint_velocity_state_interface_ = std::nullopt;
407407
return controller_interface::CallbackReturn::SUCCESS;

0 commit comments

Comments
 (0)