54 const std::string Component::defaultName =
"dynamic_scene_provider";
59 addPlugin(laserScannerFeaturesReaderPlugin);
64 addPlugin(laserScannerFeaturesWriterPlugin);
88 properties.taskPeriodMs,
"p.taskPeriodMs",
"Update rate of the running task.");
90 def->optional(properties.laserScannerFeatures.enabled,
91 "p.laserScannerFeatures.enabled",
92 "Whether laser scanner features are used.");
93 def->optional(properties.laserScannerFeatures.providerName,
94 "p.laserScannerFeatures.providerName",
96 def->optional(properties.laserScannerFeatures.name,
"p.laserScannerFeatures.name",
"");
98 def->required(properties.robot.name,
"p.robot.name",
"");
100 def->optional(properties.occupancyGrid.providerName,
"p.occupancyGrid.providerName",
"");
101 def->optional(properties.occupancyGrid.name,
"p.occupancyGrid.name",
"");
103 properties.occupancyGrid.freespaceThreshold,
"p.occupancyGrid.freespaceThreshold",
"");
105 properties.occupancyGrid.occupiedThreshold,
"p.occupancyGrid.occupiedThreshold",
"");
108 properties.humanPoses.enabled,
"p.humanPoses.enabled",
"Whether human poses are used.");
109 def->optional(properties.humanPoses.providerName,
"p.humanPoses.providerName",
"");
160 robot = virtualRobotReaderPlugin->get().getRobotWaiting(properties.robot.name);
161 if (robot !=
nullptr)
170 humanTracker.reset();
173 this, &Component::runPeriodically, properties.taskPeriodMs,
false,
"runningTask");
191 return Component::defaultName;
197 return Component::defaultName;
201 Component::runPeriodically()
203 const auto logDuration = [
this](
const std::string& name,
const Duration& duration)
206 const auto makeSWlog = [&](
const std::string& name)
207 {
return [=](
const Duration& duration) { logDuration(name, duration); }; };
221 if (not virtualRobotReaderPlugin->get().synchronizeRobotPose(*robot,
timestamp))
227 const core::Pose global_T_robot(robot->getGlobalPose());
229 ARMARX_VERBOSE <<
"Robot position: " << global_T_robot.translation().head<2>();
236 const std::vector<armem::human::HumanPose> humanPoses = [&]
238 if (!properties.humanPoses.enabled)
240 return std::vector<armem::human::HumanPose>{};
243 armarx::core::time::ScopedStopWatch sw(makeSWlog(
"dynamic_scene.read_human"));
246 const armem::human::client::Reader::Query humanPoseQuery{
247 .providerName = properties.humanPoses.providerName,
251 const armem::human::client::Reader::Result humanPoseResult =
252 humanPoseReaderPlugin->get().query(humanPoseQuery);
266 const memory::LaserScannerFeatures laserFeatures = [&]() -> memory::LaserScannerFeatures
268 if (!properties.laserScannerFeatures.enabled)
270 return memory::LaserScannerFeatures{};
273 armarx::core::time::ScopedStopWatch sw(makeSWlog(
"dynamic_scene.read_laserscanner"));
276 const memory::client::laser_scanner_features::Reader::Query laserFeaturesQuery{
277 .providerName = properties.laserScannerFeatures.providerName,
278 .name = properties.laserScannerFeatures.name,
281 const memory::client::laser_scanner_features::Reader::Result laserFeaturesResult =
282 laserScannerFeaturesReaderPlugin->get().queryData(laserFeaturesQuery);
284 if (laserFeaturesResult.status !=
287 ARMARX_VERBOSE <<
"Querying laser scanner features failed. Reason: "
288 << laserFeaturesResult.errorMessage;
295 << laserFeaturesResult.errorMessage;
297 ARMARX_VERBOSE << laserFeaturesResult.features.size() <<
" clusters/features";
299 if (laserFeaturesResult.features.empty())
306 <<
"We request the merged instance with only one result";
308 return laserFeaturesResult.features.front();
429 if (properties.humanPoses.enabled)
431 armarx::core::time::ScopedStopWatch sw(makeSWlog(
"dynamic_scene.human_tracker.camera"));
433 ARMARX_VERBOSE <<
"Running human tracker with camera measurements";
434 humanTracker.update(human::HumanTracker::CameraMeasurement{.detectionTime =
timestamp,
435 .humanPoses = humanPoses});
440 const std::vector<memory::LaserScannerFeature> unusedFeatures = [&]
442 if (!properties.laserScannerFeatures.enabled)
444 return std::vector<memory::LaserScannerFeature>{};
447 armarx::core::time::ScopedStopWatch sw(
448 makeSWlog(
"dynamic_scene.human_tracker.laserscanner"));
450 ARMARX_VERBOSE <<
"Running human tracker with lasersensor measurements";
452 return humanTracker.update(human::HumanTracker::LaserMeasurement{
453 .detectionTime =
timestamp, .clusters = laserFeatures.features});
465 armarx::core::time::ScopedStopWatch sw(makeSWlog(
"dynamic_scene.write_back_human"));
468 std::vector<human::Human> humans = humanTracker.getTrackedHumans();
470 if (not humans.empty())
476 if (not unusedFeatures.empty())
479 <<
" laser scanner features not associated with humans";
481 laserScannerFeaturesWriterPlugin->get().store(
482 memory::LaserScannerFeatures{.frame =
"global",
483 .frameGlobalPose = Eigen::Isometry3f::Identity(),
484 .features = unusedFeatures},
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
armarx::viz::Client & getArvizClient()
static DateTime Now()
Current time on the virtual clock.
static void WaitFor(const Duration &duration)
Wait for a certain duration on the virtual clock.
Default component property definition container.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
void setDebugObserverDatafield(Ts &&... ts) const
void sendDebugObserverBatch()
void setDebugObserverBatchModeEnabled(bool enable)
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
bool usingProxy(const std::string &name, const std::string &endpoints="")
Registers a proxy for retrieval after initialization and adds it to the dependency list.
PluginT * addPlugin(const std::string prefix="", ParamsT &&... params)
std::string getName() const
Retrieve name of object.
The periodic task executes one thread method repeatedly using the time period specified in the constr...
Represents a point in time.
Measures the time this stop watch was inside the current scope.
void onInitComponent() override
void onDisconnectComponent() override
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectComponent() override
static std::string GetDefaultName()
Get the component's default name.
void onExitComponent() override
std::string getDefaultName() const override
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
#define ARMARX_CHECK_EQUAL(lhs, rhs)
This macro evaluates whether lhs is equal (==) rhs and if it turns out to be false it will throw an E...
#define ARMARX_INFO
The normal logging level.
#define ARMARX_VERBOSE
The logging level for verbose information.
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
enum armarx::armem::human::client::Reader::Result::Status status
std::vector< HumanPose > humanPoses