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 @@
#include <filesystem>
#include <ArmarXCore/core/time/CycleUtil.h>
#include <ArmarXCore/core/time/Metronome.h>
namespace armarx
......@@ -39,7 +39,7 @@ namespace armarx
armarx::PropertyDefinitionsPtr defs(new RobotToArVizPropertyDefinitions(getConfigIdentifier()));
// 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.showRobotNodeFrames, "ShowRobotNodeFrames",
......@@ -57,7 +57,7 @@ namespace armarx
void RobotToArViz::onInitComponent()
{
getProperty(updateFrequency, "updateFrequency");
getProperty(updateFrequencyHz, "updateFrequency");
}
......@@ -83,10 +83,10 @@ namespace armarx
createRemoteGuiTab();
RemoteGui_startRunningTask();
task = new SimplePeriodicTask<>([this]()
task = new SimpleRunningTask<>([this]()
{
this->updateRobot();
}, int(1000 / updateFrequency));
this->updateRobotRun();
});
task->start();
}
......@@ -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);
......
......@@ -96,14 +96,15 @@ namespace armarx
private:
void updateRobot();
void updateRobotRun();
void updateRobotOnce();
static bool trySetFilePathFromDataDir(viz::Robot& robotViz, const std::string& absolutePath);
private:
float updateFrequency = 100;
SimplePeriodicTask<>::pointer_type task;
float updateFrequencyHz = 100;
SimpleRunningTask<>::pointer_type task;
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