ObjectInstanceToRobotNodeAttachments.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include <VirtualRobot/VirtualRobot.h>
6
7#include <RobotAPI/interface/core/RobotState.h>
8
9#include <MemoryX/interface/components/ObjectToRobotNodeAttachment.h>
10#include <MemoryX/interface/components/WorkingMemoryInterface.h>
13
14namespace memoryx
15{
16
17 /**
18 * @brief This class can be used to visualize object instances
19 * from working memory to ArViz.
20 */
22 {
23 public:
25
26 /// Set the proxies.
27 void initFromProxies(const WorkingMemoryInterfacePrx& workingMemory,
28 const armarx::RobotStateComponentInterfacePrx& robotStateComponent);
29
30
31 void attachObjectToRobotNode(const memoryx::AttachObjectToRobotNodeInput& attachment);
32 void detachObjectFromRobotNode(const memoryx::DetachObjectFromRobotNodeInput& detachment);
33
34 bool isObjectAttached(const std::string& id) const;
35
36 Eigen::Matrix4f getObjectPoseInFrame(ObjectInstancePtr object, const std::string& frame);
37
38
39 /// Get all entities from `objectInstanceSegment` and cast them to `ObjectInstance`.
40 std::vector<ObjectInstancePtr> queryObjects();
41
42 ObjectInstancePtr getMatchingObjectInstance(const memoryx::ObjectIdOrClass& object);
43 std::string getMatchingObjectID(const memoryx::ObjectIdOrClass& object);
44
45
46 private:
47 struct Attachment;
48
49 Eigen::Matrix4f getAttachedObjectPoseInFrame(const Attachment& attachment,
50 const std::string& frame);
51 Eigen::Matrix4f getDetachedObjectPoseInFrame(ObjectInstancePtr object,
52 const std::string& frame);
53
54
55 private:
58
59 ObjectInstanceMemorySegmentBasePrx objectInstanceSegment;
60
61 struct Attachment
62 {
63 std::string robotNode;
64 Eigen::Matrix4f initialPose = Eigen::Matrix4f::Identity();
65 Eigen::Matrix4f objectOffset = Eigen::Matrix4f::Identity();
66 };
67
68 /// Object instance ID to attachment.
69 std::map<std::string, Attachment> attachments;
70 std::map<std::string, std::pair<IceUtil::Time, armarx::FramedPose>> objectPoseCache;
71 };
72
73} // namespace memoryx
std::string getMatchingObjectID(const memoryx::ObjectIdOrClass &object)
void attachObjectToRobotNode(const memoryx::AttachObjectToRobotNodeInput &attachment)
void detachObjectFromRobotNode(const memoryx::DetachObjectFromRobotNodeInput &detachment)
std::vector< ObjectInstancePtr > queryObjects()
Get all entities from objectInstanceSegment and cast them to ObjectInstance.
ObjectInstancePtr getMatchingObjectInstance(const memoryx::ObjectIdOrClass &object)
void initFromProxies(const WorkingMemoryInterfacePrx &workingMemory, const armarx::RobotStateComponentInterfacePrx &robotStateComponent)
Set the proxies.
Eigen::Matrix4f getObjectPoseInFrame(ObjectInstancePtr object, const std::string &frame)
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
VirtualRobot headers.
IceInternal::Handle< ObjectInstance > ObjectInstancePtr