ArticulatedObjectVisu.cpp
Go to the documentation of this file.
2 
3 #include <algorithm>
4 
5 #include <SimoxUtility/math/pose.h>
6 
11 
13 
14 #include "Segment.h"
15 
17 {
18 
20  const std::string& prefix)
21  {
22  defs->optional(
23  p.enabled, prefix + "enabled", "Enable or disable visualization of objects.");
24  defs->optional(p.frequencyHz, prefix + "frequenzyHz", "Frequency of visualization.");
25  }
26 
28  const std::string& providerName,
30  {
31  viz::Layer layer = arviz.layer(providerName);
32 
33  visualizeObjects(layer, objects);
34 
35  return layer;
36  }
37 
39  viz::Layer& layer,
41  {
42  const auto visualizeObject =
44  {
45  const auto xmlPath = obj.description.xml.serialize();
46 
47  // clang-format off
48  auto robot = viz::Robot(obj.description.name)
49  // .file(xmlPath.package, xmlPath.path)
50  .file(xmlPath.path, xmlPath.path)
51  .joints(obj.config.jointMap)
52  .pose(obj.config.globalPose);
53  // clang-format on
54 
55  robot.useFullModel();
56 
57  layer.add(robot);
58  };
59 
60  std::for_each(objects.begin(), objects.end(), visualizeObject);
61  }
62 
64  {
65  updateTask = new PeriodicTask<ArticulatedObjectVisu>(this, &ArticulatedObjectVisu::visualizeRun, 1000 / p.frequencyHz);
66 
67  ARMARX_INFO << "ArticulatedObjectVisu: init";
68  updateTask->start();
69  }
70 
71  void ArticulatedObjectVisu::visualizeRun()
72  {
73  // std::scoped_lock lock(visuMutex);
74  ARMARX_INFO << "Update task";
75 
76  // if (not p.enabled)
77  // {
78  // return;
79  // }
80 
81  // TIMING_START(Visu);
82 
83  const auto articulatedObjects = segment.getArticulatedObjects();
84  ARMARX_INFO << "Found " << articulatedObjects.size() << " articulated objects";
85 
86  viz::Layer layer = arviz.layer("ArticulatedObjectInstances");
87 
88  ARMARX_INFO << "visualizing objects";
90 
91  ARMARX_INFO << "Committing objects";
92  arviz.commit({layer});
93 
94  ARMARX_INFO << "Done committing";
95 
96  // TIMING_END_STREAM(Visu, ARMARX_VERBOSE);
97 
98  // if (debugObserver)
99  // {
100  // debugObserver->setDebugChannel(getName(),
101  // {
102  // { "t Visualize [ms]", new Variant(Visu.toMilliSecondsDouble()) },
103  // });
104  // }
105  }
106 
107  // void Visu::RemoteGui::setup(const Visu& visu)
108  // {
109  // using namespace armarx::RemoteGui::Client;
110 
111  // enabled.setValue(visu.enabled);
112  // inGlobalFrame.setValue(visu.inGlobalFrame);
113  // alpha.setRange(0, 1.0);
114  // alpha.setValue(visu.alpha);
115  // alphaByConfidence.setValue(visu.alphaByConfidence);
116  // oobbs.setValue(visu.oobbs);
117  // objectFrames.setValue(visu.objectFrames);
118  // {
119  // float max = 10000;
120  // objectFramesScale.setRange(0, max);
121  // objectFramesScale.setDecimals(2);
122  // objectFramesScale.setSteps(int(10 * max));
123  // objectFramesScale.setValue(visu.objectFramesScale);
124  // }
125 
126  // GridLayout grid;
127  // int row = 0;
128  // grid.add(Label("Enabled"), {row, 0}).add(enabled, {row, 1});
129  // row++;
130  // grid.add(Label("Global Frame"), {row, 0}).add(inGlobalFrame, {row, 1});
131  // row++;
132  // grid.add(Label("Alpha"), {row, 0}).add(alpha, {row, 1}, {1, 3});
133  // row++;
134  // grid.add(Label("Alpha by Confidence"), {row, 0}).add(alphaByConfidence, {row, 1});
135  // row++;
136  // grid.add(Label("OOBB"), {row, 0}).add(oobbs, {row, 1});
137  // row++;
138  // grid.add(Label("Object Frames"), {row, 0}).add(objectFrames, {row, 1});
139  // grid.add(Label("Scale:"), {row, 2}).add(objectFramesScale, {row, 3});
140  // row++;
141 
142  // group.setLabel("Visualization");
143  // group.addChild(grid);
144  // }
145 
146  // void Visu::RemoteGui::update(Visu& visu)
147  // {
148  // visu.enabled = enabled.getValue();
149  // visu.inGlobalFrame = inGlobalFrame.getValue();
150  // visu.alpha = alpha.getValue();
151  // visu.alphaByConfidence = alphaByConfidence.getValue();
152  // visu.oobbs = oobbs.getValue();
153  // visu.objectFrames = objectFrames.getValue();
154  // visu.objectFramesScale = objectFramesScale.getValue();
155  // }
156 
157 } // namespace armarx::armem::server::obj::instance
armarx::viz::Client::commit
CommitResult commit(StagedCommit const &commit)
Definition: Client.cpp:80
armarx::armem::server::obj::instance::ArticulatedObjectVisu::visualizeObjects
void visualizeObjects(viz::Layer &layer, const armarx::armem::articulated_object::ArticulatedObjects &objects) const
Definition: ArticulatedObjectVisu.cpp:38
armarx::armem::robot_state::Robot
Definition: types.h:126
armarx::armem::server::obj::instance::ArticulatedObjectVisu::defineProperties
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="visu.")
Definition: ArticulatedObjectVisu.cpp:19
Segment.h
PeriodicTask.h
armarx::viz::Layer::add
void add(ElementT const &element)
Definition: Layer.h:29
armarx::armem::server::obj::instance
Definition: ArticulatedObjectVisu.cpp:16
armarx::armem::server::obj::instance::ArticulatedObjectVisu::visualizeProvider
viz::Layer visualizeProvider(const std::string &providerName, const armarx::armem::articulated_object::ArticulatedObjects &objects) const
Definition: ArticulatedObjectVisu.cpp:27
armarx::armem::human::Robot
@ Robot
Definition: util.h:14
armarx::armem::server::obj::instance::ArticulatedObjectVisu::init
void init()
Definition: ArticulatedObjectVisu.cpp:63
armarx::navigation::util::articulatedObjects
objpose::ObjectPoseSeq articulatedObjects(objpose::ObjectPoseSeq objects)
Definition: util.cpp:95
armarx::armem::server::obj::instance::Segment::getArticulatedObjects
::armarx::armem::articulated_object::ArticulatedObjects getArticulatedObjects()
Definition: Segment.cpp:712
CycleUtil.h
armarx::armem::articulated_object::ArticulatedObjects
armarx::armem::robot_state::Robots ArticulatedObjects
Definition: types.h:141
TimeUtil.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::PeriodicTask
Definition: ArmarXManager.h:70
Logging.h
armarx::viz::Client::layer
Layer layer(std::string const &name) const
Definition: Client.cpp:73
armarx::viz::Layer
Definition: Layer.h:12
ArticulatedObjectVisu.h
ObjectFinder.h