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::distance_to_obstacle_costmap_provider
17 * @author Fabian Reister ( fabian dot reister at kit dot edu )
18 * @date 2022
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23
24#pragma once
25
26#include <mutex>
27#include <optional>
28#include <string>
29#include <vector>
30
33
42
45#include <armarx/navigation/components/nav_3d_test/ComponentInterface.h>
49
51{
52
53 class Component :
54 virtual public armarx::Component,
55 virtual public ObjectPoseClientPluginUser,
58 // , virtual public armarx::DebugObserverComponentPluginUser
59 // , virtual public armarx::LightweightRemoteGuiComponentPluginUser
61 {
62 public:
63 Component();
64
65 /// @see armarx::ManagedIceObject::getDefaultName()
66 std::string getDefaultName() const override;
67
68 /// Get the component's default name.
69 static std::string GetDefaultName();
70
71
72 protected:
73 /// @see PropertyUser::createPropertyDefinitions()
75
76 /// @see armarx::ManagedIceObject::onInitComponent()
77 void onInitComponent() override;
78
79 /// @see armarx::ManagedIceObject::onConnectComponent()
80 void onConnectComponent() override;
81
82 /// @see armarx::ManagedIceObject::onDisconnectComponent()
83 void onDisconnectComponent() override;
84
85 /// @see armarx::ManagedIceObject::onExitComponent()
86 void onExitComponent() override;
87
88
89 /* (Requires armarx::LightweightRemoteGuiComponentPluginUser.)
90 /// This function should be called once in onConnect() or when you
91 /// need to re-create the Remote GUI tab.
92 void createRemoteGuiTab();
93
94 /// After calling `RemoteGui_startRunningTask`, this function is
95 /// called periodically in a separate thread. If you update variables,
96 /// make sure to synchronize access to them.
97 void RemoteGui_update() override;
98 */
99
101
103 const std::vector<armem::MemoryID>& snapshotIDs);
104
105 private:
106 // Private methods go here.
107
108 // Forward declare `Properties` if you used it before its defined.
109 // struct Properties;
110
111 /// Draw costmap in ArViz.
112 void drawCostmap(viz::Client& arviz);
113
114 void drawGlobalTrajectory(const std::vector<core::Pose2D>& trajectory, viz::Client& arviz);
115
116
117
118 static const std::string defaultName;
119
120 // Private member variables go here.
121
122
123 /// Properties shown in the Scenario GUI.
124 struct Properties
125 {
126 std::string robotName;
127 std::string primitiveModelIds =
128 "navigation,urdf_col"; // intentionally not using empty default model
129 std::string colModel = "Platform-navigation-colmodel";
130
133
134 std::string costmapToExtend;
135 bool buildSecondCostmapWithSmallerMargins = true;
136 std::string costmapSmallerMarginsToExtend;
137 std::string robotModelXmlFilepath = "";
138 };
139
140 Properties properties;
141
142 /* (Requires the armarx::ArVizComponentPluginUser.)
143 * When used from different threads, an ArViz client needs to be synchronized.
144 /// Protects the arviz client inherited from the ArViz plugin.
145 std::mutex arvizMutex;
146 */
147 std::optional<armem::robot_state::description::RobotDescription> robotDescription;
149 virtualRobotReaderPlugin = nullptr;
150
151
154 articulatedObjectReaderPlugin = nullptr;
155
156
158 costmapReaderPlugin = nullptr;
159
161 costmapWriterPlugin = nullptr;
162
163
165 roomReaderPlugin = nullptr;
166
167
168 std::mutex createCostmapMtx;
169
170 // Holds data that is needed to go from one step to another one (e.g. the costmap)
171 struct SequentialState
172 {
173 std::optional<algorithms::orientation_aware::Costmap3D> costmap;
174 };
175 SequentialState state;
176
177 };
178
179} // namespace armarx::navigation::components::distance_to_obstacle_costmap_provider
Provides a ready-to-use ArViz client arviz as member variable.
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,...
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition Component.cpp:86
void processObjectInstance(const armem::MemoryID &id, const std::vector< armem::MemoryID > &snapshotIDs)
static std::string GetDefaultName()
Get the component's default name.
client::plugins::ListeningPluginUser ListeningClientPluginUser
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.