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
20namespace armarx::objpose
21{
22
24 {
25 std::string frameName;
26 std::string agentName;
27 Eigen::Matrix4f poseInFrame = Eigen::Matrix4f::Identity();
28 };
29
30 /**
31 * @brief An object pose as stored by the ObjectPoseStorage.
32 */
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
48 void setObjectPoseRobot(const Eigen::Matrix4f& objectPoseRobot,
49 bool updateObjectPoseGlobal = true);
50 void setObjectPoseGlobal(const Eigen::Matrix4f& objectPoseGlobal,
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.
66 Eigen::Matrix4f objectPoseRobot = Eigen::Matrix4f::Identity();
67 /// ... and with uncertainty.
68 std::optional<PoseManifoldGaussian> objectPoseRobotGaussian;
69
70 /// The object pose in the global frame.
71 Eigen::Matrix4f objectPoseGlobal = Eigen::Matrix4f::Identity();
72 /// ... and with uncertainty.
73 std::optional<PoseManifoldGaussian> objectPoseGlobalGaussian;
74
75 /// The object pose in the frame it was originally localized in.
76 Eigen::Matrix4f objectPoseOriginal = Eigen::Matrix4f::Identity();
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.
88 Eigen::Matrix4f robotPose = Eigen::Matrix4f::Identity();
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);
135 ObjectPoseSeq fromIce(const data::ObjectPoseSeq& ice);
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);
147 data::ObjectPoseSeq toIce(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
static DateTime Invalid()
Definition DateTime.cpp:57
A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
Definition ObjectID.h:11
Represents a point in time.
Definition DateTime.h:25
An object pose provided by an ObjectPoseProvider.
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
ObjectPose * findObjectPoseByID(ObjectPoseSeq &objectPoses, const ObjectID &id)
Find an object pose by the object ID.
std::vector< ObjectPose > ObjectPoseSeq
void fromIce(const Box &box, simox::OrientedBox< float > &oobb)
objpose::AABB toIce(const simox::AxisAlignedBoundingBox &aabb)
An object pose as stored by the ObjectPoseStorage.
Definition ObjectPose.h:34
float confidence
Confidence in [0, 1] (1 = full, 0 = none).
Definition ObjectPose.h:96
armarx::ObjectID objectID
The object ID, i.e. dataset, class name and instance name.
Definition ObjectPose.h:56
objpose::ObjectPose getAttached(VirtualRobot::RobotPtr agent) const
Get a copy of *this with updated attachment.
std::optional< ObjectAttachmentInfo > attachment
Attachment information.
Definition ObjectPose.h:93
std::map< std::string, float > robotConfig
The robot config when the object was observed.
Definition ObjectPose.h:86
std::optional< PackagePath > articulatedSimoxXmlPath
Definition ObjectPose.h:123
std::string providerName
Name of the providing component.
Definition ObjectPose.h:59
void fromProvidedPose(const data::ProvidedObjectPose &provided, VirtualRobot::RobotPtr robot=nullptr)
data::ObjectPose toIce() const
void setObjectPoseGlobal(const Eigen::Matrix4f &objectPoseGlobal, bool updateObjectPoseRobot=true)
bool isStatic
Whether object is static. Static objects don't decay.
Definition ObjectPose.h:63
void updateAttached(VirtualRobot::RobotPtr agent)
Update an the object pose and robot state of an attached object pose according to the given agent sta...
std::optional< simox::OrientedBoxf > oobbRobot() const
Get the OOBB in the robot frame (according to objectPoseRobot).
DateTime timestamp
Source timestamp.
Definition ObjectPose.h:98
Eigen::Matrix4f objectPoseRobot
The object pose in the robot root frame.
Definition ObjectPose.h:66
Eigen::Matrix4f robotPose
The robot pose when the object was observed.
Definition ObjectPose.h:88
Eigen::Matrix4f objectPoseOriginal
The object pose in the frame it was originally localized in.
Definition ObjectPose.h:76
ObjectType objectType
Known or unknown object.
Definition ObjectPose.h:61
std::optional< PoseManifoldGaussian > objectPoseGlobalGaussian
... and with uncertainty.
Definition ObjectPose.h:73
void setObjectPoseRobot(const Eigen::Matrix4f &objectPoseRobot, bool updateObjectPoseGlobal=true)
std::map< std::string, float > objectJointValues
The object's joint values if it is articulated.
Definition ObjectPose.h:83
std::optional< simox::OrientedBoxf > localOOBB
Object bounding box in object's local coordinate frame.
Definition ObjectPose.h:102
void fromIce(const data::ObjectPose &ice)
std::optional< simox::OrientedBoxf > oobbGlobal() const
Get the OOBB in the global frame (according to objectPoseGlobal).
std::optional< PoseManifoldGaussian > objectPoseOriginalGaussian
... and with uncertainty.
Definition ObjectPose.h:80
objpose::ProvidedObjectPose toProvidedObjectPoseGlobal() const
Eigen::Matrix4f objectPoseGlobal
The object pose in the global frame.
Definition ObjectPose.h:71
std::string robotName
The name of the robot.
Definition ObjectPose.h:90
std::optional< PoseManifoldGaussian > objectPoseRobotGaussian
... and with uncertainty.
Definition ObjectPose.h:68
std::string objectPoseOriginalFrame
The frame the object was originally localized in.
Definition ObjectPose.h:78