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 
32 #include <filesystem>
33 
35 
37 
38 #include <ArmarXSimulation/interface/ObjectMemoryToSimulationInterface.h>
39 #include <ArmarXSimulation/interface/simulator/SimulatorInterface.h>
41 
43 {
44  class Component : virtual public armarx::Component
45  // virtual public armarx::ObjectPoseClientPluginUser
46  // , virtual public ArmarXSimulation::components::cluttered_scene_generator::ComponentInterface
47  // , virtual public armarx::DebugObserverComponentPluginUser
48  // , virtual public armarx::LightweightRemoteGuiComponentPluginUser
49  // , virtual public armarx::ArVizComponentPluginUser
50  {
51  public:
52  /// @see armarx::ManagedIceObject::getDefaultName()
53  std::string getDefaultName() const override;
54 
55  /// Get the component's default name.
56  static std::string GetDefaultName();
57 
58  protected:
59  /// @see PropertyUser::createPropertyDefinitions()
61 
62  /// @see armarx::ManagedIceObject::onInitComponent()
63  void onInitComponent() override;
64 
65  /// @see armarx::ManagedIceObject::onConnectComponent()
66  void onConnectComponent() override;
67 
68  /// @see armarx::ManagedIceObject::onDisconnectComponent()
69  void onDisconnectComponent() override;
70 
71  /// @see armarx::ManagedIceObject::onExitComponent()
72  void onExitComponent() override;
73 
74  /* (Requires armarx::LightweightRemoteGuiComponentPluginUser.)
75  /// This function should be called once in onConnect() or when you
76  /// need to re-create the Remote GUI tab.
77  void createRemoteGuiTab();
78 
79  /// After calling `RemoteGui_startRunningTask`, this function is
80  /// called periodically in a separate thread. If you update variables,
81  /// make sure to synchronize access to them.
82  void RemoteGui_update() override;
83  */
84 
85  private:
86  static const std::string defaultName;
87 
88  armarx::SimulatorInterfacePrx simulator_;
89  ArmarXSimulation::components::object_memory_to_simulation::ComponentInterfacePrx
90  objectMemoryToSimulation_;
91 
92  /// Properties shown in the Scenario GUI.
93  struct Properties
94  {
95  struct
96  {
97  std::string packageName;
98  std::string packagePath;
99  } out;
100 
101  struct
102  {
103  uint nScenes = 1;
104  int initialSeed = 0;
105 
106  uint nObjects = 10;
107  float verticalSpacing = 50;
108  } gen;
109  };
110 
111  Properties properties_;
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 } // 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:159
armarx::simulation::components::cluttered_scene_generator::Component::onExitComponent
void onExitComponent() override
Definition: Component.cpp:148
ObjectPoseClientPlugin.h
armarx::simulation::components::cluttered_scene_generator::Component::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: Component.cpp:54
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:153
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:91
armarx::objects::Scene
Definition: Scene.h:55
armarx::simulation::components::cluttered_scene_generator::Component::onInitComponent
void onInitComponent() override
Definition: Component.cpp:84
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::simulation::components::cluttered_scene_generator::Component::onDisconnectComponent
void onDisconnectComponent() override
Definition: Component.cpp:143
armarx::simulation::components::cluttered_scene_generator::Component::onConnectComponent
void onConnectComponent() override
Definition: Component.cpp:89
ClutteredSceneGenerator.h