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