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
37namespace armarx
38{
39 /**
40 * @class HokuyoLaserUnitPropertyDefinitions
41 * @brief
42 */
44 {
45 public:
48 {
49 defineOptionalProperty<std::string>("LaserScannerListenerName",
50 "CartographerMappingAndLocalization",
51 "Name of the laser scan listener.");
52 defineOptionalProperty<int>("UpdatePeriod", 25, "Update period for laser scans");
54 -2.3561944902,
55 "Offset is applied the raw angles before reporting them");
57 "Devices",
58 "",
59 "List of devices in form of 'IP1,port1,frame1;IP2,port2,frame2;...'");
60
62 "RobotHealthComponentName", "RobotHealth", "Name of the RobotHealth component");
64 "RobotHealthTopicName", "RobotHealthTopic", "Name of the RobotHealth topic");
65 defineOptionalProperty<std::string>("DebugObserverName",
66 "DebugObserver",
67 "Name of the topic the DebugObserver listens on");
68 }
69 };
70
72 {
73 std::string ip;
74 int port = 0;
75 std::string frame;
76 float angleOffset = 0.0f;
77 bool connected = false;
78 urg_t urg;
79 std::vector<long> lengthData;
80 int errorCounter = 0;
81
82 bool reconnect();
83
84
85 void run();
86
88 LaserScan scan;
89
90 std::string componentName;
91 LaserScannerUnitListenerPrx listenerPrx;
94 };
95
96 /**
97 * @defgroup Component-HokuyoLaserUnit HokuyoLaserUnit
98 * @ingroup RobotAPI-Components
99 * A description of the component HokuyoLaserUnit.
100 *
101 * @class HokuyoLaserUnit
102 * @ingroup Component-HokuyoLaserUnit
103 * @brief Brief description of class HokuyoLaserUnit.
104 *
105 * Detailed description of class HokuyoLaserUnit.
106 */
108 virtual public armarx::LaserScannerUnitInterface,
109 virtual public armarx::SensorActorUnit
110 {
111 public:
113
114 /**
115 * @see armarx::ManagedIceObject::getDefaultName()
116 */
117 std::string
118 getDefaultName() const override
119 {
120 return "HokuyoLaserUnit";
121 }
122
123 protected:
124 /**
125 * @see armarx::ManagedIceObject::onInitComponent()
126 */
127 void onInitComponent() override;
128
129 /**
130 * @see armarx::ManagedIceObject::onConnectComponent()
131 */
132 void onConnectComponent() override;
133
134 /**
135 * @see armarx::ManagedIceObject::onDisconnectComponent()
136 */
137 void onDisconnectComponent() override;
138
139 /**
140 * @see armarx::ManagedIceObject::onExitComponent()
141 */
142 void onExitComponent() override;
143
144 /**
145 * @see PropertyUser::createPropertyDefinitions()
146 */
148
149 std::string getReportTopicName(const Ice::Current& c) const override;
150
151 LaserScannerInfoSeq getConnectedDevices(const Ice::Current& c) const override;
152
153 private:
154 std::string laserScannerListenerProxyName;
155 LaserScannerUnitListenerPrx listenerPrx;
156 int updatePeriod = 25;
157 float angleOffset = 0.0f;
158 std::vector<HokuyoLaserScanDevice> devices;
159 LaserScannerInfoSeq connectedDevices;
160 DebugObserverInterfacePrx debugObserver;
161
162 plugins::HeartbeatComponentPlugin* heartbeat = nullptr;
163 };
164} // namespace armarx
constexpr T c
Default component property definition container.
Definition Component.h:70
ComponentPropertyDefinitions(std::string prefix, bool hasObjectNameParameter=true)
Definition Component.cpp:46
void onInitComponent() override
LaserScannerInfoSeq getConnectedDevices(const Ice::Current &c) const override
void onDisconnectComponent() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectComponent() override
std::string getReportTopicName(const Ice::Current &c) const override
void onExitComponent() override
std::string getDefaultName() const override
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
PropertyDefinition< PropertyType > & defineOptionalProperty(const std::string &name, PropertyType defaultValue, const std::string &description="", PropertyDefinitionBase::PropertyConstness constness=PropertyDefinitionBase::eConstant)
IceUtil::Handle< RunningTask< T > > pointer_type
Shared pointer type for convenience.
Base Class for SensorActorUnits.
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::DebugObserverInterface > DebugObserverInterfacePrx
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
LaserScannerUnitListenerPrx listenerPrx
std::vector< long > lengthData
RunningTask< HokuyoLaserScanDevice >::pointer_type task
DebugObserverInterfacePrx debugObserver
armarx::plugins::HeartbeatComponentPlugin * robotHealthPlugin