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