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 
8 #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 
22 namespace memoryx
23 {
24 
25  /**
26  * @brief This class can be used to visualize object instances
27  * from working memory to ArViz.
28  */
30  {
31  public:
32 
34 
35  /// Set the ArViz client.
36  void setArViz(armarx::viz::Client arviz);
37  /// Set the proxies.
38  void initFromProxies(const PriorKnowledgeInterfacePrx& priorKnowledge,
39  const WorkingMemoryInterfacePrx& workingMemory,
40  const armarx::RobotStateComponentInterfacePrx& robotStateComponent,
41  const std::vector<std::string>& datasets);
42 
43 
44  /// Draw a the floor as a polygon.
45  /// @see `makeFloorPolygon()`
46  void updateFloorPolygon(const Eigen::Vector2f& extents = { 10000, 10000 }, float height = 0);
47  /// Draw a the floor as a simox object.
48  /// @see `makeFloorObject()`
49  void updateFloorObject(float height = 0);
50 
51 
52  /// Query object instances and update their visualization.
53  void updateObjects();
54  /// Update the object instances' visualizations.
55  void updateObjects(const std::vector<ObjectInstancePtr>& objectInstances);
56 
57  /// Make a polygon representing the floor.
58  armarx::viz::Polygon makeFloorPolygon(const Eigen::Vector2f& extents = { 10000, 10000 }, float height = 0);
59 
60  armarx::viz::Object makeFloorObject(const std::string& name = "Floor");
61  std::string getFloorObjectFile();
62 
63  /// Make a `armarx::viz::Object` from a `memoryx::ObjectInstance`.
64  std::optional<armarx::viz::Object> makeObject(const ObjectInstancePtr& object);
65 
66 
67  void updateObjectClassBlackWhitelist(const armarx::BlackWhitelistUpdate& update);
68 
69  void attachObjectToRobotNode(const memoryx::AttachObjectToRobotNodeInput& attachment);
70 
71  void detachObjectFromRobotNode(const memoryx::DetachObjectFromRobotNodeInput& detachment);
72 
73 
74  public:
75 
76  std::string layerNameFloor = "Floor";
77  std::string layerNameObjects = "ObjectInstances";
78 
79  std::string floorObjectFilename = "images/Floor20x20.xml"; // In VirtualRobot/data
80 
81 
82  private:
83 
84  std::string getClassFilename(const std::string& className);
85 
86 
87  private:
88 
89  armarx::viz::Client arviz;
90 
91  armarx::RobotStateComponentInterfacePrx robotStateComponent;
93 
94  ObjectInstanceMemorySegmentBasePrx objectInstanceSegment;
95  ObjectClassSegmentWrapper objectClassSegment;
96 
97  /// Caches [class name -> filename] entries.
98  std::map<std::string, std::string> classFilenameCache;
99 
100 
101  armarx::StringBlackWhitelist objectClassBlackWhitelist;
102 
104 
105  };
106 
107 }
108 
memoryx::ObjectInstancesToArViz::setArViz
void setArViz(armarx::viz::Client arviz)
Set the ArViz client.
Definition: ObjectInstancesToArViz.cpp:19
Client.h
ObjectClassSegmentWrapper.h
memoryx::ObjectInstancesToArViz::attachObjectToRobotNode
void attachObjectToRobotNode(const memoryx::AttachObjectToRobotNodeInput &attachment)
Definition: ObjectInstancesToArViz.cpp:177
memoryx::ObjectClassSegmentWrapper
Definition: ObjectClassSegmentWrapper.h:23
memoryx::ObjectInstancesToArViz::floorObjectFilename
std::string floorObjectFilename
Definition: ObjectInstancesToArViz.h:79
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:14
memoryx::ObjectInstancesToArViz::getFloorObjectFile
std::string getFloorObjectFile()
Definition: ObjectInstancesToArViz.cpp:101
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:25
IceInternal::Handle< ObjectInstance >
memoryx::ObjectInstancesToArViz
This class can be used to visualize object instances from working memory to ArViz.
Definition: ObjectInstancesToArViz.h:29
armarx::viz::Object
Definition: Elements.h:321
memoryx::ObjectInstancesToArViz::makeFloorObject
armarx::viz::Object makeFloorObject(const std::string &name="Floor")
Definition: ObjectInstancesToArViz.cpp:94
memoryx::ObjectInstancesToArViz::detachObjectFromRobotNode
void detachObjectFromRobotNode(const memoryx::DetachObjectFromRobotNodeInput &detachment)
Definition: ObjectInstancesToArViz.cpp:183
armarx::viz::Polygon
Definition: Elements.h:258
armarx::armem::server::ltm::util::mongodb::detail::update
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
Definition: mongodb.cpp:67
armarx::BlackWhitelist< std::string >
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:85
BlackWhitelistUpdate.h
ObjectInstance.h
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
memoryx::ObjectInstancesToArViz::layerNameFloor
std::string layerNameFloor
Definition: ObjectInstancesToArViz.h:76
memoryx::ObjectInstancesToArViz::updateObjectClassBlackWhitelist
void updateObjectClassBlackWhitelist(const armarx::BlackWhitelistUpdate &update)
Definition: ObjectInstancesToArViz.cpp:169
memoryx::ObjectInstancesToArViz::layerNameObjects
std::string layerNameObjects
Definition: ObjectInstancesToArViz.h:77
memoryx::ObjectInstancesToArViz::updateFloorPolygon
void updateFloorPolygon(const Eigen::Vector2f &extents={ 10000, 10000 }, float height=0)
Draw a the floor as a polygon.
Definition: ObjectInstancesToArViz.cpp:46
armarx::viz::Client
Definition: Client.h:109
memoryx::ObjectInstancesToArViz::updateObjects
void updateObjects()
Query object instances and update their visualization.
Definition: ObjectInstancesToArViz.cpp:59
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
memoryx::ObjectInstancesToArViz::makeObject
std::optional< armarx::viz::Object > makeObject(const ObjectInstancePtr &object)
Make a armarx::viz::Object from a memoryx::ObjectInstance.
Definition: ObjectInstancesToArViz.cpp:110
memoryx::ObjectInstanceToRobotNodeAttachments
This class can be used to visualize object instances from working memory to ArViz.
Definition: ObjectInstanceToRobotNodeAttachments.h:23