28 #include <Eigen/Eigen>
33 #include <ArmarXCore/interface/components/EmergencyStopInterface.h>
35 #include <RobotAPI/interface/units/LaserScannerUnit.h>
37 #include <RobotComponents/interface/components/LaserScannerSelfLocalisation.h>
39 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
40 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
41 #include <MemoryX/interface/memorytypes/MemorySegments.h>
66 std::shared_ptr<std::mutex>
mutex;
69 std::vector<ExtractedEdge>
edges;
92 defineOptionalProperty<std::string>(
"ReportTopicName",
93 "LaserScannerSelfLocalisationTopic",
94 "The name of the report topic.");
95 defineOptionalProperty<std::string>(
"RobotStateComponentName",
96 "RobotStateComponent",
97 "The name of the RobotStateComponent. Used to get "
98 "local transformation of laser scanners");
99 defineOptionalProperty<std::string>(
"PlatformName",
101 "Name of the platform to use. This property is "
102 "used to listen to the platform topic");
103 defineOptionalProperty<std::string>(
"LaserScannerUnitName",
104 "LaserScannerSimulation",
105 "Name of the laser scanner unit to use.");
106 defineOptionalProperty<std::string>(
"WorkingMemoryName",
108 "Name of the WorkingMemory that should be used");
109 defineOptionalProperty<std::string>(
110 "LongtermMemoryName",
"LongtermMemory",
"Name of the LongtermMemory component");
111 defineOptionalProperty<bool>(
112 "UpdateWorkingMemory",
114 "Update the working memory with the corrected position (disable in simulation)");
115 defineOptionalProperty<std::string>(
"MapFilename",
116 "RobotComponents/maps/building-5020-kitchen.json",
117 "Floor map (2D) used for global localisation");
118 defineOptionalProperty<std::string>(
"AgentName",
120 "Name of the agent instance. If empty, the robot "
121 "name of the RobotStateComponent will be used");
122 defineOptionalProperty<std::string>(
123 "EmergencyStopMasterName",
124 "EmergencyStopMaster",
125 "The name used to register as an EmergencyStopMaster");
126 defineOptionalProperty<std::string>(
"DebugObserverName",
128 "Name of the topic the DebugObserver listens on");
130 defineOptionalProperty<int>(
131 "UpdatePeriodInMs", 5,
"Update period used for the map localisation");
132 defineOptionalProperty<int>(
"UpdatePeriodWorkingMemoryInMs",
134 "Update period used for updating the working memory");
135 defineOptionalProperty<int>(
"UpdatePeriodLongtermMemoryInMs",
137 "Update period used for updating the longterm memory");
138 defineOptionalProperty<float>(
"RobotPositionZ",
140 "The z-coordinate of the reported postion. Laser "
141 "scanners can only self localize in x,y.");
143 defineOptionalProperty<float>(
"MaximalLaserScannerDelay",
145 "If no new sensor values have been reported for this "
146 "amound of seconds, we emit a soft emergency stop");
148 defineOptionalProperty<int>(
"SmoothFrameSize",
150 "Frame size used for smoothing of laser scanner input",
152 defineOptionalProperty<int>(
153 "SmoothMergeDistance",
155 "Distance in mm up to which laser scanner points are merged",
157 defineOptionalProperty<float>(
158 "MatchingMaxDistance",
160 "Maximal distance in mm up to which points are matched against edges of the map",
162 defineOptionalProperty<float>(
165 "Minimum percentage of points which need to be matched (range [0, 1]). If less "
166 "points are matched no global correction is applied.",
168 defineOptionalProperty<float>(
169 "MatchingCorrectionFactor",
171 "This factor is used to apply the calculated map correction (range [0, 1])",
173 defineOptionalProperty<float>(
"EdgeMaxDistance",
175 "Maximum distance between adjacent points up to which "
176 "they are merged into one edge [mm]",
178 defineOptionalProperty<float>(
181 "Maximum angle delta up to which adjacent points are merged into one edge [rad]",
183 defineOptionalProperty<float>(
"EdgePointAddingThreshold",
185 "Maximum least square error up to which points are added "
186 "to an edge (extension at the front and back)",
188 defineOptionalProperty<int>(
"EdgeEpsilon",
190 "Half frame size for line regression (angle calculation)",
192 defineOptionalProperty<int>(
195 "Minimum number of points per edge (no edges with less points will be extracted)",
198 defineOptionalProperty<bool>(
"UseOdometry",
200 "Enable or disable odometry for pose estimation",
202 defineOptionalProperty<bool>(
"UseMapCorrection",
204 "Enable or disable map localisation for pose correction",
206 defineOptionalProperty<bool>(
209 "Enable or disable the reports of (post-processed) laser scan points",
211 defineOptionalProperty<bool>(
"ReportEdges",
213 "Enable or disable the reports of extracted edges",
216 defineOptionalProperty<float>(
219 "Standard deviation in position of the localization result",
221 defineOptionalProperty<float>(
"VelSensorStdDev",
223 "Standard deviation of the reported velocity",
226 defineOptionalProperty<std::string>(
"LoggingFilePath",
228 "Path to sensor data log file",
230 defineOptionalProperty<bool>(
233 "If true, data is logged. Can be changed online. When set to false online, data is "
234 "written to file. Otherwise on disconnect.",
237 defineOptionalProperty<std::string>(
238 "PlatformRectangleMin",
240 "Ignores points within the platform rectangle (this is the min x/y point)");
241 defineOptionalProperty<std::string>(
242 "PlatformRectangleMax",
244 "Ignores points within the platform rectangle (this is the max x/y point)");
269 virtual public armarx::LaserScannerSelfLocalisationInterface
280 return "LaserScannerSelfLocalisation";
313 LineSegment2DSeq
getMap(
const Ice::Current&)
override;
317 const std::string& name,
318 const LaserScan& scan,
319 const TimestampBasePtr& timestamp,
320 const Ice::Current&)
override;
326 const Ice::Current&)
override;
330 const Ice::Current&)
override;
336 void updateLocalisation();
340 void resetKalmanFilter(
const Eigen::Vector3f& pose);
341 Eigen::Vector3f filterPose(
const Eigen::Vector3f& pose);
345 std::string reportTopicName;
346 std::string robotStateComponentName;
347 std::string platformName;
348 std::string laserScannerUnitName;
349 std::string workingMemoryName;
350 std::string longtermMemoryName;
351 std::string mapFilename;
352 std::string agentName;
353 std::string robotRootFrame;
355 std::string emergencyStopMasterName;
356 std::string debugObserverName;
357 float workingMemoryUpdateFrequency;
358 float longtermMemoryUpdateFrequency;
359 float robotPositionZ = 0.0f;
360 float maximalLaserScannerDelay = 0.1f;
362 std::mutex propertyMutex;
363 int propSmoothFrameSize;
364 int propSmoothMergeDistance;
365 float propMatchingMaxDistance;
366 float propMatchingMinPoints;
367 float propMatchingCorrectionFactor;
368 float propEdgeMaxDistance;
369 float propEdgeMaxDeltaAngle;
370 float propEdgePointAddingThreshold;
372 int propEdgeMinPoints;
373 bool propReportPoints;
374 bool propReportEdges;
375 bool propUseOdometry;
376 bool propUseMapCorrection;
377 float propSensorStdDev;
378 float propVelSensorStdDev;
379 std::string propLoggingFilePath;
380 bool propRecordData =
false;
382 std::atomic<bool> useOdometry;
384 std::vector<LineSegment2Df> map;
387 LaserScannerUnitInterfacePrx laserScannerUnit;
388 LaserScannerSelfLocalisationListenerPrx reportTopic;
389 PlatformUnitListenerPrx platformUnitTopic;
391 GlobalRobotPoseLocalizationListenerPrx globalRobotPoseTopic;
394 memoryx::WorkingMemoryInterfacePrx workingMemory;
395 memoryx::AgentInstancesSegmentBasePrx agentsMemory;
397 bool updateWorkingMemory =
false;
398 memoryx::LongtermMemoryInterfacePrx longtermMemory;
399 memoryx::PersistentEntitySegmentBasePrx selfLocalisationSegment;
400 std::string poseEntityId;
402 std::vector<LaserScanData> scanData;
404 std::mutex setPoseMutex;
405 std::optional<Eigen::Vector3f> setPose;
407 std::mutex odometryMutex;
408 std::vector<ReportedVelocity> reportedVelocities;
409 Eigen::Vector3f lastVelocity;
412 Eigen::Vector3f estimatedPose;
414 Eigen::Vector2f platformRectMin{0, 0};
415 Eigen::Vector2f platformRectMax{0, 0};
421 std::mutex kalmanMutex;
424 struct LaserScannerFileLoggingData
426 std::mutex loggingMutex;
427 std::string filePath;
429 std::map<IceUtil::Time, std::vector<LaserScanData>> scanDataHistory;
432 std::unique_ptr<LaserScannerFileLoggingData> laserScannerFileLoggingData;