42 defs->defineOptionalProperty(
"updateFrequency", updateFrequencyHz,
"Target number of updates per second.");
43 defs->optional(gui.useCollisionModel,
"UseCollisionModel",
"Use the collision model for visualization");
45 defs->optional(gui.showRobotNodeFrames,
"ShowRobotNodeFrames",
46 "If true, show frames of robot nodes (can be changed in RemoteGui).");
54 return "RobotToArViz";
69 this->robot =
RobotState::addRobot(robotName, VirtualRobot::RobotIO::RobotDescription::eStructure);
77 if (!trySetFilePathFromDataDir(this->robotViz, robot->getFilename()))
80 this->robotViz.
file(
"", robot->getFilename());
88 this->updateRobotRun();
107 using namespace RemoteGui::Client;
112 tab.showRobotNodeFrames.setValue(gui.showRobotNodeFrames);
113 root.
add(
Label(
"Show Robot Node Frames"), {row, 0}).add(tab.showRobotNodeFrames, {row, 1});
116 tab.useCollisionModel.setValue(gui.useCollisionModel);
117 root.
add(
Label(
"Use Collision Model"), {row, 0}).add(tab.useCollisionModel, {row, 1});
125 if (tab.showRobotNodeFrames.hasValueChanged())
127 std::scoped_lock lock(guiMutex);
128 gui.showRobotNodeFrames = tab.showRobotNodeFrames.getValue();
130 if (tab.useCollisionModel.hasValueChanged())
132 std::scoped_lock lock(guiMutex);
133 gui.useCollisionModel = tab.useCollisionModel.getValue();
138 void RobotToArViz::updateRobotRun()
141 while (task and not task->isStopped())
145 metronome.waitForNextTick();
150 void RobotToArViz::updateRobotOnce()
156 std::scoped_lock lock(guiMutex);
160 std::vector<viz::Layer> layers;
162 robotViz.
joints(robot->getConfig()->getRobotNodeJointValueMap())
163 .
pose(robot->getGlobalPose());
165 if (gui.useCollisionModel)
175 layerRobot.
add(robotViz);
180 if (gui.showRobotNodeFrames)
182 for (
const auto& node : robot->getRobotNodes())
192 bool RobotToArViz::trySetFilePathFromDataDir(
viz::Robot& robotViz,
const std::string& absolutePath)
195 std::filesystem::path filepath = absolutePath;
197 for (
auto it = filepath.begin(); it != filepath.end(); ++it)
203 std::filesystem::path localPath = *jt;
205 for (; jt != filepath.end(); ++jt)
211 std::string
package = *it;
213 robotViz.
file(package, localPath.string());