ObjectPose.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <optional>
4 #include <map>
5 #include <vector>
6 
7 #include <Eigen/Core>
8 
9 #include <SimoxUtility/shapes/OrientedBox.h>
10 
11 #include <VirtualRobot/VirtualRobot.h>
12 
15 
16 #include <RobotAPI/interface/objectpose/object_pose_types.h>
20 
21 
22 namespace armarx::objpose
23 {
24 
26  {
27  std::string frameName;
28  std::string agentName;
30  };
31 
32 
33  /**
34  * @brief An object pose as stored by the ObjectPoseStorage.
35  */
36  struct ObjectPose
37  {
38  public:
39 
40  ObjectPose();
41  ObjectPose(const data::ObjectPose& ice);
42 
43  void fromIce(const data::ObjectPose& ice);
44 
45  data::ObjectPose toIce() const;
46  void toIce(data::ObjectPose& ice) const;
47 
48  void fromProvidedPose(const data::ProvidedObjectPose& provided, VirtualRobot::RobotPtr robot = nullptr);
50 
51  void setObjectPoseRobot(const Eigen::Matrix4f& objectPoseRobot, bool updateObjectPoseGlobal = true);
52  void setObjectPoseGlobal(const Eigen::Matrix4f& objectPoseGlobal, bool updateObjectPoseRobot = true);
53 
54 
55  public:
56 
57  /// The object ID, i.e. dataset, class name and instance name.
59 
60  /// Name of the providing component.
61  std::string providerName;
62  /// Known or unknown object.
63  ObjectType objectType = AnyObject;
64  /// Whether object is static. Static objects don't decay.
65  bool isStatic = false;
66 
67  /// The object pose in the robot root frame.
69  /// ... and with uncertainty.
70  std::optional<PoseManifoldGaussian> objectPoseRobotGaussian;
71 
72  /// The object pose in the global frame.
74  /// ... and with uncertainty.
75  std::optional<PoseManifoldGaussian> objectPoseGlobalGaussian;
76 
77  /// The object pose in the frame it was originally localized in.
79  /// The frame the object was originally localized in.
81  /// ... and with uncertainty.
82  std::optional<PoseManifoldGaussian> objectPoseOriginalGaussian;
83 
84  /// The object's joint values if it is articulated.
85  std::map<std::string, float> objectJointValues;
86 
87  /// The robot config when the object was observed.
88  std::map<std::string, float> robotConfig;
89  /// The robot pose when the object was observed.
91  /// The name of the robot.
92  std::string robotName;
93 
94  /// Attachment information.
95  std::optional<ObjectAttachmentInfo> attachment;
96 
97  /// Confidence in [0, 1] (1 = full, 0 = none).
98  float confidence = 0;
99  /// Source timestamp.
101 
102  /// Object bounding box in object's local coordinate frame.
103  /// @see oobbRobot(), oobbGlobal()
104  std::optional<simox::OrientedBoxf> localOOBB;
105 
106 
107  /// Get the OOBB in the robot frame (according to `objectPoseRobot`).
108  std::optional<simox::OrientedBoxf> oobbRobot() const;
109  /// Get the OOBB in the global frame (according to `objectPoseGlobal`).
110  std::optional<simox::OrientedBoxf> oobbGlobal() const;
111 
112  /**
113  * @brief Get a copy of `*this` with updated attachment.
114  * @see `updateAttached()`
115  */
117  /**
118  * @brief Update an the object pose and robot state of an attached
119  * object pose according to the given agent state (in-place).
120  * @param agent The agent/robot.
121  */
123 
124 
125  std::optional<PackagePath> articulatedSimoxXmlPath;
126 
127  };
128 
129 
130  void fromIce(const data::ObjectAttachmentInfo& ice, ObjectAttachmentInfo& attachment);
131  void fromIce(const data::ObjectAttachmentInfoPtr& ice, std::optional<ObjectAttachmentInfo>& attachment);
132  std::optional<ObjectAttachmentInfo> fromIce(const data::ObjectAttachmentInfoPtr& ice);
133 
134  void fromIce(const data::ObjectPose& ice, ObjectPose& pose);
135  ObjectPose fromIce(const data::ObjectPose& ice);
136 
137  void fromIce(const data::ObjectPoseSeq& ice, ObjectPoseSeq& poses);
139 
140 
141  void toIce(data::ObjectAttachmentInfo& ice, const ObjectAttachmentInfo& attachment);
142  void toIce(data::ObjectAttachmentInfoPtr& ice, const std::optional<ObjectAttachmentInfo>& attachment);
143  data::ObjectAttachmentInfoPtr toIce(const std::optional<ObjectAttachmentInfo>& ice);
144 
145  void toIce(data::ObjectPose& ice, const ObjectPose& pose);
146  data::ObjectPose toIce(const ObjectPose& pose);
147 
148  void toIce(data::ObjectPoseSeq& ice, const ObjectPoseSeq& poses);
150 
151 
152  // Operations on ObjectPoseSeq
153 
154  /**
155  * @brief Find an object pose by the object ID. Return nullptr if not found.
156  * @param objectPoses The object poses.
157  * @param id The object ID.
158  * @return A pointer to the (first) object pose with objectID == id, or nullptr if none is found.
159  */
160  ObjectPose* findObjectPoseByID(ObjectPoseSeq& objectPoses, const ObjectID& id);
161  const ObjectPose* findObjectPoseByID(const ObjectPoseSeq& objectPoses, const ObjectID& id);
162 
163  data::ObjectPose* findObjectPoseByID(data::ObjectPoseSeq& objectPoses, const armarx::data::ObjectID& id);
164  const data::ObjectPose* findObjectPoseByID(const data::ObjectPoseSeq& objectPoses, const armarx::data::ObjectID& id);
165 
166 }
armarx::objpose::ObjectPose::getAttached
objpose::ObjectPose getAttached(VirtualRobot::RobotPtr agent) const
Get a copy of *this with updated attachment.
Definition: ObjectPose.cpp:239
armarx::ObjectID
A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
Definition: ObjectID.h:11
armarx::objpose::ObjectPoseSeq
std::vector< ObjectPose > ObjectPoseSeq
Definition: forward_declarations.h:20
armarx::objpose::ObjectPose::objectType
ObjectType objectType
Known or unknown object.
Definition: ObjectPose.h:63
armarx::objpose::ObjectPose::fromIce
void fromIce(const data::ObjectPose &ice)
Definition: ObjectPose.cpp:31
armarx::armem::attachment::ObjectID
armem::MemoryID ObjectID
Definition: types.h:79
DateTime.h
armarx::objpose::ObjectPose::robotName
std::string robotName
The name of the robot.
Definition: ObjectPose.h:92
armarx::objpose::ObjectPose::localOOBB
std::optional< simox::OrientedBoxf > localOOBB
Object bounding box in object's local coordinate frame.
Definition: ObjectPose.h:104
armarx::objpose::fromIce
void fromIce(const Box &box, simox::OrientedBox< float > &oobb)
armarx::objpose::ObjectPose::oobbRobot
std::optional< simox::OrientedBoxf > oobbRobot() const
Get the OOBB in the robot frame (according to objectPoseRobot).
Definition: ObjectPose.cpp:221
armarx::objpose::ObjectPose::providerName
std::string providerName
Name of the providing component.
Definition: ObjectPose.h:61
armarx::objpose::ObjectAttachmentInfo::agentName
std::string agentName
Definition: ObjectPose.h:28
armarx::objpose::findObjectPoseByID
ObjectPose * findObjectPoseByID(ObjectPoseSeq &objectPoses, const ObjectID &id)
Find an object pose by the object ID.
Definition: ObjectPose.cpp:388
armarx::objpose::ObjectAttachmentInfo::frameName
std::string frameName
Definition: ObjectPose.h:27
armarx::objpose::ObjectPose::fromProvidedPose
void fromProvidedPose(const data::ProvidedObjectPose &provided, VirtualRobot::RobotPtr robot=nullptr)
Definition: ObjectPose.cpp:102
armarx::objpose::ObjectPose::objectPoseOriginalGaussian
std::optional< PoseManifoldGaussian > objectPoseOriginalGaussian
... and with uncertainty.
Definition: ObjectPose.h:82
armarx::objpose::ObjectPose::ObjectPose
ObjectPose()
Definition: ObjectPose.cpp:22
armarx::objpose::ObjectPose::setObjectPoseGlobal
void setObjectPoseGlobal(const Eigen::Matrix4f &objectPoseGlobal, bool updateObjectPoseRobot=true)
Definition: ObjectPose.cpp:210
armarx::objpose::ObjectPose::toIce
data::ObjectPose toIce() const
Definition: ObjectPose.cpp:63
armarx::objpose::ObjectPose::oobbGlobal
std::optional< simox::OrientedBoxf > oobbGlobal() const
Get the OOBB in the global frame (according to objectPoseGlobal).
Definition: ObjectPose.cpp:230
armarx::objpose::ObjectPose::isStatic
bool isStatic
Whether object is static. Static objects don't decay.
Definition: ObjectPose.h:65
GfxTL::Identity
void Identity(MatrixXX< N, N, T > *a)
Definition: MatrixXX.h:523
armarx::objpose::ObjectPose::objectPoseRobotGaussian
std::optional< PoseManifoldGaussian > objectPoseRobotGaussian
... and with uncertainty.
Definition: ObjectPose.h:70
armarx::objpose::ObjectPose::objectPoseOriginalFrame
std::string objectPoseOriginalFrame
The frame the object was originally localized in.
Definition: ObjectPose.h:80
armarx::objpose::ObjectPose::robotPose
Eigen::Matrix4f robotPose
The robot pose when the object was observed.
Definition: ObjectPose.h:90
armarx::objpose::ObjectAttachmentInfo::poseInFrame
Eigen::Matrix4f poseInFrame
Definition: ObjectPose.h:29
armarx::objpose
This file is part of ArmarX.
Definition: objpose.h:7
ObjectID.h
armarx::objpose::ObjectPose::toProvidedObjectPoseGlobal
objpose::ProvidedObjectPose toProvidedObjectPoseGlobal() const
Definition: ObjectPose.cpp:176
PoseManifoldGaussian.h
armarx::objpose::ObjectPose::robotConfig
std::map< std::string, float > robotConfig
The robot config when the object was observed.
Definition: ObjectPose.h:88
armarx::objpose::ObjectPose::setObjectPoseRobot
void setObjectPoseRobot(const Eigen::Matrix4f &objectPoseRobot, bool updateObjectPoseGlobal=true)
Definition: ObjectPose.cpp:200
armarx::objpose::ProvidedObjectPose
An object pose provided by an ObjectPoseProvider.
Definition: ProvidedObjectPose.h:25
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::objpose::ObjectPose::updateAttached
void updateAttached(VirtualRobot::RobotPtr agent)
Update an the object pose and robot state of an attached object pose according to the given agent sta...
Definition: ObjectPose.cpp:248
armarx::objpose::toIce
objpose::AABB toIce(const simox::AxisAlignedBoundingBox &aabb)
Definition: ice_conversions.cpp:94
forward_declarations.h
armarx::objpose::ObjectPose::objectID
armarx::ObjectID objectID
The object ID, i.e. dataset, class name and instance name.
Definition: ObjectPose.h:58
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::objpose::ObjectPose::objectPoseGlobal
Eigen::Matrix4f objectPoseGlobal
The object pose in the global frame.
Definition: ObjectPose.h:73
armarx::objpose::ObjectPose::attachment
std::optional< ObjectAttachmentInfo > attachment
Attachment information.
Definition: ObjectPose.h:95
armarx::objpose::ObjectPose::objectPoseOriginal
Eigen::Matrix4f objectPoseOriginal
The object pose in the frame it was originally localized in.
Definition: ObjectPose.h:78
armarx::objpose::ObjectPose::objectPoseRobot
Eigen::Matrix4f objectPoseRobot
The object pose in the robot root frame.
Definition: ObjectPose.h:68
armarx::objpose::ObjectAttachmentInfo
Definition: ObjectPose.h:25
armarx::objpose::ObjectPose::articulatedSimoxXmlPath
std::optional< PackagePath > articulatedSimoxXmlPath
Definition: ObjectPose.h:125
armarx::objpose::ObjectPose::objectJointValues
std::map< std::string, float > objectJointValues
The object's joint values if it is articulated.
Definition: ObjectPose.h:85
armarx::objpose::ObjectPose::confidence
float confidence
Confidence in [0, 1] (1 = full, 0 = none).
Definition: ObjectPose.h:98
armarx::core::time::DateTime::Invalid
static DateTime Invalid()
Definition: DateTime.cpp:60
armarx::objpose::ObjectPose
An object pose as stored by the ObjectPoseStorage.
Definition: ObjectPose.h:36
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::objpose::ObjectPose::timestamp
DateTime timestamp
Source timestamp.
Definition: ObjectPose.h:100
armarx::objpose::ObjectPose::objectPoseGlobalGaussian
std::optional< PoseManifoldGaussian > objectPoseGlobalGaussian
... and with uncertainty.
Definition: ObjectPose.h:75
PackagePath.h