Skip to content

Commit 17f628f

Browse files
committed
Fixed state update bug
1 parent 7cbce50 commit 17f628f

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

whole_body_controllers/src/ik_controller.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,18 @@ auto IKController::update_system_state_values() -> controller_interface::return_
355355
}
356356
}
357357

358-
if (common::math::has_nan(position_state_values_) || common::math::has_nan(velocity_state_values_)) {
359-
RCLCPP_DEBUG(logger_, "Received system states with NaN value."); // NOLINT
360-
return controller_interface::return_type::ERROR;
358+
if (use_position_states_) {
359+
if (common::math::has_nan(position_state_values_)) {
360+
RCLCPP_DEBUG(logger_, "Received position states with NaN value."); // NOLINT
361+
return controller_interface::return_type::ERROR;
362+
}
363+
}
364+
365+
if (use_velocity_states_) {
366+
if (common::math::has_nan(velocity_state_values_)) {
367+
RCLCPP_DEBUG(logger_, "Received velocity states with NaN value."); // NOLINT
368+
return controller_interface::return_type::ERROR;
369+
}
361370
}
362371

363372
return controller_interface::return_type::OK;
@@ -366,11 +375,11 @@ auto IKController::update_system_state_values() -> controller_interface::return_
366375
auto IKController::update_and_validate_interfaces() -> controller_interface::return_type
367376
{
368377
if (update_system_state_values() != controller_interface::return_type::OK) {
369-
RCLCPP_INFO(logger_, "Failed to update system state values"); // NOLINT
378+
RCLCPP_DEBUG(logger_, "Failed to update system state values"); // NOLINT
370379
return controller_interface::return_type::ERROR;
371380
}
372381
if (common::math::has_nan(reference_interfaces_)) {
373-
RCLCPP_INFO(logger_, "Received reference with NaN value."); // NOLINT
382+
RCLCPP_DEBUG(logger_, "Received reference with NaN value."); // NOLINT
374383
return controller_interface::return_type::ERROR;
375384
}
376385
return controller_interface::return_type::OK;
@@ -381,7 +390,7 @@ auto IKController::update_and_write_commands(const rclcpp::Time & /*time*/, cons
381390
-> controller_interface::return_type
382391
{
383392
if (update_and_validate_interfaces() != controller_interface::return_type::OK) {
384-
RCLCPP_INFO(logger_, "Skipping controller update. Failed to update and validate interfaces"); // NOLINT
393+
RCLCPP_DEBUG(logger_, "Skipping controller update. Failed to update and validate interfaces"); // NOLINT
385394
return controller_interface::return_type::OK;
386395
}
387396

0 commit comments

Comments
 (0)