Skip to content
Snippets Groups Projects
Commit 7e90504e authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Change to running task to reduce IMPORTANT log by periodic task

parent cb5cb122
No related branches found
No related tags found
1 merge request!302Change to running task to reduce IMPORTANT log by periodic task
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <filesystem> #include <filesystem>
#include <ArmarXCore/core/time/CycleUtil.h> #include <ArmarXCore/core/time/Metronome.h>
namespace armarx namespace armarx
...@@ -39,7 +39,7 @@ namespace armarx ...@@ -39,7 +39,7 @@ namespace armarx
armarx::PropertyDefinitionsPtr defs(new RobotToArVizPropertyDefinitions(getConfigIdentifier())); armarx::PropertyDefinitionsPtr defs(new RobotToArVizPropertyDefinitions(getConfigIdentifier()));
// defs->optional(updateFrequency, "updateFrequency", "Target number of updates per second."); // defs->optional(updateFrequency, "updateFrequency", "Target number of updates per second.");
defs->defineOptionalProperty("updateFrequency", updateFrequency, "Target number of updates per second."); defs->defineOptionalProperty("updateFrequency", updateFrequencyHz, "Target number of updates per second.");
defs->optional(gui.useCollisionModel, "UseCollisionModel", "Use the collision model for visualization"); defs->optional(gui.useCollisionModel, "UseCollisionModel", "Use the collision model for visualization");
defs->optional(gui.showRobotNodeFrames, "ShowRobotNodeFrames", defs->optional(gui.showRobotNodeFrames, "ShowRobotNodeFrames",
...@@ -57,7 +57,7 @@ namespace armarx ...@@ -57,7 +57,7 @@ namespace armarx
void RobotToArViz::onInitComponent() void RobotToArViz::onInitComponent()
{ {
getProperty(updateFrequency, "updateFrequency"); getProperty(updateFrequencyHz, "updateFrequency");
} }
...@@ -83,10 +83,10 @@ namespace armarx ...@@ -83,10 +83,10 @@ namespace armarx
createRemoteGuiTab(); createRemoteGuiTab();
RemoteGui_startRunningTask(); RemoteGui_startRunningTask();
task = new SimplePeriodicTask<>([this]() task = new SimpleRunningTask<>([this]()
{ {
this->updateRobot(); this->updateRobotRun();
}, int(1000 / updateFrequency)); });
task->start(); task->start();
} }
...@@ -135,7 +135,19 @@ namespace armarx ...@@ -135,7 +135,19 @@ namespace armarx
} }
void RobotToArViz::updateRobot() void RobotToArViz::updateRobotRun()
{
Metronome metronome(Frequency::Hertz(updateFrequencyHz));
while (task and not task->isStopped())
{
updateRobotOnce();
metronome.waitForNextTick();
}
}
void RobotToArViz::updateRobotOnce()
{ {
RobotState::synchronizeLocalClone(robotName); RobotState::synchronizeLocalClone(robotName);
......
...@@ -96,14 +96,15 @@ namespace armarx ...@@ -96,14 +96,15 @@ namespace armarx
private: private:
void updateRobot(); void updateRobotRun();
void updateRobotOnce();
static bool trySetFilePathFromDataDir(viz::Robot& robotViz, const std::string& absolutePath); static bool trySetFilePathFromDataDir(viz::Robot& robotViz, const std::string& absolutePath);
private: private:
float updateFrequency = 100; float updateFrequencyHz = 100;
SimplePeriodicTask<>::pointer_type task; SimpleRunningTask<>::pointer_type task;
std::string robotName = "robot"; std::string robotName = "robot";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment