ObjectMemoryEditor.cpp
Go to the documentation of this file.
1 #include "ObjectMemoryEditor.h"
2 
4 
7 
8 #include "Editor.h"
9 
10 namespace armarx
11 {
13  {
15 
16  defs->optional(this->objectScaling, "Editor.ObjectScaling",
17  "Scaling factor that is applied to all intractable objects.");
18 
19  defs->optional(this->confidenceThreshold, "Editor.ConfidenceThreshold",
20  "Only objects with a confidence greater than this value are shown.");
21 
22  return defs;
23  }
24 
26  {
27  return "InteractiveMemoryEditor";
28  }
29 
31  {
32  {
33  providerInfo.objectType = objpose::ObjectType::KnownObject;
34 
35  for (const auto& dataset : objectFinder.getDatasets())
36  {
37  std::vector<ObjectInfo> objects = objectFinder.findAllObjectsOfDataset(dataset);
38 
39  for (const auto& obj: objects)
40  {
41  providerInfo.supportedObjects.push_back(armarx::toIce(obj.id()));
42  }
43  }
44  }
45  }
46 
48  {
50 
51  objectVizTask = new SimpleRunningTask<>([this]()
52  {
53  this->run();
54  });
55  objectVizTask->start();
56  }
57 
59  {
60  }
61 
63  {
64  }
65 
66 
67  void ObjectMemoryEditor::run()
68  {
70 
71  Editor::Properties properties =
72  {
73  .providerName = getName(),
74  .objectScaling = objectScaling,
75  .confidenceThreshold = confidenceThreshold,
76  .availableObjects = providerInfo.supportedObjects,
77  };
78 
79  Editor editor(arviz, properties,
80  [this](objpose::ProvidedObjectPoseSeq &poses)
81  {
82  objectPoseTopic->reportObjectPoses(getName(), objpose::toIce(poses));
83  },
84  [client]() -> objpose::ObjectPoseSeq
85  {
86  return client.fetchObjectPoses();
87  });
88 
89  Metronome metronome(Frequency::Hertz(20));
90  while (objectVizTask and not objectVizTask->isStopped())
91  {
92  editor.step();
93 
94  metronome.waitForNextTick();
95  }
96  }
97 
98  objpose::ProviderInfo ObjectMemoryEditor::getProviderInfo(const Ice::Current & /*unused*/)
99  {
100  return providerInfo;
101  }
102 
103  objpose::provider::RequestObjectsOutput ObjectMemoryEditor::requestObjects(
104  const objpose::provider::RequestObjectsInput &input, const Ice::Current & /*unused*/)
105  {
106  objpose::provider::RequestObjectsOutput output;
107 
108  for (const auto &id: input.objectIDs)
109  {
110  output.results[id].success = false;
111  }
112 
113  return output;
114  }
115 } // namespace armarx
armarx::SimpleRunningTask
Usage:
Definition: TaskUtil.h:70
armarx::ObjectMemoryEditor::getDefaultName
std::string getDefaultName() const override
Retrieve default name of component.
Definition: ObjectMemoryEditor.cpp:25
armarx::ObjectMemoryEditor::onInitComponent
void onInitComponent() override
Pure virtual hook for the subclass.
Definition: ObjectMemoryEditor.cpp:30
armarx::objpose::ObjectPoseClient::fetchObjectPoses
ObjectPoseSeq fetchObjectPoses() const
Fetch all known object poses.
Definition: ObjectPoseClient.cpp:39
ice_conversions.h
armarx::objpose::ObjectPoseSeq
std::vector< ObjectPose > ObjectPoseSeq
Definition: forward_declarations.h:20
armarx::DebugObserverComponentPluginUser::setDebugObserverBatchModeEnabled
void setDebugObserverBatchModeEnabled(bool enable)
Definition: DebugObserverComponentPlugin.cpp:118
armarx::ObjectMemoryEditor::getProviderInfo
objpose::ProviderInfo getProviderInfo(const Ice::Current &=Ice::emptyCurrent) override
Definition: ObjectMemoryEditor.cpp:98
armarx::ObjectPoseProviderPluginUser::objectPoseTopic
objpose::ObjectPoseTopicPrx objectPoseTopic
Definition: ObjectPoseProviderPlugin.h:56
armarx::objpose::ObjectPoseClient
Provides access to the armarx::objpose::ObjectPoseStorageInterface (aka the object memory).
Definition: ObjectPoseClient.h:18
armarx::toIce
void toIce(std::map< IceKeyT, IceValueT > &iceMap, const boost::container::flat_map< CppKeyT, CppValueT > &cppMap)
Definition: ice_conversions_boost_templates.h:15
armarx::ObjectMemoryEditor::requestObjects
objpose::provider::RequestObjectsOutput requestObjects(const objpose::provider::RequestObjectsInput &input, const Ice::Current &) override
Definition: ObjectMemoryEditor.cpp:103
ObjectMemoryEditor.h
armarx::Editor::Properties::providerName
std::string providerName
Definition: Editor.h:119
armarx::ObjectFinder::findAllObjectsOfDataset
std::vector< ObjectInfo > findAllObjectsOfDataset(const std::string &dataset, bool checkPaths=true) const
Definition: ObjectFinder.cpp:201
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:19
armarx::ObjectMemoryEditor::onConnectComponent
void onConnectComponent() override
Pure virtual hook for the subclass.
Definition: ObjectMemoryEditor.cpp:47
Metronome.h
armarx::objpose::ProvidedObjectPoseSeq
std::vector< ProvidedObjectPose > ProvidedObjectPoseSeq
Definition: forward_declarations.h:25
armarx::Component::getConfigIdentifier
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition: Component.cpp:74
armarx::objpose::toIce
objpose::AABB toIce(const simox::AxisAlignedBoundingBox &aabb)
Definition: ice_conversions.cpp:94
ProvidedObjectPose.h
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
armarx::ArVizComponentPluginUser::arviz
armarx::viz::Client arviz
Definition: ArVizComponentPlugin.h:43
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::ObjectMemoryEditor::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: ObjectMemoryEditor.cpp:12
Editor.h
armarx::ObjectMemoryEditor::onExitComponent
void onExitComponent() override
Hook for subclass.
Definition: ObjectMemoryEditor.cpp:62
armarx::ManagedIceObject::getName
std::string getName() const
Retrieve name of object.
Definition: ManagedIceObject.cpp:107
armarx::core::time::Frequency::Hertz
static Frequency Hertz(std::int64_t hertz)
Definition: Frequency.cpp:23
armarx::ObjectMemoryEditor::onDisconnectComponent
void onDisconnectComponent() override
Hook for subclass.
Definition: ObjectMemoryEditor.cpp:58
armarx::ObjectFinder::getDatasets
std::vector< std::string > getDatasets() const
Definition: ObjectFinder.cpp:113
armarx::ObjectPoseClientPluginUser::getClient
objpose::ObjectPoseClient getClient() const
Definition: ObjectPoseClientPlugin.cpp:64
armarx::Editor::Properties
Definition: Editor.h:117
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28