ObjectInstancesToArViz.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <set>
4 #include <vector>
5 
6 #include <VirtualRobot/VirtualRobot.h>
7 
10 #include <RobotAPI/interface/core/RobotState.h>
11 
12 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
13 #include <MemoryX/interface/components/WorkingMemoryToArVizInterface.h>
17 
18 // Todo: Move somewhere else
20 
21 namespace memoryx
22 {
23 
24  /**
25  * @brief This class can be used to visualize object instances
26  * from working memory to ArViz.
27  */
29  {
30  public:
32 
33  /// Set the ArViz client.
34  void setArViz(armarx::viz::Client arviz);
35  /// Set the proxies.
36  void initFromProxies(const PriorKnowledgeInterfacePrx& priorKnowledge,
37  const WorkingMemoryInterfacePrx& workingMemory,
38  const armarx::RobotStateComponentInterfacePrx& robotStateComponent,
39  const std::vector<std::string>& datasets);
40 
41 
42  /// Draw a the floor as a polygon.
43  /// @see `makeFloorPolygon()`
44  void updateFloorPolygon(const Eigen::Vector2f& extents = {10000, 10000}, float height = 0);
45  /// Draw a the floor as a simox object.
46  /// @see `makeFloorObject()`
47  void updateFloorObject(float height = 0);
48 
49 
50  /// Query object instances and update their visualization.
51  void updateObjects();
52  /// Update the object instances' visualizations.
53  void updateObjects(const std::vector<ObjectInstancePtr>& objectInstances);
54 
55  /// Make a polygon representing the floor.
56  armarx::viz::Polygon makeFloorPolygon(const Eigen::Vector2f& extents = {10000, 10000},
57  float height = 0);
58 
59  armarx::viz::Object makeFloorObject(const std::string& name = "Floor");
60  std::string getFloorObjectFile();
61 
62  /// Make a `armarx::viz::Object` from a `memoryx::ObjectInstance`.
63  std::optional<armarx::viz::Object> makeObject(const ObjectInstancePtr& object);
64 
65 
66  void updateObjectClassBlackWhitelist(const armarx::BlackWhitelistUpdate& update);
67 
68  void attachObjectToRobotNode(const memoryx::AttachObjectToRobotNodeInput& attachment);
69 
70  void detachObjectFromRobotNode(const memoryx::DetachObjectFromRobotNodeInput& detachment);
71 
72 
73  public:
74  std::string layerNameFloor = "Floor";
75  std::string layerNameObjects = "ObjectInstances";
76 
77  std::string floorObjectFilename = "images/Floor20x20.xml"; // In VirtualRobot/data
78 
79 
80  private:
81  std::string getClassFilename(const std::string& className);
82 
83 
84  private:
85  armarx::viz::Client arviz;
86 
87  armarx::RobotStateComponentInterfacePrx robotStateComponent;
89 
90  ObjectInstanceMemorySegmentBasePrx objectInstanceSegment;
91  ObjectClassSegmentWrapper objectClassSegment;
92 
93  /// Caches [class name -> filename] entries.
94  std::map<std::string, std::string> classFilenameCache;
95 
96 
97  armarx::StringBlackWhitelist objectClassBlackWhitelist;
98 
100  };
101 
102 } // namespace memoryx
memoryx::ObjectInstancesToArViz::setArViz
void setArViz(armarx::viz::Client arviz)
Set the ArViz client.
Definition: ObjectInstancesToArViz.cpp:18
Client.h
ObjectClassSegmentWrapper.h
memoryx::ObjectInstancesToArViz::makeFloorPolygon
armarx::viz::Polygon makeFloorPolygon(const Eigen::Vector2f &extents={10000, 10000}, float height=0)
Make a polygon representing the floor.
Definition: ObjectInstancesToArViz.cpp:87
memoryx::ObjectInstancesToArViz::updateFloorPolygon
void updateFloorPolygon(const Eigen::Vector2f &extents={10000, 10000}, float height=0)
Draw a the floor as a polygon.
Definition: ObjectInstancesToArViz.cpp:45
memoryx::ObjectInstancesToArViz::attachObjectToRobotNode
void attachObjectToRobotNode(const memoryx::AttachObjectToRobotNodeInput &attachment)
Definition: ObjectInstancesToArViz.cpp:179
memoryx::ObjectClassSegmentWrapper
Definition: ObjectClassSegmentWrapper.h:22
memoryx::ObjectInstancesToArViz::floorObjectFilename
std::string floorObjectFilename
Definition: ObjectInstancesToArViz.h:77
memoryx::ObjectInstancesToArViz::updateFloorObject
void updateFloorObject(float height=0)
Draw a the floor as a simox object.
Definition: ObjectInstancesToArViz.cpp:52
memoryx
VirtualRobot headers.
Definition: CommonPlacesTester.cpp:48
ObjectInstanceToRobotNodeAttachments.h
BlackWhitelist.h
memoryx::ObjectInstancesToArViz::ObjectInstancesToArViz
ObjectInstancesToArViz()
Definition: ObjectInstancesToArViz.cpp:13
memoryx::ObjectInstancesToArViz::getFloorObjectFile
std::string getFloorObjectFile()
Definition: ObjectInstancesToArViz.cpp:103
memoryx::ObjectInstancesToArViz::initFromProxies
void initFromProxies(const PriorKnowledgeInterfacePrx &priorKnowledge, const WorkingMemoryInterfacePrx &workingMemory, const armarx::RobotStateComponentInterfacePrx &robotStateComponent, const std::vector< std::string > &datasets)
Set the proxies.
Definition: ObjectInstancesToArViz.cpp:24
IceInternal::Handle< ObjectInstance >
memoryx::ObjectInstancesToArViz
This class can be used to visualize object instances from working memory to ArViz.
Definition: ObjectInstancesToArViz.h:28
armarx::viz::Object
Definition: Elements.h:332
memoryx::ObjectInstancesToArViz::makeFloorObject
armarx::viz::Object makeFloorObject(const std::string &name="Floor")
Definition: ObjectInstancesToArViz.cpp:96
memoryx::ObjectInstancesToArViz::detachObjectFromRobotNode
void detachObjectFromRobotNode(const memoryx::DetachObjectFromRobotNodeInput &detachment)
Definition: ObjectInstancesToArViz.cpp:186
armarx::viz::Polygon
Definition: Elements.h:260
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:68
armarx::BlackWhitelist< std::string >
BlackWhitelistUpdate.h
ObjectInstance.h
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
memoryx::ObjectInstancesToArViz::layerNameFloor
std::string layerNameFloor
Definition: ObjectInstancesToArViz.h:74
memoryx::ObjectInstancesToArViz::updateObjectClassBlackWhitelist
void updateObjectClassBlackWhitelist(const armarx::BlackWhitelistUpdate &update)
Definition: ObjectInstancesToArViz.cpp:170
memoryx::ObjectInstancesToArViz::layerNameObjects
std::string layerNameObjects
Definition: ObjectInstancesToArViz.h:75
armarx::viz::Client
Definition: Client.h:117
memoryx::ObjectInstancesToArViz::updateObjects
void updateObjects()
Query object instances and update their visualization.
Definition: ObjectInstancesToArViz.cpp:60
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19
memoryx::ObjectInstancesToArViz::makeObject
std::optional< armarx::viz::Object > makeObject(const ObjectInstancePtr &object)
Make a armarx::viz::Object from a memoryx::ObjectInstance.
Definition: ObjectInstancesToArViz.cpp:112
memoryx::ObjectInstanceToRobotNodeAttachments
This class can be used to visualize object instances from working memory to ArViz.
Definition: ObjectInstanceToRobotNodeAttachments.h:21