33#include <Ice/LocalException.h>
35#include <range/v3/range/conversion.hpp>
36#include <range/v3/view/enumerate.hpp>
37#include <range/v3/view/filter.hpp>
38#include <range/v3/view/transform.hpp>
40#include <SimoxUtility/color/Color.h>
41#include <SimoxUtility/color/GlasbeyLUT.h>
60#include <RobotAPI/libraries/armem_locations/aron/Location.aron.generated.h>
65#include <armarx/navigation/algorithms/aron/Room.aron.generated.h>
71#include <armarx/navigation/core/aron/Graph.aron.generated.h>
74#include <armarx/navigation/human/aron/Human.aron.generated.h>
77#include <armarx/navigation/memory/aron/LaserScannerFeatures.aron.generated.h>
108 const std::vector<ObjectInfo>& info,
112 std::map<armem::MemoryID, location::arondto::Location> raw;
122 location::arondto::Location dto;
123 dto.fromAron(instance->data());
124 raw[entity.
id()] = dto;
130 for (
const auto& [
id, location] : raw)
133 FramedPose framedPose;
134 fromAron(location.framedPose, framedPose);
137 if (res.pose.has_value())
139 visu->vertex->draw(layer,
id.
str(), res.pose.value());
146 const std::vector<ObjectInfo>& info,
147 std::vector<viz::Layer>& layers)
150 std::map<armem::MemoryID, navigation::core::arondto::Graph> raw;
154 using namespace armem::server;
156 [&](
const wm::Entity& entity)
160 navigation::core::arondto::Graph dto;
161 dto.fromAron(instance->data());
162 raw[entity.
id()] = dto;
168 for (
auto& [
id, dto] : raw)
170 viz::Layer& layer = layers.emplace_back(
arviz.layer(
id.str()));
174 visu->draw(layer, graph, {.objects=objects, .info=info});
183 const std::vector<ObjectInfo> info;
200 const std::vector<ObjectInfo> info = objectFinder.findAllObjects();
204 catch (const ::Ice::NotRegisteredException& e)
206 ARMARX_VERBOSE <<
"Failed to retrieve objects from ObjectMemory: " << e.what();
215 const std::vector<ObjectInfo> info;
231 const std::vector<ObjectInfo> info = objectFinder.findAllObjects();
235 catch (const ::Ice::NotRegisteredException& e)
237 ARMARX_VERBOSE <<
"Failed to retrieve objects from ObjectMemory: " << e.what();
252 std::vector<RawCostmap> raw;
263 const std::string entityIdStr = instance->id().getEntityID().str();
264 const auto it = lastCostmapVisualization_.find(entityIdStr);
265 if (it == lastCostmapVisualization_.end() ||
266 it->second < instance->id().timestamp)
271 lastCostmapVisualization_[entityIdStr] = instance->id().timestamp;
278 for (
auto& [
id, costmap] : raw)
282 arviz.layer(
"costmaps_" +
id.providerSegmentName +
"_" +
id.entityName));
289 const bool visuTransparent,
294 std::string providerName;
296 navigation::human::arondto::Human dto;
299 std::set<std::string> providerNames;
300 std::vector<RawHuman> raw;
319 navigation::human::arondto::Human::FromAron(
326 std::map<std::string, navigation::human::Humans> namedProviderHumans;
327 for (
const auto& providerName : providerNames)
329 namedProviderHumans[providerName];
332 for (
const auto& entry : raw)
335 if (dtToNow < maxAge and dtToNow.
isPositive())
339 namedProviderHumans[entry.providerName].emplace_back(std::move(
human));
343 for (
const auto& [providerName, humans] : namedProviderHumans)
345 viz::Layer& layer = layers.emplace_back(
arviz.layer(
"humans_" + providerName));
346 drawHumansInLayer(humans, layer, visuTransparent);
354 std::map<armem::MemoryID, std::optional<navigation::algorithms::arondto::Room>> raw;
362 std::optional<navigation::algorithms::arondto::Room> dto;
365 auto& d = dto.emplace();
366 d.fromAron(instance->data());
368 raw[entity.
id()] = dto;
374 for (
const auto& [
id, dto] : raw)
381 drawRoom(layer, room, simox::color::GlasbeyLUT::at(i));
391 static const std::string globalEntityName =
"global";
394 layers.emplace_back(
arviz.layer(
"laser_scanner_features_convex_hulls"));
395 viz::Layer& chainLayer = layers.emplace_back(
arviz.layer(
"laser_scanner_features_chains"));
397 struct RawLaserScannerFeatures
400 memory::arondto::LaserScannerFeatures dto;
404 std::vector<RawLaserScannerFeatures> raw;
414 auto& entry = raw.emplace_back();
415 entry.id = instance->id();
416 entry.dto.fromAron(instance->data());
428 static constexpr float zOffset = 20.F;
430 namespace rv = ranges::views;
431 const auto globalFeatures =
434 [](
const RawLaserScannerFeatures& r)
435 -> std::pair<armem::MemoryID, memory::LaserScannerFeatures>
439 return {r.id, features};
441 rv::filter([](
const auto& p)
noexcept
445 for (
const auto& [
id, features] : globalFeatures)
447 const std::string idStr =
id.str();
449 for (
const auto& [
index, feature] : ranges::views::enumerate(features.features))
452 if (not feature.convexHull.empty())
455 for (
const Eigen::Vector2f& pt : feature.convexHull)
457 polygon.
addPoint(Eigen::Vector3f(pt.x(), pt.y(), zOffset));
459 polygon.
color(simox::Color::red(180, 80));
462 convexHullLayer.
add(polygon);
465 if (feature.chain.size() >= 2)
467 std::vector<Eigen::Vector3f> pts3d;
468 pts3d.reserve(feature.chain.size());
469 for (
const Eigen::Vector2f& pt : feature.chain)
471 pts3d.emplace_back(pt.x(), pt.y(), zOffset);
476 .color(viz::Color::blue()));
488 for (
const auto& point : room.
polygon)
497 polygon.color(color.with_alpha(50));
498 polygon.lineColor(simox::Color::black());
499 polygon.lineWidth(0);
512 const bool visuTransparent)
514 const Eigen::Translation3f human_T_mmm(Eigen::Vector3f{0, 0, 1000});
517 for (
const auto& [i, human] : ranges::views::enumerate(humans))
519 const std::string idx = std::to_string(i);
523 mmm.file(
"RobotAPI",
"RobotAPI/robots/MMM/mmm.xml");
526 mmm.overrideColor(viz::Color::orange(255, visuTransparent ? 100 : 255));
529 if (human.linearVelocity != Eigen::Vector2f::Zero())
532 vel3d.translation().head<2>() += human.linearVelocity * 2;
534 .fromTo(human3d.translation(), vel3d.translation())
535 .
color(simox::Color::red()));
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
static DateTime Now()
Current time on the virtual clock.
void setLogObjectDiscoveryError(bool logEnabled)
std::string providerSegmentName
auto * findLatestInstance(int instanceIndex=0)
const DataT & data() const
auto doLocked(FunctionT &&function) const
Execute function under shared (read) lock.
Client-side working entity instance.
Represents a point in time.
bool isPositive() const
Tests whether the duration is positive (value in µs > 0).
void drawLaserScannerFeatures(std::vector< viz::Layer > &layers)
std::unique_ptr< navigation::graph::GraphVisu > visu
const armem::server::wm::CoreSegment & costmapSegment
const armem::server::wm::CoreSegment & graphSegment
const armem::server::wm::CoreSegment & roomsSegment
void drawRooms(std::vector< viz::Layer > &layers)
const armem::server::wm::CoreSegment & humanSegment
const armem::server::wm::CoreSegment & locSegment
void drawLocations(std::vector< viz::Layer > &layers)
const armem::server::wm::CoreSegment & laserScannerFeaturesSegment
void drawCostmaps(std::vector< viz::Layer > &layers, float zOffset)
void drawGraphs(std::vector< viz::Layer > &layers)
Visu(viz::Client &arviz, const armem::server::wm::CoreSegment &locSegment, const armem::server::wm::CoreSegment &graphSegment, const armem::server::wm::CoreSegment &costmapSegment, const armem::server::wm::CoreSegment &humanSegment, const armem::server::wm::CoreSegment &roomsSegment, const armem::server::wm::CoreSegment &laserScannerFeaturesSegment)
void drawHumans(std::vector< viz::Layer > &layers, bool visuTransparent, Duration maxAge)
Provides access to the armarx::objpose::ObjectPoseStorageInterface (aka the object memory).
const ObjectFinder & getObjectFinder() const
Get the internal object finder.
bool isConnected() const
Indicate whether this client is connected to an object pose storage.
ObjectPoseMap fetchObjectPosesAsMap() const
Fetch all known object poses.
DerivedT & color(Color color)
DerivedT & position(float x, float y, float z)
DerivedT & scale(Eigen::Vector3f scale)
#define ARMARX_VERBOSE
The logging level for verbose information.
std::string const GlobalFrame
Variable of the global coordinate system.
armem::wm::EntityInstance EntityInstance
Costmap costmapFromAron(const aron::data::DictPtr &dto)
void visualize(const algorithms::Costmap &costmap, viz::Layer &layer, const std::string &name, const float zOffset)
std::vector< Eigen::Vector3f > to3D(const std::vector< Eigen::Vector2f > &v)
void resolveLocation(Graph::Vertex &vertex, const aron::data::DictPtr &locationData)
void resolveLocations(Graph &graph, const MemoryContainerT &locationContainer)
This file is part of ArmarX.
This file is part of ArmarX.
std::vector< Human > Humans
void fromAron(const arondto::Circle &dto, Circle &bo)
std::map< ObjectID, ObjectPose > ObjectPoseMap
bool forEachEntity(FunctionT &&func)
auto & getLatestSnapshot(int snapshotIndex=0)
Retrieve the latest entity snapshot.
std::vector< Eigen::Vector2f > polygon
Eigen::Vector2f center() const
void add(ElementT const &element)
Polygon & lineWidth(float w)
Polygon & addPoint(Eigen::Vector3f p)
Polygon & lineColor(Color color)
Text & text(std::string const &t)