FloorVis.cpp
Go to the documentation of this file.
1 #include "FloorVis.h"
2 
5 #include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h>
6 
8 
9 
11 {
12 
14  {
15  }
16 
17 
18  void FloorVis::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix)
19  {
20  properties.define(defs, prefix);
21  }
22 
23 
25  {
26  this->arviz = arviz;
27  }
28 
29 
30  void FloorVis::updateFloorObject(const wm::CoreSegment& classCoreSegment)
31  {
32  viz::Layer layer = arviz.layer(properties.layerName);
33  if (properties.show)
34  {
35  const wm::Entity* entity = classCoreSegment.findEntity(properties.entityName);
36  if (entity)
37  {
38  ARMARX_INFO << "Drawing floor class '" << properties.entityName << "'.";
39  layer.add(makeFloorObject(*entity));
40  }
41  else
42  {
43  ARMARX_INFO << "Did not find floor class '" << properties.entityName << "'.";
44  }
45  }
46  arviz.commit({layer});
47  }
48 
49 
51  {
52  const wm::EntityInstance& instance = classEntity.getLatestSnapshot().getInstance(0);
53  arondto::ObjectClass data;
54  data.fromAron(instance.data());
55  return makeFloorObject(classEntity.name(), data);
56  }
57 
58 
60  const std::string& name,
61  const arondto::ObjectClass& objectClass)
62  {
64  return armarx::viz::Object(name)
65  .file(objectClass.simoxXmlPath.package, objectClass.simoxXmlPath.path)
66  .position(Eigen::Vector3f(0, 0, properties.height));
67  }
68 
69 
70  void FloorVis::Properties::define(armarx::PropertyDefinitionsPtr defs, const std::string& prefix)
71  {
72  defs->optional(show, prefix + "Show", "Whether to show the floor.");
73  defs->optional(entityName, prefix + "EntityName", "Object class entity of the floor.");
74  defs->optional(layerName, prefix + "LayerName", "Layer to draw the floor on.");
75  defs->optional(height, prefix + "Height",
76  "Height (z) of the floor plane. \n"
77  "Set slightly below 0 to avoid z-fighting when drawing planes on the ground.");
78  }
79 
80 }
81 
82 
armarx::viz::Client::commit
CommitResult commit(StagedCommit const &commit)
Definition: Client.cpp:80
armarx::armem::base::CoreSegmentBase::findEntity
EntityT * findEntity(const std::string &entityName)
Definition: CoreSegmentBase.h:199
armarx::armem::server::obj::clazz::FloorVis::Properties::entityName
std::string entityName
Definition: FloorVis.h:44
armarx::armem::server::obj::clazz::FloorVis::defineProperties
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="")
Definition: FloorVis.cpp:18
armarx::armem::server::obj::clazz
Definition: FloorVis.cpp:10
armarx::armem::wm::EntityInstance
Client-side working entity instance.
Definition: memory_definitions.h:32
armarx::armem::base::detail::GetLatestSnapshotMixin::getLatestSnapshot
auto & getLatestSnapshot(int snapshotIndex=0)
Retrieve the latest entity snapshot.
Definition: lookup_mixins.h:199
armarx::viz::Object::file
Object & file(std::string const &project, std::string const &filename)
Definition: Elements.h:328
armarx::armem::server::obj::clazz::FloorVis::Properties::layerName
std::string layerName
Definition: FloorVis.h:45
armarx::armem::server::obj::clazz::FloorVis::setArViz
void setArViz(armarx::viz::Client arviz)
Definition: FloorVis.cpp:24
armarx::armem::server::obj::clazz::FloorVis::Properties::define
void define(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="")
Definition: FloorVis.cpp:70
armarx::viz::Layer::add
void add(ElementT const &element)
Definition: Layer.h:29
armarx::armem::server::wm::Entity
Definition: memory_definitions.h:30
armarx::viz::ElementOps::position
DerivedT & position(float x, float y, float z)
Definition: ElementOps.h:127
memory_definitions.h
ARMARX_TRACE
#define ARMARX_TRACE
Definition: trace.h:69
armarx::viz::Object
Definition: Elements.h:321
data
uint8_t data[1]
Definition: EtherCATFrame.h:68
armarx::armem::server::obj::clazz::FloorVis::Properties::show
bool show
Definition: FloorVis.h:42
memory_definitions.h
armarx::armem::server::wm::CoreSegment
base::CoreSegmentBase
Definition: memory_definitions.h:86
armarx::armem::server::obj::clazz::FloorVis::FloorVis
FloorVis()
Definition: FloorVis.cpp:13
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
PropertyDefinitionContainer.h
IceUtil::Handle< class PropertyDefinitionContainer >
FloorVis.h
armarx::armem::server::obj::clazz::FloorVis::makeFloorObject
armarx::viz::Object makeFloorObject(const wm::Entity &classEntity)
Definition: FloorVis.cpp:50
armarx::armem::server::obj::clazz::FloorVis::updateFloorObject
void updateFloorObject(const wm::CoreSegment &classCoreSegment)
Draw a the floor as a simox object.
Definition: FloorVis.cpp:30
armarx::viz::Client::layer
Layer layer(std::string const &name) const
Definition: Client.cpp:73
armarx::armem::base::EntityInstanceBase::data
const DataT & data() const
Definition: EntityInstanceBase.h:129
armarx::viz::Client
Definition: Client.h:109
armarx::viz::Layer
Definition: Layer.h:12
armarx::armem::server::obj::clazz::FloorVis::Properties::height
float height
Definition: FloorVis.h:46
armarx::armem::base::EntityBase::name
std::string & name()
Definition: EntityBase.h:93