diff --git a/source/RobotAPI/components/ObjectPoseObserver/ObjectPoseObserver.cpp b/source/RobotAPI/components/ObjectPoseObserver/ObjectPoseObserver.cpp index d5a7b55c3712b8ed984a0ee33e5c4b061e30f888..e9560ff39830ef28fb7bb820a514efefa24abae9 100644 --- a/source/RobotAPI/components/ObjectPoseObserver/ObjectPoseObserver.cpp +++ b/source/RobotAPI/components/ObjectPoseObserver/ObjectPoseObserver.cpp @@ -185,16 +185,13 @@ namespace armarx } { std::scoped_lock lock(dataMutex); - if (providers.count(providerName) == 0) + std::stringstream ss; + for (const auto& id : info.supportedObjects) { - std::stringstream ss; - for (const auto& id : info.supportedObjects) - { - ss << "- " << id << "\n"; - } - ARMARX_VERBOSE << "New provider '" << providerName << "' available.\n" - << "Supported objects: \n" << ss.str(); + ss << "- " << id << "\n"; } + ARMARX_VERBOSE << "Provider '" << providerName << "' available.\n" + << "Supported objects: \n" << ss.str(); providers[providerName] = info; if (updateCounters.count(providerName) == 0) @@ -207,7 +204,8 @@ namespace armarx { offerChannel(providerName, "Channel of provider '" + providerName + "'."); } - offerOrUpdateDataField(providerName, "objectType", objpose::ObjectTypeEnumNames.to_name(info.objectType), ""); + offerOrUpdateDataField(providerName, "objectType", objpose::ObjectTypeEnumNames.to_name(info.objectType), "The object type (known or unknown)"); + offerOrUpdateDataField(providerName, "numSupportedObjects", int(info.supportedObjects.size()), "Number of requestable objects."); } @@ -236,13 +234,14 @@ namespace armarx } - void ObjectPoseObserver::requestObjects(const objpose::ObjectIDSeq& objectIDs, Ice::Long relativeTimeoutMS, const Ice::Current&) + objpose::RequestObjectsOutput ObjectPoseObserver::requestObjects( + const objpose::RequestObjectsInput& input, const Ice::Current&) { std::map<std::string, objpose::ObjectIDSeq> requests; { std::scoped_lock lock(dataMutex); - for (const auto& objectID : objectIDs) + for (const auto& objectID : input.objectIDs) { for (const auto& [name, info] : providers) { @@ -261,13 +260,16 @@ namespace armarx if (provider) { ARMARX_VERBOSE << "Requesting provider '" << providerName << "' for objects " << objects; - provider->requestObjects(objects, relativeTimeoutMS); + provider->requestObjects(objects, input.relativeTimeoutMS); } } + objpose::RequestObjectsOutput output; + // todo + return output; } - objpose::ProviderInfoMap ObjectPoseObserver::getAvailableProvidersWithInfo(const Ice::Current&) + objpose::ProviderInfoMap ObjectPoseObserver::getAvailableProvidersInfo(const Ice::Current&) { std::scoped_lock lock(dataMutex); return providers; diff --git a/source/RobotAPI/components/ObjectPoseObserver/ObjectPoseObserver.h b/source/RobotAPI/components/ObjectPoseObserver/ObjectPoseObserver.h index 894bf651a7e63fe969e9ca65ef6c5cb65c4d9073..c555f79069981a163bc1ce6a1b17ff61ab150d5c 100644 --- a/source/RobotAPI/components/ObjectPoseObserver/ObjectPoseObserver.h +++ b/source/RobotAPI/components/ObjectPoseObserver/ObjectPoseObserver.h @@ -91,11 +91,11 @@ namespace armarx objpose::data::ObjectPoseSeq getObjectPoses(ICE_CURRENT_ARG) override; objpose::data::ObjectPoseSeq getObjectPosesByProvider(const std::string& providerName, ICE_CURRENT_ARG) override; - void requestObjects(const objpose::ObjectIDSeq& objectIDs, Ice::Long relativeTimeoutMS, ICE_CURRENT_ARG) override; + objpose::RequestObjectsOutput requestObjects(const objpose::RequestObjectsInput& input, ICE_CURRENT_ARG) override; Ice::StringSeq getAvailableProviderNames(ICE_CURRENT_ARG) override; objpose::ProviderInfo getProviderInfo(const std::string& providerName, ICE_CURRENT_ARG) override; - objpose::ProviderInfoMap getAvailableProvidersWithInfo(ICE_CURRENT_ARG) override; + objpose::ProviderInfoMap getAvailableProvidersInfo(ICE_CURRENT_ARG) override; bool hasProvider(const std::string& providerName, ICE_CURRENT_ARG) override; diff --git a/source/RobotAPI/interface/objectpose/ObjectPoseObserver.ice b/source/RobotAPI/interface/objectpose/ObjectPoseObserver.ice index 5cc889cd13d206e416ce3c1830a372d052a3224d..0f3d66799925f14f8259774b03f85b85ec55f1a5 100644 --- a/source/RobotAPI/interface/objectpose/ObjectPoseObserver.ice +++ b/source/RobotAPI/interface/objectpose/ObjectPoseObserver.ice @@ -36,16 +36,38 @@ module armarx module objpose { + struct RequestObjectsInput + { + ObjectIDSeq objectIDs; + long relativeTimeoutMS; + /** + * If there are multiple providers for the given IDs, prefer this one. + * If the specified provider is not available, take any. + */ + string preferredProvider; + }; + struct ObjectRequestResult + { + /// Name of the provider who was requested. + string providerName; + }; + dictionary<ObjectID, ObjectRequestResult> ObjectRequestResultMap; + struct RequestObjectsOutput + { + ObjectRequestResultMap results; + }; + + interface ObjectPoseObserverInterface extends ObserverInterface, ObjectPoseTopic { data::ObjectPoseSeq getObjectPoses(); data::ObjectPoseSeq getObjectPosesByProvider(string providerName); - void requestObjects(ObjectIDSeq objectIDs, long relativeTimeoutMS); + RequestObjectsOutput requestObjects(RequestObjectsInput input); Ice::StringSeq getAvailableProviderNames(); - ProviderInfoMap getAvailableProvidersWithInfo(); + ProviderInfoMap getAvailableProvidersInfo(); ProviderInfo getProviderInfo(string providerName); bool hasProvider(string providerName);