diff --git a/src/sas_robot_driver_ros.cpp b/src/sas_robot_driver_ros.cpp index 497cda9..19aa2a7 100644 --- a/src/sas_robot_driver_ros.cpp +++ b/src/sas_robot_driver_ros.cpp @@ -162,6 +162,17 @@ int RobotDriverROS::control_loop() } + // Execute the control loop callback if one has been set + if (robot_driver_->control_loop_callback_is_set()) { + RCLCPP_INFO_STREAM_ONCE(node_->get_logger(), "::Control loop callback is set and will be executed!"); + try { + robot_driver_->execute_control_loop_callback(); + } catch (const std::exception& e) { + throw std::runtime_error("Control loop callback execution failed: " + std::string(e.what())); + } + } + + auto joint_positions{robot_driver_->get_joint_positions()}; VectorXd joint_velocities; try{joint_velocities = robot_driver_->get_joint_velocities();} catch(...){}