Skip to content

Commit 31b923d

Browse files
committed
reorder joint status state checking
1 parent 481ce37 commit 31b923d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

mep3_controllers/src/joint_position_controller.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,7 @@ namespace mep3_controllers
130130
auto result = std::make_shared<mep3_msgs::action::JointPositionCommand::Result>();
131131
result->set__last_effort(joint->effort_handle->get().get_value());
132132
result->set__last_position(joint->position_handle->get().get_value());
133-
if (fabs(joint->position_handle->get().get_value() - joint->target_position) < joint->tolerance)
134-
{
135-
result->set__result(mep3_msgs::action::JointPositionCommand::Goal::RESULT_SUCCESS);
136-
joint->action_server->succeeded_current(result);
137-
joint->active = false;
138-
}
139-
else if (joint->action_server->is_cancel_requested())
133+
if (joint->action_server->is_cancel_requested())
140134
{
141135
result->set__result(mep3_msgs::action::JointPositionCommand::Goal::RESULT_PREEMPTED);
142136
joint->action_server->terminate_current(result);
@@ -164,6 +158,12 @@ namespace mep3_controllers
164158
joint->active = false;
165159
RCLCPP_ERROR(get_node()->get_logger(), "Joint %s overload", joint->name.c_str());
166160
}
161+
else if (fabs(joint->position_handle->get().get_value() - joint->target_position) < joint->tolerance)
162+
{
163+
result->set__result(mep3_msgs::action::JointPositionCommand::Goal::RESULT_SUCCESS);
164+
joint->action_server->succeeded_current(result);
165+
joint->active = false;
166+
}
167167
else
168168
{
169169
// TODO: If the action is terminated (with the feedback) then it crashes the whole BT.

0 commit comments

Comments
 (0)