diff --git a/source/RobotAPI/components/units/RobotUnit/RobotUnit.cpp b/source/RobotAPI/components/units/RobotUnit/RobotUnit.cpp index 5679160c7e1e8035e2bc0804ae5c86a95d008a5e..82be0d0113e8f36adfe377ddcf49b79a9cf38c06 100644 --- a/source/RobotAPI/components/units/RobotUnit/RobotUnit.cpp +++ b/source/RobotAPI/components/units/RobotUnit/RobotUnit.cpp @@ -1070,13 +1070,16 @@ namespace armarx auto start = MicroNow(); nJointCtrl->rtSwapBufferAndRun(sensorValuesTimestamp, timeSinceLastIteration); auto duration = MicroNow() - start; - if (duration.count() > 500) + if (checkControllerExecutionTimings) { - ARMARX_ERROR << deactivateSpam(5) << "The NJointController " << nJointCtrl->getClassName() << " took " << duration.count() << " µs to run!"; - } - else if (duration.count() > 50) - { - ARMARX_RT_LOGF_WARN("An NJointController took %d µs to run!", duration.count()).deactivateSpam(5); + if (duration.count() > 500) + { + ARMARX_ERROR << deactivateSpam(5) << "The NJointController " << nJointCtrl->getClassName() << " took " << duration.count() << " µs to run!"; + } + else if (duration.count() > 50) + { + ARMARX_RT_LOGF_WARN("The NJointController with ID %d took %d µs to run!", nJointCtrl->getId(), duration.count()).deactivateSpam(5); + } } } } @@ -2860,6 +2863,8 @@ namespace armarx ObserverPublishSensorValues = getProperty<bool>("ObserverPublishSensorValues").getValue(); ObserverPublishControlTargets = getProperty<bool>("ObserverPublishControlTargets").getValue(); + checkControllerExecutionTimings = getProperty<bool>("CheckControllerExecutionTimings"); + //load robot { robotNodeSetName = getProperty<std::string>("RobotNodeSetName").getValue(); diff --git a/source/RobotAPI/components/units/RobotUnit/RobotUnit.h b/source/RobotAPI/components/units/RobotUnit/RobotUnit.h index 006fcf0cdf65580fab63759bd811faafd138a8f6..12069b65cba0520a9c154d2f5773ea44f2771ccc 100644 --- a/source/RobotAPI/components/units/RobotUnit/RobotUnit.h +++ b/source/RobotAPI/components/units/RobotUnit/RobotUnit.h @@ -240,6 +240,14 @@ namespace armarx defineOptionalProperty<std::string>( "TrajectoryControllerUnitName", "TrajectoryPlayer", "Name of the TrajectoryControllerUnit. The respective component outside of the RobotUnit is TrajectoryPlayer"); + + // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // + // ////////////////////////////////////////////////////// Misc. Properties ///////////////////////////////////////////////////////////// // + // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // + + defineOptionalProperty<bool>( + "CheckControllerExecutionTimings", false, + "Check controller execution timings and print a warning if execution takes long."); } }; @@ -593,6 +601,7 @@ namespace armarx // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // util // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // + bool checkControllerExecutionTimings = false; protected: template<class ExceptT = LogicError> inline void throwIfStateIsNot(const std::set<RobotUnitState>& sinit, const std::string& fnc, bool onlyWarn = false) const;