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