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 
35 
36 #include <armarx/navigation/components/distance_to_obstacle_costmap_provider/ComponentInterface.h>
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  // Private member variables go here.
108 
109 
110  /// Properties shown in the Scenario GUI.
111  struct Properties
112  {
113  std::string robotName;
114  std::string primitiveModelIds = "navigation";
115  std::string colModel = "Platform-navigation-colmodel";
116 
117  algorithms::Costmap::Parameters costmapBuilderParams;
118 
119  };
120 
121  Properties properties;
122  /* Use a mutex if you access variables from different threads
123  * (e.g. ice functions and RemoteGui_update()).
124  std::mutex propertiesMutex;
125  */
126 
127 
128  /* (Requires the armarx::LightweightRemoteGuiComponentPluginUser.)
129  /// Tab shown in the Remote GUI.
130  struct RemoteGuiTab : armarx::RemoteGui::Client::Tab
131  {
132  armarx::RemoteGui::Client::LineEdit boxLayerName;
133  armarx::RemoteGui::Client::IntSpinBox numBoxes;
134 
135  armarx::RemoteGui::Client::Button drawBoxes;
136  };
137  RemoteGuiTab tab;
138  */
139 
140 
141  /* (Requires the armarx::ArVizComponentPluginUser.)
142  * When used from different threads, an ArViz client needs to be synchronized.
143  /// Protects the arviz client inherited from the ArViz plugin.
144  std::mutex arvizMutex;
145  */
146  std::optional<armem::robot_state::description::RobotDescription> robotDescription;
148  virtualRobotReaderPlugin = nullptr;
149 
150 
153  articulatedObjectReaderPlugin = nullptr;
154 
155 
157  costmapWriterPlugin = nullptr;
158 
159 
161  };
162 
163 } // namespace armarx::navigation::components::distance_to_obstacle_costmap_provider
armarx::armem::articulated_object::ArticulatedObjectReader
Definition: ArticulatedObjectReader.h:10
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::createAndStoreCostmap
bool createAndStoreCostmap()
Definition: Component.cpp:128
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::onDisconnectComponent
void onDisconnectComponent() override
Definition: Component.cpp:244
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::GetDefaultName
static std::string GetDefaultName()
Get the component's default name.
Definition: Component.cpp:261
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::onConnectComponent
void onConnectComponent() override
Definition: Component.cpp:86
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:59
ReaderWriterPlugin.h
armarx::ObjectPoseClientPluginUser
Provides an objpose::ObjectPoseTopicPrx objectPoseTopic as member variable.
Definition: ObjectPoseClientPlugin.h:67
RunningTask.h
ArticulatedObjectReader.h
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::onInitComponent
void onInitComponent() override
Definition: Component.cpp:76
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::run
void run()
Definition: Component.cpp:120
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:250
armarx::navigation::algorithms::Costmap::Parameters
Definition: Costmap.h:21
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::Component
Component()
Definition: Component.cpp:49
armarx::navigation::components::distance_to_obstacle_costmap_provider
Definition: Component.cpp:47
armarx::navigation::components::distance_to_obstacle_costmap_provider::Component::getDefaultName
std::string getDefaultName() const override
Definition: Component.cpp:255