LaserScansMemory.cpp
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 * @author Fabian Reister ( fabian dot reister at kit dot edu )
17 * @date 2022
18 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
19 * GNU General Public License
20 */
21
22#include "LaserScansMemory.h"
23
24#include <SimoxUtility/algorithm/string.h>
25
28
33#include <RobotAPI/libraries/armem_laser_scans/aron/LaserScan.aron.generated.h>
34
36
38 "LaserScansMemory");
39
41{
43 {
44 addPlugin(virtualRobotReaderPlugin);
45 addPlugin(debugObserver);
46 }
47
50 {
53
54 workingMemory().name() = "LaserScans";
55
56 {
57 const std::string prefix = "";
58 commonVisu.defineProperties(defs, prefix + "visu.");
59 }
60
61 defs->optional(properties_.coreSeg.laserScans.maxHistorySize,
62 "LaserScans.CoreMaxHistorySize",
63 "Max history size of the " + QUOTED("LaserScans") + " core segment.");
64
65 return defs;
66 }
67
68 std::string
70 {
71 return "LaserScansMemory";
72 }
73
74 void
76 {
77 auto& coreSegment = workingMemory().addCoreSegment(
78 "LaserScans", armarx::armem::laser_scans::arondto::LaserScanStamped::ToAronType());
79
80 coreSegment.setMaxHistorySize(properties_.coreSeg.laserScans.maxHistorySize);
81
82 commonVisu.init(&coreSegment, &virtualRobotReaderPlugin->get());
83 }
84
85 void
87 {
88 commonVisu.connect(getArvizClient(), debugObserver->getDebugObserver());
89 commonVisu.connectRemoteGui(this, "Laser Scanner Calibration");
91 }
92
93 void
95 {
96 commonVisu.remoteGuiUpdate();
97 }
98
99 void
101 {
102 // Stop the visualization task before the core segment and the ArViz client go away.
103 commonVisu.disconnect();
104 }
105
106 void
110
111 armem::data::AddSegmentsResult
112 LaserScansMemory::addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&)
113 {
114 // Allowing adding core segments.
115 armem::data::AddSegmentsResult result =
116 ReadWritePluginUser::addSegments(input, addCoreSegmentOnUsage);
117
118 // Core segments created on usage do not inherit this component's history limit - they get
119 // the library default of 120,000 snapshots per entity, which is ~1.5 GB per sensor frame at
120 // laser-scan sizes. Apply the configured limit to them as well.
121 if (addCoreSegmentOnUsage)
122 {
124 [this](armem::server::wm::CoreSegment& coreSegment)
125 {
126 if (coreSegment.getMaxHistorySize() !=
127 properties_.coreSeg.laserScans.maxHistorySize)
128 {
129 coreSegment.setMaxHistorySize(
130 properties_.coreSeg.laserScans.maxHistorySize);
131 }
132 });
133 }
134
135 return result;
136 }
137
138} // namespace armarx::armem::server::laser_scans
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
Definition Decoupled.h:29
#define QUOTED(x)
armarx::viz::Client & getArvizClient()
Default component property definition container.
Definition Component.h:70
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
Definition Component.cpp:88
PluginT * addPlugin(const std::string prefix="", ParamsT &&... params)
bool forEachCoreSegment(CoreSegmentFunctionT &&func)
Definition MemoryBase.h:188
virtual data::AddSegmentsResult addSegments(const data::AddSegmentsInput &input, const Ice::Current &=Ice::emptyCurrent) override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
armem::data::AddSegmentsResult addSegments(const armem::data::AddSegmentsInput &input, const Ice::Current &) override
CoreSegment & addCoreSegment(const std::string &name, Args... args)
void setMaxHistorySize(long maxSize)
Sets the maximum history size of entities in this container.
This file is part of ArmarX.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.