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