SimulationObjectPoseProvider.h
Go to the documentation of this file.
1 /**
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package armarx
17  * @author Philip Scherer ( ulila@student.kit.edu )
18  * @date 2022
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <cstdint>
26 
30 
33 
34 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
35 
36 namespace armarx
37 {
39  virtual public armarx::Component,
41  {
42  public:
43  /// @see armarx::ManagedIceObject::getDefaultName()
44  std::string getDefaultName() const override;
45 
46  /// Get the component's default name.
47  static std::string GetDefaultName();
48 
49  // ObjectPoseProvider interface
50  public:
51  objpose::provider::RequestObjectsOutput
52  requestObjects(const objpose::provider::RequestObjectsInput& input,
53  const Ice::Current& /* unused */) override;
54 
55  objpose::ProviderInfo getProviderInfo(const Ice::Current& /* unused */) override;
56 
57  protected:
58  /// @see PropertyUser::createPropertyDefinitions()
60 
61  /// @see armarx::ManagedIceObject::onInitComponent()
62  void onInitComponent() override;
63 
64  /// @see armarx::ManagedIceObject::onConnectComponent()
65  void onConnectComponent() override;
66 
67  /// @see armarx::ManagedIceObject::onDisconnectComponent()
68  void onDisconnectComponent() override;
69 
70  /// @see armarx::ManagedIceObject::onExitComponent()
71  void onExitComponent() override;
72 
73  private:
74  // Private methods go here.
75  void poseProviderTaskRun();
76 
77  std::vector<objpose::ProvidedObjectPose> getAllPoses(const armarx::SceneVisuData& sceneData,
78  const DateTime& time) const;
79 
80  void updateKnownObjects(const armarx::SceneVisuData& sceneData);
81  void removeExpiredRequests(const DateTime& time);
82  std::vector<objpose::ProvidedObjectPose> getRequestedPoses(const DateTime& time) const;
83 
84  objpose::ProvidedObjectPose objectPoseFromVisuData(const armarx::ObjectVisuData& visuData,
85  const DateTime& time) const;
86 
87  private:
88  static const std::string defaultName;
89 
90  mutable std::mutex knownObjectsMutex;
91  std::map<std::string, armarx::ObjectVisuData> knownObjects;
92 
93  mutable std::mutex activeRequestsMutex;
94  std::map<std::string, armarx::core::time::DateTime> activeRequests;
95 
96  SimulatorInterfacePrx simulatorPrx;
97 
99 
100  struct Properties
101  {
102  std::int64_t updateFrequency = 10;
103 
104  // Comma separated list of object entities and durations if desired.
105  bool requestAllEntities = false;
106  std::string initiallyRequestedEntities = "";
107  };
108  Properties properties;
109  };
110 } // namespace armarx
ObjectPoseProviderPlugin.h
armarx::SimulationObjectPoseProvider::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: SimulationObjectPoseProvider.cpp:46
DateTime.h
armarx::SimulationObjectPoseProvider::onExitComponent
void onExitComponent() override
Definition: SimulationObjectPoseProvider.cpp:120
armarx::ObjectPoseProviderPluginUser
Provides an objpose::ObjectPoseTopicPrx objectPoseTopic as member variable.
Definition: ObjectPoseProviderPlugin.h:43
armarx::SimulationObjectPoseProvider
Definition: SimulationObjectPoseProvider.h:38
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:19
armarx::SimulationObjectPoseProvider::getDefaultName
std::string getDefaultName() const override
Definition: SimulationObjectPoseProvider.cpp:125
TaskUtil.h
armarx::SimulationObjectPoseProvider::GetDefaultName
static std::string GetDefaultName()
Get the component's default name.
Definition: SimulationObjectPoseProvider.cpp:132
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::objpose::ProvidedObjectPose
An object pose provided by an ObjectPoseProvider.
Definition: ProvidedObjectPose.h:25
armarx::SimulationObjectPoseProvider::onConnectComponent
void onConnectComponent() override
Definition: SimulationObjectPoseProvider.cpp:106
armarx::core::time::DateTime
Represents a point in time.
Definition: DateTime.h:24
armarx::SimulationObjectPoseProvider::getProviderInfo
objpose::ProviderInfo getProviderInfo(const Ice::Current &) override
Definition: SimulationObjectPoseProvider.cpp:186
ProvidedObjectPose.h
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::SimulationObjectPoseProvider::requestObjects
objpose::provider::RequestObjectsOutput requestObjects(const objpose::provider::RequestObjectsInput &input, const Ice::Current &) override
Definition: SimulationObjectPoseProvider.cpp:138
armarx::SimulationObjectPoseProvider::onDisconnectComponent
void onDisconnectComponent() override
Definition: SimulationObjectPoseProvider.cpp:115
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::SimulationObjectPoseProvider::onInitComponent
void onInitComponent() override
Definition: SimulationObjectPoseProvider.cpp:76