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::room_editor
17 * @author Fabian Reister ( fabian dot reister at kit dot edu )
18 * @date 2026
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25#include <atomic>
26#include <memory>
27#include <mutex>
28#include <string>
29
30#include <Ice/Current.h>
31
35
39
42
43#include <armarx/navigation/components/room_editor/ComponentInterface.h>
47
49{
50
51 /**
52 * @defgroup Component-room_editor room_editor
53 * @ingroup armarx_navigation-Components
54 *
55 * An interactive ArViz front-end for the room polygons stored in the navigation memory.
56 *
57 * Rooms are read from the `Rooms` core segment of the navigation memory and visualized
58 * in ArViz. Every polygon vertex is a draggable handle, restricted to the XY plane.
59 * Additional handles on the edge midpoints allow cutting an edge, i.e. inserting a new
60 * vertex in between two existing ones (either by dragging the handle to the desired
61 * position or via its context menu).
62 *
63 * Every modification is written back into the navigation memory immediately. Once the
64 * rooms have the desired shape, they can be dumped back into the `rooms.json` file of
65 * the navigation graph (analogously to the location export of the LocationGraphEditor).
66 *
67 * @class Component
68 * @ingroup Component-room_editor
69 * @brief Interactive ArViz-based editor for room polygons.
70 */
71 class Component :
72 virtual public armarx::Component,
76 {
77 public:
78 Component();
79
80 /// @see armarx::ManagedIceObject::getDefaultName()
81 std::string getDefaultName() const override;
82
83 /// Get the component's default name.
84 static std::string GetDefaultName();
85
86 // ComponentInterface
87 void reloadFromMemory(const Ice::Current& current) override;
88 bool exportToJson(const Ice::Current& current) override;
89
90 protected:
91 /// @see PropertyUser::createPropertyDefinitions()
93
94 /// @see armarx::ManagedIceObject::onInitComponent()
95 void onInitComponent() override;
96
97 /// @see armarx::ManagedIceObject::onConnectComponent()
98 void onConnectComponent() override;
99
100 /// @see armarx::ManagedIceObject::onDisconnectComponent()
101 void onDisconnectComponent() override;
102
103 /// @see armarx::ManagedIceObject::onExitComponent()
104 void onExitComponent() override;
105
106 void createRemoteGuiTab();
107
108 /// @see armarx::LightweightRemoteGuiComponentPluginUser::RemoteGui_update()
109 void RemoteGui_update() override;
110
111 private:
112 /// The interaction loop: commits the ArViz layers and handles the user's interactions.
113 void run();
114
115 /// Reads the rooms from the memory and hands them over to the editor.
116 bool reload();
117
118 /// Writes a single (modified) room back into the navigation memory.
119 void storeRoom(const EditableRoom& room);
120
121 /// Triggers the JSON export in the navigation memory.
122 bool exportRooms();
123
124 private:
125 static const std::string defaultName;
126
127 /// Properties shown in the Scenario GUI.
128 struct Properties
129 {
130 /// If set, only the rooms of this provider segment (navigation graph) are edited.
131 std::string providerSegmentName = "";
132
133 /// Rate of the ArViz interaction loop [Hz].
134 float updateRate = 20.F;
135
136 /// ArViz layer prefix.
137 std::string layerPrefix = "RoomEditor";
138
139 /// Radius of the vertex handles [mm].
140 float vertexHandleRadius = 75.F;
141
142 /// Edge length of the edge handles [mm].
143 float edgeHandleSize = 90.F;
144
145 /// Package the rooms are exported to.
146 std::string exportPackageName = "PriorKnowledgeData";
147
148 /// Directory (relative to the package's data directory) the rooms are exported to.
149 std::string exportDirectory = "navigation-graphs";
150 };
151
152 Properties properties;
153
154 std::unique_ptr<RoomEditor> editor;
155
157
158 std::atomic_bool reloadRequested{false};
159
160 /// Number of rooms currently being edited (for the Remote GUI status label).
161 std::atomic_int numRooms{0};
162
163 /// Guards the export path, which can be changed via the Remote GUI.
164 std::mutex exportPathMutex;
165
166 /// Tab shown in the Remote GUI.
167 struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
168 {
171
172 armarx::RemoteGui::Client::LineEdit exportPackageName;
176 };
177
178 RemoteGuiTab tab;
179
181 roomsReaderPlugin = nullptr;
183 roomsWriterPlugin = nullptr;
184 };
185
186} // namespace armarx::navigation::components::room_editor
Provides a ready-to-use ArViz client arviz as member variable.
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
A component plugin offering client-side access to a reader or writer and manages the lifecycle,...
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition Component.cpp:63
static std::string GetDefaultName()
Get the component's default name.
void reloadFromMemory()
Re-reads the rooms from the navigation memory.
bool exportToJson()
Dumps the rooms of the navigation memory to disk (rooms.json), using the package and directory config...
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
A room together with the provider segment (i.e. the navigation graph) it belongs to.
Definition RoomEditor.h:45