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
21namespace 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:
86
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
This class can be used to visualize object instances from working memory to ArViz.
std::optional< armarx::viz::Object > makeObject(const ObjectInstancePtr &object)
Make a armarx::viz::Object from a memoryx::ObjectInstance.
void initFromProxies(const PriorKnowledgeInterfacePrx &priorKnowledge, const WorkingMemoryInterfacePrx &workingMemory, const armarx::RobotStateComponentInterfacePrx &robotStateComponent, const std::vector< std::string > &datasets)
Set the proxies.
void updateObjectClassBlackWhitelist(const armarx::BlackWhitelistUpdate &update)
void attachObjectToRobotNode(const memoryx::AttachObjectToRobotNodeInput &attachment)
void detachObjectFromRobotNode(const memoryx::DetachObjectFromRobotNodeInput &detachment)
armarx::viz::Polygon makeFloorPolygon(const Eigen::Vector2f &extents={10000, 10000}, float height=0)
Make a polygon representing the floor.
void setArViz(armarx::viz::Client arviz)
Set the ArViz client.
armarx::viz::Object makeFloorObject(const std::string &name="Floor")
void updateFloorObject(float height=0)
Draw a the floor as a simox object.
void updateFloorPolygon(const Eigen::Vector2f &extents={10000, 10000}, float height=0)
Draw a the floor as a polygon.
void updateObjects()
Query object instances and update their visualization.
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
BlackWhitelist< std::string > StringBlackWhitelist
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
VirtualRobot headers.
IceInternal::Handle< ObjectInstance > ObjectInstancePtr