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 ArmarXSimulation::ArmarXObjects::cluttered_scene_generator
17  * @author Patrick Hegemann ( 335495-patrickhegemann at users dot noreply dot gitlab dot com )
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 <ArmarXCore/libraries/ArmarXCoreComponentPlugins/DebugObserverComponentPlugin.h>
27 
28 // #include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h>
29 
30 // #include <RobotAPI/libraries/RobotAPIComponentPlugins/ArVizComponentPlugin.h>
31 
33 
34 #include <ArmarXSimulation/interface/ObjectMemoryToSimulationInterface.h>
35 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
37 
39 
40 #include <filesystem>
41 
43 {
44  class Component :
45  virtual public armarx::Component
46  // virtual public armarx::ObjectPoseClientPluginUser
47  // , virtual public ArmarXSimulation::components::cluttered_scene_generator::ComponentInterface
48  // , virtual public armarx::DebugObserverComponentPluginUser
49  // , virtual public armarx::LightweightRemoteGuiComponentPluginUser
50  // , virtual public armarx::ArVizComponentPluginUser
51  {
52  public:
53 
54  /// @see armarx::ManagedIceObject::getDefaultName()
55  std::string getDefaultName() const override;
56 
57  /// Get the component's default name.
58  static std::string GetDefaultName();
59 
60  protected:
61 
62  /// @see PropertyUser::createPropertyDefinitions()
64 
65  /// @see armarx::ManagedIceObject::onInitComponent()
66  void onInitComponent() override;
67 
68  /// @see armarx::ManagedIceObject::onConnectComponent()
69  void onConnectComponent() override;
70 
71  /// @see armarx::ManagedIceObject::onDisconnectComponent()
72  void onDisconnectComponent() override;
73 
74  /// @see armarx::ManagedIceObject::onExitComponent()
75  void onExitComponent() override;
76 
77  /* (Requires armarx::LightweightRemoteGuiComponentPluginUser.)
78  /// This function should be called once in onConnect() or when you
79  /// need to re-create the Remote GUI tab.
80  void createRemoteGuiTab();
81 
82  /// After calling `RemoteGui_startRunningTask`, this function is
83  /// called periodically in a separate thread. If you update variables,
84  /// make sure to synchronize access to them.
85  void RemoteGui_update() override;
86  */
87 
88  private:
89  static const std::string defaultName;
90 
91  armarx::SimulatorInterfacePrx simulator_;
92  ArmarXSimulation::components::object_memory_to_simulation::ComponentInterfacePrx objectMemoryToSimulation_;
93 
94  /// Properties shown in the Scenario GUI.
95  struct Properties
96  {
97  struct {
98  std::string packageName;
99  std::string packagePath;
100  } out;
101 
102  struct {
103  uint nScenes = 1;
104  int initialSeed = 0;
105 
106  uint nObjects = 10;
107  float verticalSpacing = 50;
108  } gen;
109  };
110  Properties properties_;
111 
112 
113 
114  scene_generation::ObjectSet getObjectClasses();
115 
116  void generateScene(const scene_generation::ClutteredSceneGenerator::Config& config,
117  int seed);
118 
119  // std::vector<armarx::objpose::ObjectPose> getObjectPoses();
120  // objects::Scene convertScene(const std::vector<armarx::objpose::ObjectPose>& objectPoses);
121  objects::Scene getScene();
122 
123  void storeScene(const objects::Scene& scene, const std::filesystem::path& path);
124 
125  /* Use a mutex if you access variables from different threads
126  * (e.g. ice functions and RemoteGui_update()).
127  std::mutex propertiesMutex;
128  */
129 
130  /* (Requires the armarx::LightweightRemoteGuiComponentPluginUser.)
131  /// Tab shown in the Remote GUI.
132  struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
133  {
134  armarx::RemoteGui::Client::LineEdit boxLayerName;
135  armarx::RemoteGui::Client::IntSpinBox numBoxes;
136 
137  armarx::RemoteGui::Client::Button drawBoxes;
138  };
139  RemoteGuiTab tab;
140  */
141 
142 
143  /* (Requires the armarx::ArVizComponentPluginUser.)
144  * When used from different threads, an ArViz client needs to be synchronized.
145  /// Protects the arviz client inherited from the ArViz plugin.
146  std::mutex arvizMutex;
147  */
148 
149  };
150 
151 } // namespace armarx::simulation::components::cluttered_scene_generator
armarx::simulation::components::cluttered_scene_generator::Component::GetDefaultName
static std::string GetDefaultName()
Get the component's default name.
Definition: Component.cpp:156
armarx::simulation::components::cluttered_scene_generator::Component::onExitComponent
void onExitComponent() override
Definition: Component.cpp:145
ObjectPoseClientPlugin.h
armarx::simulation::components::cluttered_scene_generator::Component::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: Component.cpp:55
armarx::simulation::scene_generation::ClutteredSceneGenerator::Config
Definition: ClutteredSceneGenerator.h:52
armarx::simulation::components::cluttered_scene_generator::Component
Definition: Component.h:44
armarx::simulation::components::cluttered_scene_generator::Component::getDefaultName
std::string getDefaultName() const override
Definition: Component.cpp:150
armarx::simulation::components::cluttered_scene_generator
Definition: Component.cpp:49
armarx::simulation::scene_generation::ObjectSet
Definition: SimulatedObject.h:52
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
armarx::objects::Scene
Definition: Scene.h:56
armarx::simulation::components::cluttered_scene_generator::Component::onInitComponent
void onInitComponent() override
Definition: Component.cpp:80
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::simulation::components::cluttered_scene_generator::Component::onDisconnectComponent
void onDisconnectComponent() override
Definition: Component.cpp:140
armarx::simulation::components::cluttered_scene_generator::Component::onConnectComponent
void onConnectComponent() override
Definition: Component.cpp:86
ClutteredSceneGenerator.h