SegmentAdapter.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 RobotAPI::armem_objects::Adapter
17  * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu )
18  * @date 2021
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <mutex>
26 
27 #include <VirtualRobot/VirtualRobot.h>
28 
30 
32 #include <RobotAPI/interface/armem/server/ObjectMemoryInterface.h>
33 #include <RobotAPI/interface/core/RobotState.h>
34 
36 
42 
43 
44 #define ICE_CURRENT_ARG const Ice::Current& = Ice::emptyCurrent
45 
46 
48 {
49 
50  /**
51  * @brief Helps implementing the `armarx::armem::server::ObjectInstanceSegmentInterface`.
52  */
54  virtual public armarx::Logging
55  , virtual public armarx::armem::server::ObjectInstanceSegmentInterface
56  {
57  public:
58 
60 
61  std::string getName() const;
62  void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix = "");
63 
64  void init();
65  void connect(
66  robot_state::VirtualRobotReader* virtualRobotReader,
67  KinematicUnitObserverInterfacePrx kinematicUnitObserver,
68  viz::Client arviz,
69  DebugObserverInterfacePrx debugObserver
70  );
71 
72 
73  // ObjectPoseTopic interface
74  public:
75  virtual void reportProviderAvailable(const std::string& providerName, const objpose::ProviderInfo& info, ICE_CURRENT_ARG) override;
76  virtual void reportObjectPoses(const std::string& providerName, const objpose::data::ProvidedObjectPoseSeq& objectPoses, ICE_CURRENT_ARG) override;
77 
78  // ObjectInstanceSegmentInterface interface
79  public:
80 
81  // OBJECT POSES
82 
84  virtual objpose::data::ObjectPoseSeq getObjectPosesByProvider(const std::string& providerName, ICE_CURRENT_ARG) override;
85 
86  // PROVIDER INFORMATION
87 
88  virtual bool hasProvider(const std::string& providerName, ICE_CURRENT_ARG) override;
89  virtual objpose::ProviderInfo getProviderInfo(const std::string& providerName, ICE_CURRENT_ARG) override;
90  virtual Ice::StringSeq getAvailableProviderNames(ICE_CURRENT_ARG) override;
91  virtual objpose::ProviderInfoMap getAvailableProvidersInfo(ICE_CURRENT_ARG) override;
92 
93 
94  // REQUESTING
95 
96  virtual objpose::observer::RequestObjectsOutput requestObjects(const objpose::observer::RequestObjectsInput& input, ICE_CURRENT_ARG) override;
97 
98  // ATTACHING
99 
100  virtual objpose::AttachObjectToRobotNodeOutput attachObjectToRobotNode(const objpose::AttachObjectToRobotNodeInput& input, ICE_CURRENT_ARG) override;
101  virtual objpose::DetachObjectFromRobotNodeOutput detachObjectFromRobotNode(const objpose::DetachObjectFromRobotNodeInput& input, ICE_CURRENT_ARG) override;
102  virtual objpose::DetachAllObjectsFromRobotNodesOutput detachAllObjectsFromRobotNodes(const objpose::DetachAllObjectsFromRobotNodesInput& input, ICE_CURRENT_ARG) override;
103 
104  virtual objpose::AgentFramesSeq getAttachableFrames(ICE_CURRENT_ARG) override;
105 
106  // HEAD MOVEMENT SIGNALS
107 
108  virtual objpose::SignalHeadMovementOutput signalHeadMovement(const objpose::SignalHeadMovementInput& input, ICE_CURRENT_ARG) override;
109 
110  // PREDICTING
111 
112  virtual objpose::ObjectPosePredictionResultSeq
113  predictObjectPoses(const objpose::ObjectPosePredictionRequestSeq& requests,
114  ICE_CURRENT_ARG) override;
115 
116  virtual armem::prediction::data::PredictionEngineSeq
118 
119 
120  private:
121 
122  void updateProviderInfo(const std::string& providerName, const objpose::ProviderInfo& info);
123 
124  void updateObjectPoses(const std::string& providerName, const objpose::data::ProvidedObjectPoseSeq& providedPoses);
125  void handleProviderUpdate(const std::string& providerName);
126 
127 
128  // Visualization
129 
130  void visualizeRun();
131 
132 
133  public:
134 
135  static const std::string linearPredictionEngineID;
136  static const std::vector<PredictionEngine> predictionEngines;
137 
138 
139  private:
140 
141  viz::Client arviz;
142  DebugObserverInterfacePrx debugObserver;
143 
144  instance::Segment segment;
145 
146  instance::RobotHeadMovement robotHead;
147  std::mutex robotHeadMutex;
148 
149  instance::Visu visu;
150  std::mutex visuMutex;
151 
152  Segment::Calibration calibration;
153 
154 
155  public:
156 
157  struct RemoteGui
158  {
161 
166 
167  void setup(const SegmentAdapter& adapter);
168  void update(SegmentAdapter& adapter);
169  };
170 
171  };
172 
173 }
174 
175 #undef ICE_CURRENT_ARG
Client.h
armarx::armem::server::obj::instance::SegmentAdapter::predictObjectPoses
virtual objpose::ObjectPosePredictionResultSeq predictObjectPoses(const objpose::ObjectPosePredictionRequestSeq &requests, ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:434
armarx::armem::server::obj::instance::SegmentAdapter::RemoteGui::robotHead
instance::RobotHeadMovement::RemoteGui robotHead
Definition: SegmentAdapter.h:165
armarx::armem::robot_state::VirtualRobotReader
The VirtualRobotReader class.
Definition: VirtualRobotReader.h:40
armarx::armem::server::obj::instance::SegmentAdapter::hasProvider
virtual bool hasProvider(const std::string &providerName, ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:371
armarx::armem::server::obj::instance::Visu::RemoteGui
Definition: Visu.h:112
armarx::objpose::ObjectPoseSeq
std::vector< ObjectPose > ObjectPoseSeq
Definition: forward_declarations.h:20
armarx::armem::server::obj::instance::SegmentAdapter::getObjectPosesByProvider
virtual objpose::data::ObjectPoseSeq getObjectPosesByProvider(const std::string &providerName, ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:241
armarx::armem::server::obj::instance::SegmentAdapter::getAvailableObjectPoseEngines
virtual armem::prediction::data::PredictionEngineSeq getAvailableObjectPoseEngines(ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:511
armarx::armem::server::obj::instance::Segment::Calibration
Definition: Segment.h:47
armarx::RemoteGui::Client::VBoxLayout
Definition: Widgets.h:167
armarx::armem::server::MemoryToIceAdapter
Helps connecting a Memory server to the Ice interface.
Definition: MemoryToIceAdapter.h:19
armarx::armem::server::obj::instance::SegmentAdapter::RemoteGui::update
void update(SegmentAdapter &adapter)
Definition: SegmentAdapter.cpp:618
armarx::armem::server::obj::instance::Decay::RemoteGui
Definition: Decay.h:48
armarx::armem::server::obj::instance::SegmentAdapter::getName
std::string getName() const
Definition: SegmentAdapter.cpp:53
ICE_CURRENT_ARG
#define ICE_CURRENT_ARG
Definition: SegmentAdapter.h:44
armarx::armem::server::obj::instance::SegmentAdapter::RemoteGui::decay
instance::Decay::RemoteGui decay
Definition: SegmentAdapter.h:164
armarx::armem::server::obj::instance::SegmentAdapter::init
void init()
Definition: SegmentAdapter.cpp:68
Segment.h
Decay.h
armarx::armem::server::obj::instance::SegmentAdapter::RemoteGui::group
armarx::RemoteGui::Client::GroupBox group
Definition: SegmentAdapter.h:159
armarx::armem::server::obj::instance::SegmentAdapter::reportObjectPoses
virtual void reportObjectPoses(const std::string &providerName, const objpose::data::ProvidedObjectPoseSeq &objectPoses, ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:117
armarx::armem::server::obj::instance::SegmentAdapter::attachObjectToRobotNode
virtual objpose::AttachObjectToRobotNodeOutput attachObjectToRobotNode(const objpose::AttachObjectToRobotNodeInput &input, ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:380
armarx::armem::server::obj::instance
Definition: ArticulatedObjectVisu.cpp:16
armarx::armem::server::obj::instance::SegmentAdapter::getAvailableProviderNames
virtual Ice::StringSeq getAvailableProviderNames(ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:353
armarx::armem::server::obj::instance::SegmentAdapter::RemoteGui::visu
instance::Visu::RemoteGui visu
Definition: SegmentAdapter.h:162
armarx::armem::server::obj::instance::SegmentAdapter::detachAllObjectsFromRobotNodes
virtual objpose::DetachAllObjectsFromRobotNodesOutput detachAllObjectsFromRobotNodes(const objpose::DetachAllObjectsFromRobotNodesInput &input, ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:400
armarx::armem::server::obj::instance::Visu
Models decay of object localizations by decreasing the confidence the longer the object was not local...
Definition: Visu.h:26
armarx::armem::server::obj::instance::SegmentAdapter::getAttachableFrames
virtual objpose::AgentFramesSeq getAttachableFrames(ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:410
armarx::aron::input
ReaderT::InputType & input
Definition: rw.h:19
armarx::armem::server::obj::instance::SegmentAdapter::getAvailableProvidersInfo
virtual objpose::ProviderInfoMap getAvailableProvidersInfo(ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:344
armarx::RemoteGui::Client::GroupBox
Definition: Widgets.h:193
VirtualRobotReader.h
armarx::armem::server::obj::instance::SegmentAdapter::SegmentAdapter
SegmentAdapter(MemoryToIceAdapter &iceMemory)
Definition: SegmentAdapter.cpp:47
armarx::armem::server::obj::instance::SegmentAdapter::detachObjectFromRobotNode
virtual objpose::DetachObjectFromRobotNodeOutput detachObjectFromRobotNode(const objpose::DetachObjectFromRobotNodeInput &input, ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:390
MemoryToIceAdapter.h
armarx::objpose::ProvidedObjectPoseSeq
std::vector< ProvidedObjectPose > ProvidedObjectPoseSeq
Definition: forward_declarations.h:25
armarx::armem::server::obj::instance::SegmentAdapter::getObjectPoses
virtual objpose::data::ObjectPoseSeq getObjectPoses(ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:217
armarx::armem::server::obj::instance::SegmentAdapter::RemoteGui::segment
instance::Segment::RemoteGui segment
Definition: SegmentAdapter.h:163
armarx::armem::server::obj::instance::SegmentAdapter::getProviderInfo
virtual objpose::ProviderInfo getProviderInfo(const std::string &providerName, ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:362
armarx::Logging
Base Class for all Logging classes.
Definition: Logging.h:232
armarx::armem::server::obj::instance::RobotHeadMovement
Definition: RobotHeadMovement.h:26
armarx::armem::server::obj::instance::RobotHeadMovement::RemoteGui
Definition: RobotHeadMovement.h:67
armarx::armem::server::obj::instance::SegmentAdapter::RemoteGui::setup
void setup(const SegmentAdapter &adapter)
Definition: SegmentAdapter.cpp:597
IceUtil::Handle< class PropertyDefinitionContainer >
RobotHeadMovement.h
armarx::armem::server::obj::instance::SegmentAdapter::linearPredictionEngineID
static const std::string linearPredictionEngineID
Definition: SegmentAdapter.h:135
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
armarx::armem::server::obj::instance::SegmentAdapter
Helps implementing the armarx::armem::server::ObjectInstanceSegmentInterface.
Definition: SegmentAdapter.h:53
armarx::armem::server::obj::instance::Segment::RemoteGui
Definition: Segment.h:218
armarx::armem::server::obj::instance::SegmentAdapter::reportProviderAvailable
virtual void reportProviderAvailable(const std::string &providerName, const objpose::ProviderInfo &info, ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:111
Visu.h
Widgets.h
armarx::armem::server::obj::instance::SegmentAdapter::signalHeadMovement
virtual objpose::SignalHeadMovementOutput signalHeadMovement(const objpose::SignalHeadMovementInput &input, ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:427
armarx::armem::server::obj::instance::Segment
Definition: Segment.h:35
armarx::armem::server::obj::instance::SegmentAdapter::RemoteGui::layout
armarx::RemoteGui::Client::VBoxLayout layout
Definition: SegmentAdapter.h:160
armarx::viz::Client
Definition: Client.h:109
armarx::armem::server::obj::instance::SegmentAdapter::RemoteGui
Definition: SegmentAdapter.h:157
armarx::armem::server::obj::instance::SegmentAdapter::requestObjects
virtual objpose::observer::RequestObjectsOutput requestObjects(const objpose::observer::RequestObjectsInput &input, ICE_CURRENT_ARG) override
Definition: SegmentAdapter.cpp:266
armarx::armem::server::obj::instance::SegmentAdapter::predictionEngines
static const std::vector< PredictionEngine > predictionEngines
Definition: SegmentAdapter.h:136
armarx::armem::server::obj::instance::SegmentAdapter::connect
void connect(robot_state::VirtualRobotReader *virtualRobotReader, KinematicUnitObserverInterfacePrx kinematicUnitObserver, viz::Client arviz, DebugObserverInterfacePrx debugObserver)
Definition: SegmentAdapter.cpp:80
armarx::armem::server::obj::instance::SegmentAdapter::defineProperties
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="")
Definition: SegmentAdapter.cpp:59