Component.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 Navigation::ArmarXObjects::Navigator
17 * @author Fabian Reister ( fabian dot reister at kit dot edu )
18 * @author Christian R. G. Dreher ( c dot dreher at kit dot edu )
19 * @date 2021
20 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21 * GNU General Public License
22 */
23
24
25#pragma once
26
27
28#include <memory>
29#include <mutex>
30#include <optional>
31#include <string>
32#include <unordered_map>
33#include <vector>
34
35#include <Eigen/Core>
36
37#include <Ice/Current.h>
38#include <Ice/Object.h>
39#include <IceUtil/Optional.h>
40
44
45#include <ArmarXGui/interface/RemoteGuiInterface.h>
47
48#include <RobotAPI/interface/aron/Aron.h>
54
73
75{
76
77 /**
78 * @defgroup Component-Navigator Navigator
79 * @ingroup armarx_navigation-Components
80 * A description of the component Navigator.
81 *
82 * @class Navigator
83 * @ingroup Component-Navigator
84 * @brief Brief description of class Navigator.
85 *
86 * Detailed description of class Navigator.
87 */
88 class Component :
89 virtual public armarx::Component,
90 virtual public client::NavigatorInterface,
91 virtual public ObjectPoseClientPluginUser,
92 virtual public ArVizComponentPluginUser,
96 // virtual public armem::ListeningClientPluginUser
97 {
98
99 public:
100 Component();
101 ~Component() override;
102
103 /// @see armarx::ManagedIceObject::getDefaultName()
104 std::string getDefaultName() const override;
105
106 static std::string GetDefaultName();
107
108 void createConfig(const aron::data::dto::DictPtr& stackConfig,
109 const std::string& callerId,
110 const Ice::Current& c = Ice::emptyCurrent) override;
111
112 void removeConfig(const std::string& callerId,
113 const Ice::Current& c = Ice::emptyCurrent) override;
114
115 void moveTo(const std::vector<Eigen::Matrix4f>& waypoints,
116 const std::string& navigationMode,
117 const std::string& callerId,
118 const Ice::Current& c = Ice::emptyCurrent) override;
119
120 void moveTo2(const client::detail::Waypoints& waypoints,
121 const std::string& navigationMode,
122 const std::string& callerId,
123 const Ice::Current& c = Ice::emptyCurrent) override;
124
126 const std::string& navigationMode,
127 const std::string& callerId,
128 const Ice::Current& c = Ice::emptyCurrent) override;
129
130 void moveToLocation(const std::string& location,
131 const IceUtil::Optional<std::string>& providerName,
132 const std::string& callerId,
133 const Ice::Current& c = Ice::emptyCurrent) override;
134
135 void updateMoveTo(const std::vector<Eigen::Matrix4f>& waypoints,
136 const std::string& navigationMode,
137 const std::string& callerId,
138 const Ice::Current& c = Ice::emptyCurrent) override;
139
140 void moveTowards(const Eigen::Vector3f& direction,
141 const std::string& navigationMode,
142 const std::string& callerId,
143 const Ice::Current& c = Ice::emptyCurrent) override;
144
145 void setVelocityFactor(float velocityFactor,
146 const std::string& callerId,
147 const Ice::Current& c = Ice::emptyCurrent) override;
148
149 void pause(const std::string& callerId, const Ice::Current& c = Ice::emptyCurrent) override;
150
151 void resume(const std::string& callerId,
152 const Ice::Current& c = Ice::emptyCurrent) override;
153
154 void stop(const std::string& callerId, const Ice::Current& c = Ice::emptyCurrent) override;
155
156 void stopAll(const Ice::Current& c = Ice::emptyCurrent) override;
157
158 bool isPaused(const std::string& callerId,
159 const Ice::Current& c = Ice::emptyCurrent) override;
160
161 bool isStopped(const std::string& callerId,
162 const Ice::Current& c = Ice::emptyCurrent) override;
163
164 const core::Scene& scene() const;
165
166 protected:
167 /// @see PropertyUser::createPropertyDefinitions()
169
170 /// @see armarx::ManagedIceObject::onInitComponent()
171 void onInitComponent() override;
172
173 /// @see armarx::ManagedIceObject::onConnectComponent()
174 void onConnectComponent() override;
175
176 /// @see armarx::ManagedIceObject::onDisconnectComponent()
177 void onDisconnectComponent() override;
178
179 /// @see armarx::ManagedIceObject::onExitComponent()
180 void onExitComponent() override;
181
182 /// This function should be called once in onConnect() or when you
183 /// need to re-create the Remote GUI tab.
184 void createRemoteGuiTab();
185
186 /// After calling `RemoteGui_startRunningTask`, this function is
187 /// called periodically in a separate thread. If you update variables,
188 /// make sure to synchronize access to them.
189 void RemoteGui_update() override;
190
191 bool initializeScene();
192
193 void stopAllImpl(bool emitMemoryEvent);
194
195
196 // core::StaticScene staticScene();
197
198 // [[nodiscard]] VirtualRobot::RobotPtr getRobot();
199 // void updateRobot();
200
202 std::optional<std::string> activeNavigatorId() const;
203
204 private:
205 void visualizeSPFA();
206
207 // core::Scene scene;
208
209 std::optional<server::PlatformControllerExecutor> executor;
210 std::optional<server::ArvizIntrospector> introspector;
211 // std::optional<server::MemoryIntrospector> memoryIntrospector;
212 std::optional<server::scene_provider::SceneProvider> sceneProvider;
213
214 std::unordered_map<std::string, server::Navigator> navigators;
215
216 std::mutex propertiesMutex;
217
218 // unique_ptr to avoid dangling refs
219 std::vector<std::unique_ptr<server::MemoryIntrospector>> memoryIntrospectors;
220
221 // `navigation` memory reader and writer
223 parameterizationReaderPlugin = nullptr;
225 parameterizationWriterPlugin = nullptr;
227 eventsWriterPlugin = nullptr;
229 resultsWriterPlugin = nullptr;
231 graphReaderPlugin = nullptr;
233 costmapReaderPlugin = nullptr;
235 costmap3dReaderPlugin = nullptr;
237 humanReaderPlugin = nullptr;
239 laserScannerFeaturesReaderPlugin = nullptr;
240
241 // armem::vision::occupancy_grid::client::Reader occupancyGridReader;
242
243 // `robot_state` memory reader and writer
244 std::optional<armem::robot_state::description::RobotDescription> robotDescription;
246 virtualRobotReaderPlugin = nullptr;
247
248
249 server::MemoryParameterizationService parameterizationService;
250 // server::MemoryPublisher publisher;
251
252 // key is `callerId`
253 std::unordered_map<std::string, std::unique_ptr<server::MemoryPublisher>> memoryPublishers;
254
255 struct Parameters
256 {
257 float occupiedGridThreshold{0.55F};
258 bool disableExecutor{false};
259
261
262 bool rtUnitDynamicallyLoadLibraries = false;
263
264 server::Navigator::Config::General navigatorGeneralConfig;
265 server::GoalReachedMonitorConfig navigatorGoalReachedConfig;
266 };
267
268 Parameters params;
269
270 struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
271 {
273 };
274
275 RemoteGuiTab tab;
276 };
277} // namespace armarx::navigation::components::navigator
constexpr T c
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
A component plugin offering client-side access to a reader or writer and manages the lifecycle,...
void moveToLocation(const std::string &location, const IceUtil::Optional< std::string > &providerName, const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
void removeConfig(const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
void pause(const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
void resume(const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
void setVelocityFactor(float velocityFactor, const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
std::optional< std::string > activeNavigatorId() const
void moveToAlternatives(const client::detail::TargetAlternatives &targets, const std::string &navigationMode, const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
void RemoteGui_update() override
After calling RemoteGui_startRunningTask, this function is called periodically in a separate thread.
bool isPaused(const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
bool isStopped(const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
PropertyDefinitionsPtr createPropertyDefinitions() override
void updateMoveTo(const std::vector< Eigen::Matrix4f > &waypoints, const std::string &navigationMode, const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
void createConfig(const aron::data::dto::DictPtr &stackConfig, const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
void stop(const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
void moveTo(const std::vector< Eigen::Matrix4f > &waypoints, const std::string &navigationMode, const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
void moveTowards(const Eigen::Vector3f &direction, const std::string &navigationMode, const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
void moveTo2(const client::detail::Waypoints &waypoints, const std::string &navigationMode, const std::string &callerId, const Ice::Current &c=Ice::emptyCurrent) override
void createRemoteGuiTab()
This function should be called once in onConnect() or when you need to re-create the Remote GUI tab.
Brief description of class targets.
Definition targets.h:39
::IceInternal::Handle< Dict > DictPtr
sequence< TargetAlternative > TargetAlternatives
This file is part of ArmarX.
Definition constants.cpp:4
core::GoalReachedConfig GoalReachedMonitorConfig
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.