ObjectPoseClient.cpp
Go to the documentation of this file.
1 #include "ObjectPoseClient.h"
2 
3 #include <optional>
4 
6 
7 namespace armarx::objpose
8 {
9 
11  {
12  }
13 
15  const ObjectFinder& finder) :
16  objectFinder(finder)
17  {
18  this->connect(objectPoseStorage);
19  }
20 
21  void
23  {
24  this->objectPoseStorage = objectPoseStorage;
25  }
26 
27  bool
29  {
30  return bool(objectPoseStorage);
31  }
32 
35  {
36  if (not objectPoseStorage)
37  {
38  ARMARX_WARNING << "No object pose storage.";
39  return {};
40  }
41  return fromIce(objectPoseStorage->getObjectPoses());
42  }
43 
46  {
47  ObjectPoseMap map;
48  for (auto& pose : fetchObjectPoses())
49  {
50  map.emplace(pose.objectID, std::move(pose));
51  }
52  return map;
53  }
54 
55  std::optional<ObjectPose>
57  {
58  const auto objectPoses = fetchObjectPoses();
59  const auto* object = findObjectPoseByID(objectPoses, objectID);
60 
61  if (object != nullptr)
62  {
63  return *object;
64  }
65 
66  return std::nullopt;
67  }
68 
69  std::optional<ObjectPose>
71  const std::string& providerName) const
72  {
73  const auto objectPoses = fetchObjectPosesFromProvider(providerName);
74  const auto* object = findObjectPoseByID(objectPoses, objectID);
75 
76  if (object != nullptr)
77  {
78  return *object;
79  }
80 
81  return std::nullopt;
82  }
83 
85  ObjectPoseClient::fetchObjectPosesFromProvider(const std::string& providerName) const
86  {
87  if (!objectPoseStorage)
88  {
89  ARMARX_WARNING << "No object pose storage.";
90  return {};
91  }
92  return fromIce(objectPoseStorage->getObjectPosesByProvider(providerName));
93  }
94 
97  {
98  return objectPoseStorage;
99  }
100 
101  const ObjectFinder&
103  {
104  return objectFinder;
105  }
106 
107 } // namespace armarx::objpose
armarx::objpose::ObjectPoseClient::fetchObjectPoses
ObjectPoseSeq fetchObjectPoses() const
Fetch all known object poses.
Definition: ObjectPoseClient.cpp:34
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::fromIce
void fromIce(const Box &box, simox::OrientedBox< float > &oobb)
armarx::objpose::ObjectPoseClient::objectFinder
ObjectFinder objectFinder
Definition: ObjectPoseClient.h:107
armarx::objpose::findObjectPoseByID
ObjectPose * findObjectPoseByID(ObjectPoseSeq &objectPoses, const ObjectID &id)
Find an object pose by the object ID.
Definition: ObjectPose.cpp:419
armarx::objpose::ObjectPoseClient::fetchObjectPose
std::optional< ObjectPose > fetchObjectPose(const ObjectID &objectID) const
Fetch the pose of a single object.
Definition: ObjectPoseClient.cpp:56
armarx::objpose::ObjectPoseClient::getObjectFinder
const ObjectFinder & getObjectFinder() const
Get the internal object finder.
Definition: ObjectPoseClient.cpp:102
armarx::objpose::ObjectPoseClient::objectPoseStorage
ObjectPoseStorageInterfacePrx objectPoseStorage
Definition: ObjectPoseClient.h:105
armarx::ObjectFinder
Used to find objects in the ArmarX objects repository [1] (formerly [2]).
Definition: ObjectFinder.h:22
armarx::objpose::ObjectPoseClient::fetchObjectPosesAsMap
ObjectPoseMap fetchObjectPosesAsMap() const
Fetch all known object poses.
Definition: ObjectPoseClient.cpp:45
armarx::objpose::ObjectPoseClient::getObjectPoseStorage
const ObjectPoseStorageInterfacePrx & getObjectPoseStorage() const
Get the object pose storage's proxy.
Definition: ObjectPoseClient.cpp:96
armarx::objpose
Definition: objpose.h:6
ObjectPoseClient.h
ObjectPose.h
IceInternal::ProxyHandle<::IceProxy::armarx::objpose::ObjectPoseStorageInterface >
armarx::objpose::ObjectPoseClient::ObjectPoseClient
ObjectPoseClient()
Construct a disconnected client.
Definition: ObjectPoseClient.cpp:10
armarx::objpose::ObjectPoseClient::fetchObjectPoseFromProvider
std::optional< ObjectPose > fetchObjectPoseFromProvider(const ObjectID &objectID, const std::string &providerName) const
Fetch the pose of a single object and a single provider.
Definition: ObjectPoseClient.cpp:70
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx::objpose::ObjectPoseClient::isConnected
bool isConnected() const
Indicate whether this client is connected to an object pose storage.
Definition: ObjectPoseClient.cpp:28
armarx::objpose::ObjectPoseClient::connect
void connect(const ObjectPoseStorageInterfacePrx &objectPoseStorage)
Connect to the given object pose storage.
Definition: ObjectPoseClient.cpp:22
armarx::objpose::ObjectPoseClient::fetchObjectPosesFromProvider
ObjectPoseSeq fetchObjectPosesFromProvider(const std::string &providerName) const
Fetch object poses from a specific provider.
Definition: ObjectPoseClient.cpp:85
armarx::objpose::ObjectPoseMap
std::map< ObjectID, ObjectPose > ObjectPoseMap
Definition: forward_declarations.h:21