43 defs->defineOptionalProperty(
44 "updateFrequency", updateFrequencyHz,
"Target number of updates per second.");
45 defs->optional(
gui.useCollisionModel,
47 "Use the collision model for visualization");
49 defs->optional(
gui.showRobotNodeFrames,
50 "ShowRobotNodeFrames",
51 "If true, show frames of robot nodes (can be changed in RemoteGui).");
59 return "RobotToArViz";
75 VirtualRobot::RobotIO::RobotDescription::eStructure);
83 if (!trySetFilePathFromDataDir(this->robotViz, robot->getFilename()))
86 this->robotViz.file(
"", robot->getFilename());
116 tab.showRobotNodeFrames.setValue(
gui.showRobotNodeFrames);
117 root.
add(
Label(
"Show Robot Node Frames"), {row, 0})
118 .add(tab.showRobotNodeFrames, {row, 1});
121 tab.useCollisionModel.setValue(
gui.useCollisionModel);
122 root.
add(
Label(
"Use Collision Model"), {row, 0}).add(tab.useCollisionModel, {row, 1});
131 if (tab.showRobotNodeFrames.hasValueChanged())
133 std::scoped_lock lock(guiMutex);
134 gui.showRobotNodeFrames = tab.showRobotNodeFrames.getValue();
136 if (tab.useCollisionModel.hasValueChanged())
138 std::scoped_lock lock(guiMutex);
139 gui.useCollisionModel = tab.useCollisionModel.getValue();
144 RobotToArViz::updateRobotRun()
151 metronome.waitForNextTick();
156 RobotToArViz::updateRobotOnce()
162 std::scoped_lock lock(guiMutex);
166 std::vector<viz::Layer> layers;
168 robotViz.joints(robot->getConfig()->getRobotNodeJointValueMap())
169 .pose(robot->getGlobalPose());
171 if (gui.useCollisionModel)
173 robotViz.useCollisionModel();
177 robotViz.useFullModel();
180 viz::Layer& layerRobot = layers.emplace_back(
arviz.layer(robot->getName()));
181 layerRobot.
add(robotViz);
185 viz::Layer& layerFrames = layers.emplace_back(
arviz.layer(robot->getName() +
" Frames"));
186 if (gui.showRobotNodeFrames)
188 for (
const auto& node : robot->getRobotNodes())
190 layerFrames.
add(viz::Pose(node->getName()).pose(node->getGlobalPose()));
194 arviz.commit(layers);
198 RobotToArViz::trySetFilePathFromDataDir(
viz::Robot& robotViz,
const std::string& absolutePath)
201 std::filesystem::path filepath = absolutePath;
203 for (
auto it = filepath.begin(); it != filepath.end(); ++it)
209 std::filesystem::path localPath = *jt;
211 for (; jt != filepath.end(); ++jt)
217 std::string
package = *it;
219 robotViz.
file(package, localPath.string());
int Label(int n[], int size, int *curLabel, MiscLib::Vector< std::pair< int, size_t > > *labels)
armarx::viz::Client arviz
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Property< PropertyType > getProperty(const std::string &name)
static Frequency Hertz(std::int64_t hertz)
std::string getName() const
Retrieve name of object.
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
bool synchronizeLocalClone(const VirtualRobot::RobotPtr &robot) const
VirtualRobot::RobotPtr addRobot(const std::string &id, const VirtualRobot::RobotPtr &robot, const VirtualRobot::RobotNodeSetPtr &rns={}, const VirtualRobot::RobotNodePtr &node={})
bool hasRobot(const std::string &id) const
Property definitions of RobotToArViz.
RobotToArVizPropertyDefinitions(std::string prefix)
void onInitComponent() override
void onDisconnectComponent() override
void RemoteGui_update() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectComponent() override
void onExitComponent() override
void createRemoteGuiTab()
std::string getDefaultName() const override
bool isStopped()
Retrieve whether stop() has been called.
Simple rate limiter for use in loops to maintain a certain frequency given a clock.
Robot & file(std::string const &project, std::string const &filename)
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
SimpleRunningTask(Ts...) -> SimpleRunningTask< std::function< void(void)> >
void RemoteGui_startRunningTask()
void RemoteGui_createTab(std::string const &name, RemoteGui::Client::Widget const &rootWidget, RemoteGui::Client::Tab *tab)
GridLayout & add(Widget const &child, Pos pos, Span span=Span{1, 1})
void add(ElementT const &element)