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::distance_to_obstacle_costmap_provider
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 #include <mutex>
27 
30 
34 
36 #include <armarx/navigation/components/distance_to_obstacle_costmap_provider/ComponentInterface.h>
37 
38 
40 {
41 
42  class Component :
43  virtual public armarx::Component,
44  virtual public ObjectPoseClientPluginUser,
47  // , virtual public armarx::DebugObserverComponentPluginUser
48  // , virtual public armarx::LightweightRemoteGuiComponentPluginUser
49  // , virtual public armarx::ArVizComponentPluginUser
50  {
51  public:
52  Component();
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 
61  protected:
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 
78  /* (Requires armarx::LightweightRemoteGuiComponentPluginUser.)
79  /// This function should be called once in onConnect() or when you
80  /// need to re-create the Remote GUI tab.
81  void createRemoteGuiTab();
82 
83  /// After calling `RemoteGui_startRunningTask`, this function is
84  /// called periodically in a separate thread. If you update variables,
85  /// make sure to synchronize access to them.
86  void RemoteGui_update() override;
87  */
88 
89  bool createAndStoreCostmap();
90 
91  void run();
92 
93  private:
94  // Private methods go here.
95 
96  // Forward declare `Properties` if you used it before its defined.
97  // struct Properties;
98 
99  /* (Requires the armarx::ArVizComponentPluginUser.)
100  /// Draw some boxes in ArViz.
101  void drawBoxes(const Properties& p, viz::Client& arviz);
102  */
103 
104 
105  static const std::string defaultName;
106 
107 
108  // Private member variables go here.
109 
110 
111  /// Properties shown in the Scenario GUI.
112  struct Properties
113  {
114  std::string robotName;
115  std::string primitiveModelIds = "navigation";
116  };
117  Properties properties;
118  /* Use a mutex if you access variables from different threads
119  * (e.g. ice functions and RemoteGui_update()).
120  std::mutex propertiesMutex;
121  */
122 
123 
124  /* (Requires the armarx::LightweightRemoteGuiComponentPluginUser.)
125  /// Tab shown in the Remote GUI.
126  struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
127  {
128  armarx::RemoteGui::Client::LineEdit boxLayerName;
129  armarx::RemoteGui::Client::IntSpinBox numBoxes;
130 
131  armarx::RemoteGui::Client::Button drawBoxes;
132  };
133  RemoteGuiTab tab;
134  */
135 
136 
137  /* (Requires the armarx::ArVizComponentPluginUser.)
138  * When used from different threads, an ArViz client needs to be synchronized.
139  /// Protects the arviz client inherited from the ArViz plugin.
140  std::mutex arvizMutex;
141  */
142  std::optional<armem::robot::RobotDescription> robotDescription;
144  virtualRobotReaderPlugin = nullptr;
145 
146 
148  costmapWriterPlugin = nullptr;
149 
150 
152  };
153 
154 } // namespace armarx::navigation::components::distance_to_obstacle_costmap_provider
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::createAndStoreCostmap
bool createAndStoreCostmap()
Definition: Component.cpp:117
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::onDisconnectComponent
void onDisconnectComponent() override
Definition: Component.cpp:186
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::GetDefaultName
static std::string GetDefaultName()
Get the component's default name.
Definition: Component.cpp:203
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::onConnectComponent
void onConnectComponent() override
Definition: Component.cpp:75
armarx::navigation::components::distance_to_obstacle_costmap_provider::ComponentInterface
Definition: ComponentInterface.ice:30
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
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: Component.cpp:54
ReaderWriterPlugin.h
armarx::ObjectPoseClientPluginUser
Provides an objpose::ObjectPoseTopicPrx objectPoseTopic as member variable.
Definition: ObjectPoseClientPlugin.h:67
RunningTask.h
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::onInitComponent
void onInitComponent() override
Definition: Component.cpp:65
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::run
void run()
Definition: Component.cpp:109
VirtualRobotReader.h
Component.h
armarx::Component
Baseclass for all ArmarX ManagedIceObjects requiring properties.
Definition: Component.h:95
Writer.h
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component
Definition: Component.h:42
IceUtil::Handle< class PropertyDefinitionContainer >
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::onExitComponent
void onExitComponent() override
Definition: Component.cpp:192
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::Component
Component()
Definition: Component.cpp:45
armarx::navigation::components::distance_to_obstacle_costmap_provider
Definition: Component.cpp:43
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::getDefaultName
std::string getDefaultName() const override
Definition: Component.cpp:197