HokuyoLaserUnit.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 RobotAPI::ArmarXObjects::HokuyoLaserUnit
17  * @author Fabian Paus ( fabian dot paus at kit dot edu )
18  * @date 2017
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #pragma once
24 
25 #include <vector>
26 
29 
31 #include <RobotAPI/interface/components/RobotHealthInterface.h>
32 #include <RobotAPI/interface/units/LaserScannerUnit.h>
34 
35 #include <HokuyoLaserScannerDriver/urg_sensor.h>
36 
37 namespace armarx
38 {
39  /**
40  * @class HokuyoLaserUnitPropertyDefinitions
41  * @brief
42  */
44  {
45  public:
48  {
49  defineOptionalProperty<std::string>(
50  "LaserScannerListenerName", "CartographerMappingAndLocalization", "Name of the laser scan listener.");
51  defineOptionalProperty<int>("UpdatePeriod", 25, "Update period for laser scans");
52  defineOptionalProperty<float>("AngleOffset",
53  -2.3561944902,
54  "Offset is applied the raw angles before reporting them");
55  defineOptionalProperty<std::string>(
56  "Devices",
57  "",
58  "List of devices in form of 'IP1,port1,frame1;IP2,port2,frame2;...'");
59 
60  defineOptionalProperty<std::string>(
61  "RobotHealthComponentName", "RobotHealth", "Name of the RobotHealth component");
62  defineOptionalProperty<std::string>(
63  "RobotHealthTopicName", "RobotHealthTopic", "Name of the RobotHealth topic");
64  defineOptionalProperty<std::string>("DebugObserverName",
65  "DebugObserver",
66  "Name of the topic the DebugObserver listens on");
67  }
68  };
69 
71  {
72  std::string ip;
73  int port = 0;
74  std::string frame;
75  float angleOffset = 0.0f;
76  bool connected = false;
77  urg_t urg;
78  std::vector<long> lengthData;
79  int errorCounter = 0;
80 
81  bool reconnect();
82 
83 
84  void run();
85 
87  LaserScan scan;
88 
89  std::string componentName;
90  LaserScannerUnitListenerPrx listenerPrx;
93  };
94 
95  /**
96  * @defgroup Component-HokuyoLaserUnit HokuyoLaserUnit
97  * @ingroup RobotAPI-Components
98  * A description of the component HokuyoLaserUnit.
99  *
100  * @class HokuyoLaserUnit
101  * @ingroup Component-HokuyoLaserUnit
102  * @brief Brief description of class HokuyoLaserUnit.
103  *
104  * Detailed description of class HokuyoLaserUnit.
105  */
107  virtual public armarx::LaserScannerUnitInterface,
108  virtual public armarx::SensorActorUnit
109  {
110  public:
111  HokuyoLaserUnit();
112 
113  /**
114  * @see armarx::ManagedIceObject::getDefaultName()
115  */
116  std::string
117  getDefaultName() const override
118  {
119  return "HokuyoLaserUnit";
120  }
121 
122  protected:
123  /**
124  * @see armarx::ManagedIceObject::onInitComponent()
125  */
126  void onInitComponent() override;
127 
128  /**
129  * @see armarx::ManagedIceObject::onConnectComponent()
130  */
131  void onConnectComponent() override;
132 
133  /**
134  * @see armarx::ManagedIceObject::onDisconnectComponent()
135  */
136  void onDisconnectComponent() override;
137 
138  /**
139  * @see armarx::ManagedIceObject::onExitComponent()
140  */
141  void onExitComponent() override;
142 
143  /**
144  * @see PropertyUser::createPropertyDefinitions()
145  */
147 
148  std::string getReportTopicName(const Ice::Current& c) const override;
149 
150  LaserScannerInfoSeq getConnectedDevices(const Ice::Current& c) const override;
151 
152  private:
153  std::string laserScannerListenerProxyName;
154  LaserScannerUnitListenerPrx listenerPrx;
155  int updatePeriod = 25;
156  float angleOffset = 0.0f;
157  std::vector<HokuyoLaserScanDevice> devices;
158  LaserScannerInfoSeq connectedDevices;
159  DebugObserverInterfacePrx debugObserver;
160 
161  plugins::HeartbeatComponentPlugin* heartbeat = nullptr;
162  };
163 } // namespace armarx
armarx::HokuyoLaserUnit::HokuyoLaserUnit
HokuyoLaserUnit()
Definition: HokuyoLaserUnit.cpp:37
armarx::HokuyoLaserUnit::onInitComponent
void onInitComponent() override
Definition: HokuyoLaserUnit.cpp:44
armarx::HokuyoLaserScanDevice::task
RunningTask< HokuyoLaserScanDevice >::pointer_type task
Definition: HokuyoLaserUnit.h:86
armarx::HokuyoLaserScanDevice::errorCounter
int errorCounter
Definition: HokuyoLaserUnit.h:79
armarx::PropertyDefinitionContainer::prefix
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Definition: PropertyDefinitionContainer.h:333
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::HokuyoLaserUnit::onDisconnectComponent
void onDisconnectComponent() override
Definition: HokuyoLaserUnit.cpp:153
armarx::HokuyoLaserScanDevice::port
int port
Definition: HokuyoLaserUnit.h:73
RunningTask.h
armarx::plugins::HeartbeatComponentPlugin
Definition: HeartbeatComponentPlugin.h:33
armarx::HokuyoLaserUnitPropertyDefinitions
Definition: HokuyoLaserUnit.h:43
armarx::HokuyoLaserScanDevice::frame
std::string frame
Definition: HokuyoLaserUnit.h:74
armarx::HokuyoLaserUnit::onExitComponent
void onExitComponent() override
Definition: HokuyoLaserUnit.cpp:171
armarx::HokuyoLaserScanDevice::run
void run()
Definition: HokuyoLaserUnit.cpp:229
armarx::HokuyoLaserScanDevice::reconnect
bool reconnect()
Definition: HokuyoLaserUnit.cpp:195
SensorActorUnit.h
armarx::HokuyoLaserUnit::onConnectComponent
void onConnectComponent() override
Definition: HokuyoLaserUnit.cpp:92
armarx::HokuyoLaserUnitPropertyDefinitions::HokuyoLaserUnitPropertyDefinitions
HokuyoLaserUnitPropertyDefinitions(std::string prefix)
Definition: HokuyoLaserUnit.h:46
armarx::HokuyoLaserScanDevice
Definition: HokuyoLaserUnit.h:70
armarx::HokuyoLaserScanDevice::componentName
std::string componentName
Definition: HokuyoLaserUnit.h:89
armarx::HokuyoLaserUnit::getConnectedDevices
LaserScannerInfoSeq getConnectedDevices(const Ice::Current &c) const override
Definition: HokuyoLaserUnit.cpp:189
HeartbeatComponentPlugin.h
Component.h
armarx::HokuyoLaserScanDevice::urg
urg_t urg
Definition: HokuyoLaserUnit.h:77
armarx::HokuyoLaserScanDevice::debugObserver
DebugObserverInterfacePrx debugObserver
Definition: HokuyoLaserUnit.h:92
armarx::HokuyoLaserUnit::createPropertyDefinitions
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
Definition: HokuyoLaserUnit.cpp:176
armarx::HokuyoLaserUnit::getDefaultName
std::string getDefaultName() const override
Definition: HokuyoLaserUnit.h:117
armarx::ComponentPropertyDefinitions
Default component property definition container.
Definition: Component.h:70
IceUtil::Handle
Definition: forward_declarations.h:29
armarx::HokuyoLaserUnit::getReportTopicName
std::string getReportTopicName(const Ice::Current &c) const override
Definition: HokuyoLaserUnit.cpp:183
armarx::SensorActorUnit
Base Class for SensorActorUnits.
Definition: SensorActorUnit.h:42
IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface >
armarx::HokuyoLaserScanDevice::angleOffset
float angleOffset
Definition: HokuyoLaserUnit.h:75
armarx::HokuyoLaserScanDevice::robotHealthPlugin
armarx::plugins::HeartbeatComponentPlugin * robotHealthPlugin
Definition: HokuyoLaserUnit.h:91
armarx::HokuyoLaserScanDevice::lengthData
std::vector< long > lengthData
Definition: HokuyoLaserUnit.h:78
armarx::HokuyoLaserUnit
Brief description of class HokuyoLaserUnit.
Definition: HokuyoLaserUnit.h:106
armarx::HokuyoLaserScanDevice::connected
bool connected
Definition: HokuyoLaserUnit.h:76
armarx::HokuyoLaserScanDevice::ip
std::string ip
Definition: HokuyoLaserUnit.h:72
armarx::HokuyoLaserScanDevice::listenerPrx
LaserScannerUnitListenerPrx listenerPrx
Definition: HokuyoLaserUnit.h:90
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::HokuyoLaserScanDevice::scan
LaserScan scan
Definition: HokuyoLaserUnit.h:87