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::human_simulator
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
27#include <string>
28
29#include <VirtualRobot/VirtualRobot.h>
30
34
39
40#include <armarx/navigation/components/human_simulator/ComponentInterface.h>
44
45#include "RVO.h"
46
48{
49
50 class Component :
51 virtual public armarx::Component,
54 // , virtual public armarx::DebugObserverComponentPluginUser
55 // , virtual public armarx::LightweightRemoteGuiComponentPluginUser
57 {
58 public:
59 Component();
60
61 /// @see armarx::ManagedIceObject::getDefaultName()
62 std::string getDefaultName() const override;
63
64 /// Get the component's default name.
65 static std::string GetDefaultName();
66
67
68 protected:
69 /// @see PropertyUser::createPropertyDefinitions()
71
72 /// @see armarx::ManagedIceObject::onInitComponent()
73 void onInitComponent() override;
74
75 /// @see armarx::ManagedIceObject::onConnectComponent()
76 void onConnectComponent() override;
77
78 /// @see armarx::ManagedIceObject::onDisconnectComponent()
79 void onDisconnectComponent() override;
80
81 /// @see armarx::ManagedIceObject::onExitComponent()
82 void onExitComponent() override;
83
84
85 /* (Requires armarx::LightweightRemoteGuiComponentPluginUser.)
86 /// This function should be called once in onConnect() or when you
87 /// need to re-create the Remote GUI tab.
88 void createRemoteGuiTab();
89
90 /// After calling `RemoteGui_startRunningTask`, this function is
91 /// called periodically in a separate thread. If you update variables,
92 /// make sure to synchronize access to them.
93 void RemoteGui_update() override;
94 */
95
96
97 private:
98 // Private methods go here.
99
100 // Forward declare `Properties` if you used it before its defined.
101 // struct Properties;
102
103 /* (Requires the armarx::ArVizComponentPluginUser.)
104 /// Draw some boxes in ArViz.
105 void drawBoxes(const Properties& p, viz::Client& arviz);
106 */
107
108 void runPeriodically();
109
110 void setPreferredVelocities(RVO::RVOSimulator* simulator,
111 const std::vector<RVO::Vector2>& goals);
112
113
114 private:
115 static const std::string defaultName;
116
118
119 // Private member variables go here.
120
121
122 /// Properties shown in the Scenario GUI.
123 struct Properties
124 {
125 int taskPeriodMs = 100;
126
127
128 std::size_t nHumans = 4;
129
131
132 std::string robotName = "Armar6";
133
134 std::string objectPoseProviderName = "R003_grasping_challenge";
135 };
136
137 Properties properties;
138 /* Use a mutex if you access variables from different threads
139 * (e.g. ice functions and RemoteGui_update()).
140 std::mutex propertiesMutex;
141 */
142
143
144 /* (Requires the armarx::LightweightRemoteGuiComponentPluginUser.)
145 /// Tab shown in the Remote GUI.
146 struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
147 {
148 armarx::RemoteGui::Client::LineEdit boxLayerName;
149 armarx::RemoteGui::Client::IntSpinBox numBoxes;
150
151 armarx::RemoteGui::Client::Button drawBoxes;
152 };
153 RemoteGuiTab tab;
154 */
155
156
157 /* (Requires the armarx::ArVizComponentPluginUser.)
158 * When used from different threads, an ArViz client needs to be synchronized.
159 /// Protects the arviz client inherited from the ArViz plugin.
160 std::mutex arvizMutex;
161 */
162
163 template <typename T>
164 using ReaderWriterPlugin = armem::client::plugins::ReaderWriterPlugin<T>;
165
167
168 std::size_t robotAgentId;
169
170 ReaderWriterPlugin<armem::robot_state::VirtualRobotReader>* virtualRobotReaderPlugin =
171 nullptr;
172
173 ReaderWriterPlugin<memory::client::costmap::Reader>* costmapReaderPlugin = nullptr;
174
175
176 ReaderWriterPlugin<memory::client::human::Writer>* humanWriterPlugin = nullptr;
177
178
179 std::vector<human::simulation::SimulatedHuman> simulatedHumans;
180
181 // hrvo::Simulator simulator;
182 RVO::RVOSimulator simulator;
183
184 std::vector<RVO::Vector2> goals;
185 };
186
187} // namespace armarx::navigation::components::human_simulator
Provides a ready-to-use ArViz client arviz as member variable.
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition Component.h:94
Provides an objpose::ObjectPoseTopicPrx objectPoseTopic as member variable.
IceUtil::Handle< PeriodicTask< 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:82
static std::string GetDefaultName()
Get the component's default name.
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.