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
36namespace 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
109 Properties properties;
110 };
111} // namespace armarx
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
Provides an objpose::ObjectPoseTopicPrx objectPoseTopic as member variable.
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
objpose::ProviderInfo getProviderInfo(const Ice::Current &) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
static std::string GetDefaultName()
Get the component's default name.
objpose::provider::RequestObjectsOutput requestObjects(const objpose::provider::RequestObjectsInput &input, const Ice::Current &) override
Represents a point in time.
Definition DateTime.h:25
An object pose provided by an ObjectPoseProvider.
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.