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
74
76{
77
78 /**
79 * @defgroup Component-Navigator Navigator
80 * @ingroup armarx_navigation-Components
81 * A description of the component Navigator.
82 *
83 * @class Navigator
84 * @ingroup Component-Navigator
85 * @brief Brief description of class Navigator.
86 *
87 * Detailed description of class Navigator.
88 */
89 class Component :
90 virtual public armarx::Component,
91 virtual public client::NavigatorInterface,
92 virtual public ObjectPoseClientPluginUser,
93 virtual public ArVizComponentPluginUser,
97 // virtual public armem::ListeningClientPluginUser
98 {
99
100 public:
101 Component();
102 ~Component() override;
103
104 /// @see armarx::ManagedIceObject::getDefaultName()
105 std::string getDefaultName() const override;
106
107 static std::string GetDefaultName();
108
109 void createConfig(const aron::data::dto::DictPtr& stackConfig,
110 const std::string& callerId,
111 const Ice::Current& c = Ice::emptyCurrent) override;
112
113 void removeConfig(const std::string& callerId,
114 const Ice::Current& c = Ice::emptyCurrent) override;
115
116 void moveTo(const std::vector<Eigen::Matrix4f>& waypoints,
117 const std::string& navigationMode,
118 const std::string& callerId,
119 const Ice::Current& c = Ice::emptyCurrent) override;
120
121 void moveTo2(const client::detail::Waypoints& waypoints,
122 const std::string& navigationMode,
123 const std::string& callerId,
124 const Ice::Current& c = Ice::emptyCurrent) override;
125
127 const std::string& navigationMode,
128 const std::string& callerId,
129 const Ice::Current& c = Ice::emptyCurrent) override;
130
131 void moveToLocation(const std::string& location,
132 const IceUtil::Optional<std::string>& providerName,
133 const std::string& callerId,
134 const Ice::Current& c = Ice::emptyCurrent) override;
135
136 void updateMoveTo(const std::vector<Eigen::Matrix4f>& waypoints,
137 const std::string& navigationMode,
138 const std::string& callerId,
139 const Ice::Current& c = Ice::emptyCurrent) override;
140
141 void moveTowards(const Eigen::Vector3f& direction,
142 const std::string& navigationMode,
143 const std::string& callerId,
144 const Ice::Current& c = Ice::emptyCurrent) override;
145
146 void setVelocityFactor(float velocityFactor,
147 const std::string& callerId,
148 const Ice::Current& c = Ice::emptyCurrent) override;
149
150 void pause(const std::string& callerId, const Ice::Current& c = Ice::emptyCurrent) override;
151
152 void resume(const std::string& callerId,
153 const Ice::Current& c = Ice::emptyCurrent) override;
154
155 void stop(const std::string& callerId, const Ice::Current& c = Ice::emptyCurrent) override;
156
157 void stopAll(const Ice::Current& c = Ice::emptyCurrent) override;
158
159 bool isPaused(const std::string& callerId,
160 const Ice::Current& c = Ice::emptyCurrent) override;
161
162 bool isStopped(const std::string& callerId,
163 const Ice::Current& c = Ice::emptyCurrent) override;
164
165 const core::Scene& scene() const;
166
167 protected:
168 /// @see PropertyUser::createPropertyDefinitions()
170
171 /// @see armarx::ManagedIceObject::onInitComponent()
172 void onInitComponent() override;
173
174 /// @see armarx::ManagedIceObject::onConnectComponent()
175 void onConnectComponent() override;
176
177 /// @see armarx::ManagedIceObject::onDisconnectComponent()
178 void onDisconnectComponent() override;
179
180 /// @see armarx::ManagedIceObject::onExitComponent()
181 void onExitComponent() override;
182
183 /// This function should be called once in onConnect() or when you
184 /// need to re-create the Remote GUI tab.
185 void createRemoteGuiTab();
186
187 /// After calling `RemoteGui_startRunningTask`, this function is
188 /// called periodically in a separate thread. If you update variables,
189 /// make sure to synchronize access to them.
190 void RemoteGui_update() override;
191
192 bool initializeScene();
193
194 void stopAllImpl(bool emitMemoryEvent);
195
196
197 // core::StaticScene staticScene();
198
199 // [[nodiscard]] VirtualRobot::RobotPtr getRobot();
200 // void updateRobot();
201
203 std::optional<std::string> activeNavigatorId() const;
204
205 private:
206 void visualizeSPFA();
207
208 // core::Scene scene;
209
210 /// Consulted by the executor before it re-activates a controller. Empty when no
211 /// emergency-stop master could be resolved, which the executor reads as "this
212 /// deployment has none" and proceeds. Declared before `executor`, which holds a pointer
213 /// into it.
214 std::optional<server::IceEmergencyStop> emergencyStop;
215
216 std::optional<server::PlatformControllerExecutor> executor;
217 std::optional<server::ArvizIntrospector> introspector;
218 // std::optional<server::MemoryIntrospector> memoryIntrospector;
219 std::optional<server::scene_provider::SceneProvider> sceneProvider;
220
221 std::unordered_map<std::string, server::Navigator> navigators;
222
223 std::mutex propertiesMutex;
224
225 // unique_ptr to avoid dangling refs
226 std::vector<std::unique_ptr<server::MemoryIntrospector>> memoryIntrospectors;
227
228 // `navigation` memory reader and writer
230 parameterizationReaderPlugin = nullptr;
232 parameterizationWriterPlugin = nullptr;
234 eventsWriterPlugin = nullptr;
236 resultsWriterPlugin = nullptr;
238 graphReaderPlugin = nullptr;
240 costmapReaderPlugin = nullptr;
242 costmap3dReaderPlugin = nullptr;
244 humanReaderPlugin = nullptr;
246 laserScannerFeaturesReaderPlugin = nullptr;
247
248 // armem::vision::occupancy_grid::client::Reader occupancyGridReader;
249
250 // `robot_state` memory reader and writer
251 std::optional<armem::robot_state::description::RobotDescription> robotDescription;
253 virtualRobotReaderPlugin = nullptr;
254
255
256 server::MemoryParameterizationService parameterizationService;
257 // server::MemoryPublisher publisher;
258
259 // key is `callerId`
260 std::unordered_map<std::string, std::unique_ptr<server::MemoryPublisher>> memoryPublishers;
261
262 struct Parameters
263 {
264 float occupiedGridThreshold{0.55F};
265 bool disableExecutor{false};
266
268
269 bool rtUnitDynamicallyLoadLibraries = false;
270
271 std::string emergencyStopMasterName{"EmergencyStopMaster"};
272
273 server::Navigator::Config::General navigatorGeneralConfig;
274 server::GoalReachedMonitorConfig navigatorGoalReachedConfig;
275 };
276
277 Parameters params;
278
279 struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
280 {
282 };
283
284 RemoteGuiTab tab;
285 };
286} // 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.