5#include <SimoxUtility/algorithm/string/string_tools.h>
6#include <SimoxUtility/color/Color.h>
7#include <SimoxUtility/math/pose/pose.h>
8#include <SimoxUtility/shapes/AxisAlignedBoundingBox.h>
9#include <SimoxUtility/shapes/OrientedBox.h>
17#include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h>
28 objects::classSegmentID.coreSegmentName,
29 arondto::ObjectClass::ToAronType(),
41 SpecializedCoreSegment::defineProperties(defs, prefix);
43 defs->optional(p.objectsPackage,
44 prefix +
"ObjectsPackage",
45 "Name of the objects package to load from.");
46 defs->optional(p.loadFromObjectsPackage,
47 prefix +
"LoadFromObjectsPackage",
48 "If true, load the objects from the objects package on startup.");
50 floorVis.defineProperties(defs, prefix +
"Floor.");
56 SpecializedCoreSegment::init();
58 if (p.loadFromObjectsPackage)
60 ARMARX_VERBOSE <<
"Loading objects from package `" << p.objectsPackage <<
"`.";
68 if (p.loadFromObjectsPackage)
70 ARMARX_VERBOSE <<
"Loading objects from package `" << p.objectsPackage <<
"`.";
75 ARMARX_INFO <<
"Loading object from package in `reloadObjectClassesByObjectFinder()` "
76 "is disabled via property. No object classes will be reloaded!";
85 floorVis.setArViz(arviz);
99 this->objectFinder = finder;
110 const bool checkPaths =
false;
111 std::vector<ObjectInfo> infos = objectFinder.findAllObjects(checkPaths);
114 segmentPtr->id().withProviderSegmentName(objectFinder.getPackageName());
115 ARMARX_INFO <<
"Loading up to " << infos.size() <<
" object classes from '"
116 << objectFinder.getPackageName() <<
"' ...";
123 info.setLogError(
false);
127 update.arrivedTime = update.referencedTime = update.sentTime = now;
136 update.instancesData = {objectClass.toAron()};
142 << objectFinder.getPackageName() <<
"'.";
149 const Eigen::Matrix4f pose = Eigen::Matrix4f::Identity();
151 viz::Layer layerOrigin = arviz.layer(
"Origin");
154 viz::Layer layerObject = arviz.layer(
"Class Model");
155 viz::Layer layerAABB = arviz.layer(
"Class AABB");
156 viz::Layer layerOOBB = arviz.layer(
"Class OOBB");
165 return segmentPtr->findLatestInstanceDataAs<arondto::ObjectClass>(entityID,
168 if (not
aron.has_value())
173 if (not
aron->simoxXmlPath.package.empty())
176 .
file(
aron->simoxXmlPath.package,
aron->simoxXmlPath.path)
183 .pose(pose * simox::math::pose(
aron->aabb.center))
185 .
color(simox::Color::cyan(255, 64)));
190 .pose(pose * simox::math::pose(
aron->oobb.center,
191 aron->oobb.orientation))
193 .
color(simox::Color::lime(255, 64)));
198 ARMARX_INFO <<
"Failed to visualize object class " << entityID <<
"."
199 <<
"\nReason: " << e.what();
203 ARMARX_INFO <<
"Failed to visualize object class " << entityID <<
"."
204 <<
"\nReason: " << e.what();
208 arviz.commit({layerObject, layerOrigin, layerAABB, layerOOBB});
214 namespace fs = std::filesystem;
218 arondto::ObjectClass
data;
225 if (simox::alg::starts_with(location.relativePath, location.package))
228 location.relativePath = location.relativePath.substr(location.package.size() + 1);
231 if (fs::is_regular_file(location.absolutePath))
241 setPathIfExists(
data.urdfPath, info.
urdf());
242 setPathIfExists(
data.sdfPath, info.
sdf());
252 toAron(
data.aabb, aabb ? aabb.value() : simox::AxisAlignedBoundingBox());
257 toAron(
data.oobb, oobb ? oobb.value() : simox::OrientedBoxf());
261 data.names.recognized = recogNames.value();
265 data.names.spoken = spokenNames.value();
283 group.setLabel(
"Class");
315 group.setLabel(
"Data");
316 group.addChild(grid);
333 segment.properties.maxHistorySize =
337 segment.segmentPtr->setMaxHistorySize(
338 long(
segment.properties.maxHistorySize));
351 segment.segmentPtr->forEachEntity(
363 showButton.setLabel(
"Visualize Object Class");
373 group.setLabel(
"Visualization");
374 group.addChild(grid);
int Label(int n[], int size, int *curLabel, MiscLib::Vector< std::pair< int, size_t > > *labels)
Used to find objects in the ArmarX objects repository [1] (formerly [2]).
A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
Accessor for the object files.
PackageFileLocation wavefrontObj() const
std::optional< simox::AxisAlignedBoundingBox > loadAABB() const
Load the AABB (axis-aligned bounding-box) from the bounding box JSON file.
PackageFileLocation urdf() const
std::optional< simox::OrientedBox< float > > loadOOBB() const
Load the OOBB (object-oriented bounding box) from the bounding box JSON file.
std::optional< std::vector< std::string > > loadSpokenNames() const
Load names to use when verbalizing an object name.
PackageFileLocation articulatedSdf() const
PackageFileLocation articulatedUrdf() const
PackageFileLocation sdf() const
PackageFileLocation meshWrl() const
ObjectID id() const
Return "dataset/name".
std::optional< std::vector< std::string > > loadRecognizedNames() const
Load names to use when matched when recognizing an object by name.
PackageFileLocation simoxXML() const
PackageFileLocation articulatedSimoxXML() const
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
MemoryID withEntityName(const std::string &name) const
std::string providerSegmentName
Base class for all exceptions thrown by the armem library.
Helps connecting a Memory server to the Ice interface.
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
void loadByObjectFinder()
void reloadObjectClassesByObjectFinder()
void connect(viz::Client arviz)
void visualizeClass(const MemoryID &entityID, bool showAABB=true, bool showOOBB=true)
arondto::ObjectClass objectClassFromInfo(const ObjectInfo &info)
Segment(armem::server::MemoryToIceAdapter &iceMemory)
virtual ~Segment() override
auto doLocked(FunctionT &&function) const
Execute function under shared (read) lock.
SpecializedCoreSegment(MemoryToIceAdapter &iceMemory, const std::string &defaultCoreSegmentName="", aron::type::ObjectPtr coreSegmentAronType=nullptr, int defaultMaxHistorySize=10, const std::vector< PredictionEngine > &predictionEngines={})
MemoryToIceAdapter & iceMemory
server::wm::CoreSegment * segmentPtr
A base class for aron exceptions.
DerivedT & pose(Eigen::Matrix4f const &pose)
DerivedT & color(Color color)
#define ARMARX_INFO
The normal logging level.
#define ARMARX_VERBOSE
The logging level for verbose information.
void fromAron(const arondto::MemoryID &dto, MemoryID &bo)
armarx::core::time::DateTime Time
void toAron(arondto::MemoryID &dto, const MemoryID &bo)
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
GridLayout & add(Widget const &child, Pos pos, Span span=Span{1, 1})
A bundle of updates to be sent to the memory.
std::vector< EntityUpdate > updates
The entity updates.
An update of an entity for a specific point in time.
void setup(const Segment &segment)
void update(Segment &segment)
armarx::RemoteGui::Client::CheckBox infiniteHistory
armarx::RemoteGui::Client::GroupBox group
armarx::RemoteGui::Client::IntSpinBox maxHistorySize
armarx::RemoteGui::Client::Button reloadButton
void setup(const Segment &segment)
void update(Segment &segment)
armarx::RemoteGui::Client::GroupBox group
std::vector< MemoryID > showOptionsIndex
armarx::RemoteGui::Client::Button showButton
armarx::RemoteGui::Client::ComboBox showComboBox
void setup(const Segment &segment)
void update(Segment &segment)
armarx::RemoteGui::Client::GroupBox group
Box & size(Eigen::Vector3f const &s)
void add(ElementT const &element)
Object & file(std::string const &project, std::string const &filename)