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 <mutex>
28 
29 #include <string>
30 #include <VirtualRobot/VirtualRobot.h>
33 
37 
38 // #include <ArmarXCore/libraries/ArmarXCoreComponentPlugins/DebugObserverComponentPlugin.h>
39 
40 // #include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h>
41 
43 
47 // #include <Simulator.h>
48 #include "RVO.h"
49 #include <armarx/navigation/components/human_simulator/ComponentInterface.h>
50 
52 {
53 
54  class Component :
55  virtual public armarx::Component,
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 
100 
101  private:
102  // Private methods go here.
103 
104  // Forward declare `Properties` if you used it before its defined.
105  // struct Properties;
106 
107  /* (Requires the armarx::ArVizComponentPluginUser.)
108  /// Draw some boxes in ArViz.
109  void drawBoxes(const Properties& p, viz::Client& arviz);
110  */
111 
112  void runPeriodically();
113 
114  void setPreferredVelocities(RVO::RVOSimulator* simulator,
115  const std::vector<RVO::Vector2>& goals);
116 
117 
118  private:
119  static const std::string defaultName;
120 
122 
123 
124  // Private member variables go here.
125 
126 
127  /// Properties shown in the Scenario GUI.
128  struct Properties
129  {
130  int taskPeriodMs = 100;
131 
132 
133  std::size_t nHumans = 4;
134 
136 
137  std::string robotName = "Armar6";
138 
139  std::string objectPoseProviderName = "R003_grasping_challenge";
140  };
141  Properties properties;
142  /* Use a mutex if you access variables from different threads
143  * (e.g. ice functions and RemoteGui_update()).
144  std::mutex propertiesMutex;
145  */
146 
147 
148  /* (Requires the armarx::LightweightRemoteGuiComponentPluginUser.)
149  /// Tab shown in the Remote GUI.
150  struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
151  {
152  armarx::RemoteGui::Client::LineEdit boxLayerName;
153  armarx::RemoteGui::Client::IntSpinBox numBoxes;
154 
155  armarx::RemoteGui::Client::Button drawBoxes;
156  };
157  RemoteGuiTab tab;
158  */
159 
160 
161  /* (Requires the armarx::ArVizComponentPluginUser.)
162  * When used from different threads, an ArViz client needs to be synchronized.
163  /// Protects the arviz client inherited from the ArViz plugin.
164  std::mutex arvizMutex;
165  */
166 
167  template <typename T>
169 
171 
172  std::size_t robotAgentId;
173 
175  nullptr;
176 
177  ReaderWriterPlugin<memory::client::costmap::Reader>* costmapReaderPlugin = nullptr;
178 
179 
180  ReaderWriterPlugin<memory::client::human::Writer>* humanWriterPlugin = nullptr;
181 
182 
183  std::vector<human::simulation::SimulatedHuman> simulatedHumans;
184 
185  // hrvo::Simulator simulator;
186  RVO::RVOSimulator simulator;
187 
188  std::vector<RVO::Vector2> goals;
189  };
190 
191 } // namespace armarx::navigation::components::human_simulator
ArVizComponentPlugin.h
ObjectPoseClientPlugin.h
armarx::armem::client::plugins::ReaderWriterPlugin
A component plugin offering client-side access to a reader or writer and manages the lifecycle,...
Definition: ReaderWriterPlugin.h:44
Reader.h
PeriodicTask.h
armarx::navigation::components::human_simulator::Component::onDisconnectComponent
void onDisconnectComponent() override
Definition: Component.cpp:323
ReaderWriterPlugin.h
armarx::ObjectPoseClientPluginUser
Provides an objpose::ObjectPoseTopicPrx objectPoseTopic as member variable.
Definition: ObjectPoseClientPlugin.h:67
armarx::navigation::components::human_simulator::Component::getDefaultName
std::string getDefaultName() const override
Definition: Component.cpp:336
armarx::ArVizComponentPluginUser
Provides a ready-to-use ArViz client arviz as member variable.
Definition: ArVizComponentPlugin.h:36
armarx::navigation::components::human_simulator::Component::GetDefaultName
static std::string GetDefaultName()
Get the component's default name.
Definition: Component.cpp:343
armarx::navigation::components::human_simulator::ComponentInterface
Definition: ComponentInterface.ice:30
armarx::navigation::human::simulation::SimulatedHumanParams
Definition: SimulatedHuman.h:32
VirtualRobotReader.h
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::navigation::components::human_simulator::Component::Component
Component()
Definition: Component.cpp:58
Writer.h
armarx::navigation::components::human_simulator::Component
Definition: Component.h:54
armarx::navigation::components::human_simulator::Component::onExitComponent
void onExitComponent() override
Definition: Component.cpp:330
armarx::navigation::components::human_simulator::Component::onConnectComponent
void onConnectComponent() override
Definition: Component.cpp:164
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::navigation::components::human_simulator::Component::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: Component.cpp:70
SimulatedHuman.h
armarx::navigation::components::human_simulator
Definition: Component.cpp:56
armarx::navigation::components::human_simulator::Component::onInitComponent
void onInitComponent() override
Definition: Component.cpp:104
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18