Skip to content

Commit

Permalink
deactivate hwif if controller activation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
altex111 committed Feb 27, 2023
1 parent 9f1f990 commit ff90fdf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion kuka_rox_hardware_interface/src/robot_manager_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ RobotManagerNode::on_activate(const rclcpp_lifecycle::State &)
);
if (!controller_response || !controller_response->ok) {
RCLCPP_ERROR(get_logger(), "Could not start joint state broadcaster");
// TODO(Svastits): this can be removed if rollback is implemented properly
this->on_deactivate(get_current_state());
return FAILURE;
}

Expand All @@ -251,6 +253,8 @@ RobotManagerNode::on_activate(const rclcpp_lifecycle::State &)
);
if (!controller_response || !controller_response->ok) {
RCLCPP_ERROR(get_logger(), "Could not activate controller");
// TODO(Svastits): this can be removed if rollback is implemented properly
this->on_deactivate(get_current_state());
return FAILURE;
}
RCLCPP_INFO(get_logger(), "Successfully activated controllers");
Expand All @@ -275,7 +279,7 @@ RobotManagerNode::on_deactivate(const rclcpp_lifecycle::State &)
hw_request->target_state.id = State::PRIMARY_STATE_INACTIVE;
auto hw_response =
kroshu_ros2_core::sendRequest<SetHardwareComponentState::Response>(
change_hardware_state_client_, hw_request, 0, 3000);
change_hardware_state_client_, hw_request, 0, 3000); // was not stable with 2000 ms timeout
if (!hw_response || !hw_response->ok) {
RCLCPP_ERROR(get_logger(), "Could not deactivate hardware interface");
return ERROR;
Expand Down

0 comments on commit ff90fdf

Please sign in to comment.