Go to the documentation of this file.
5 #include <SimoxUtility/color/Color.h>
6 #include <SimoxUtility/math/pose/pose.h>
7 #include <SimoxUtility/shapes/AxisAlignedBoundingBox.h>
8 #include <SimoxUtility/shapes/OrientedBox.h>
15 #include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h>
25 SpecializedCoreSegment(memoryToIceAdapter,
27 arondto::ObjectClass::ToAronType(),
39 SpecializedCoreSegment::defineProperties(defs, prefix);
41 defs->optional(p.objectsPackage,
42 prefix +
"ObjectsPackage",
43 "Name of the objects package to load from.");
44 defs->optional(p.loadFromObjectsPackage,
45 prefix +
"LoadFromObjectsPackage",
46 "If true, load the objects from the objects package on startup.");
54 SpecializedCoreSegment::init();
56 if (p.loadFromObjectsPackage)
80 this->objectFinder = finder;
89 const bool checkPaths =
false;
90 std::vector<ObjectInfo> infos = objectFinder.
findAllObjects(checkPaths);
94 ARMARX_INFO <<
"Loading up to " << infos.size() <<
" object classes from '"
99 info.setLogError(
false);
106 update.instancesData = {objectClass.toAron()};
129 std::optional<arondto::ObjectClass> aron =
doLocked(
130 [
this, &entityID]() {
134 if (not aron.has_value())
139 if (not aron->simoxXmlPath.package.empty())
142 .
file(aron->simoxXmlPath.package, aron->simoxXmlPath.path)
149 .
pose(pose * simox::math::pose(aron->aabb.center))
150 .
size(aron->aabb.extents)
151 .
color(simox::Color::cyan(255, 64)));
156 .
pose(pose * simox::math::pose(aron->oobb.center,
157 aron->oobb.orientation))
158 .
size(aron->oobb.extents)
159 .
color(simox::Color::lime(255, 64)));
164 ARMARX_INFO <<
"Failed to visualize object class " << entityID <<
"."
165 <<
"\nReason: " << e.what();
169 ARMARX_INFO <<
"Failed to visualize object class " << entityID <<
"."
170 <<
"\nReason: " << e.what();
174 arviz.
commit({layerObject, layerOrigin, layerAABB, layerOOBB});
180 namespace fs = std::filesystem;
182 arondto::ObjectClass
data;
185 auto setPathIfExists =
188 if (fs::is_regular_file(location.absolutePath))
198 setPathIfExists(
data.urdfPath, info.
urdf());
199 setPathIfExists(
data.sdfPath, info.
sdf());
209 toAron(
data.oobb, oobb ? oobb.value() : simox::OrientedBoxf());
213 data.names.recognized = recogNames.value();
217 data.names.spoken = spokenNames.value();
251 reloadButton.setLabel(
"Reload");
254 maxHistorySize.setRange(1, 1e6);
259 grid.
add(reloadButton, {row, 0}, {1, 2});
261 grid.
add(
Label(
"Max History Size"), {row, 0}).add(maxHistorySize, {row, 1});
263 grid.
add(
Label(
"Infinite History Size"), {row, 0}).add(infiniteHistory, {row, 1});
274 if (reloadButton.wasClicked())
280 if (infiniteHistory.hasValueChanged() || maxHistorySize.hasValueChanged())
286 infiniteHistory.getValue() ? -1 : maxHistorySize.getValue();
289 segment.segmentPtr->setMaxHistorySize(
290 long(segment.properties.maxHistorySize));
302 showOptionsIndex.clear();
308 showComboBox.addOption(
option.str());
309 showOptionsIndex.push_back(entity.
id());
311 if (showOptionsIndex.empty())
313 showComboBox.addOption(
"<none>");
315 showButton.setLabel(
"Visualize Object Class");
319 grid.
add(showComboBox, {row, 0}, {1, 2});
321 grid.
add(showButton, {row, 0}, {1, 2});
332 if (showButton.wasClicked())
334 const size_t index =
static_cast<size_t>(showComboBox.getIndex());
335 if (
index < showOptionsIndex.size())
std::optional< AronDtoT > findLatestInstanceDataAs(const MemoryID &entityID, int instanceIndex=0) const
A base class for aron exceptions.
CommitResult commit(StagedCommit const &commit)
void update(Segment &segment)
PackageFileLocation articulatedSdf() const
std::string providerSegmentName
void setup(const Segment &segment)
A bundle of updates to be sent to the memory.
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="")
std::vector< ObjectInfo > findAllObjects(bool checkPaths=true) const
PackageFileLocation articulatedSimoxXML() const
armarx::RemoteGui::Client::GroupBox group
Helps connecting a Memory server to the Ice interface.
GridLayout & add(Widget const &child, Pos pos, Span span=Span{1, 1})
Object & file(std::string const &project, std::string const &filename)
void loadByObjectFinder(const std::string &objectsPackage)
std::string str(bool escapeDelimiters=true) const
Get a string representation of this memory ID.
void toAron(arondto::MemoryID &dto, const MemoryID &bo)
armarx::RemoteGui::Client::GroupBox group
Base class for all exceptions thrown by the armem library.
PackageFileLocation wavefrontObj() const
void setArViz(armarx::viz::Client arviz)
PackageFileLocation articulatedUrdf() const
PackageFileLocation urdf() const
const MemoryID classSegmentID
void add(ElementT const &element)
armarx::RemoteGui::Client::GroupBox group
void setup(const Segment &segment)
bool forEachEntity(FunctionT &&func)
std::optional< std::vector< std::string > > loadRecognizedNames() const
Load names to use when matched when recognizing an object by name.
std::vector< EntityUpdate > updates
The entity updates.
::simox::arondto::AxisAlignedBoundingBox AxisAlignedBoundingBox
uint32_t Label
Type of an object label.
void loadByObjectFinder()
Used to find objects in the ArmarX objects repository [1] (formerly [2]).
server::wm::CoreSegment * segmentPtr
void Identity(MatrixXX< N, N, T > *a)
MemoryID withProviderSegmentName(const std::string &name) const
PackageFileLocation sdf() const
auto doLocked(FunctionT &&function) const
An update of an entity for a specific point in time.
void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string &prefix="") override
void update(Segment &segment)
bool update(mongocxx::collection &coll, const nlohmann::json &query, const nlohmann::json &update)
void setLabel(std::string const &text)
PackageFileLocation simoxXML() const
Represents a point in time.
virtual ~Segment() override
void update(Segment &segment)
std::optional< simox::OrientedBox< float > > loadOOBB() const
Load the OOBB (object-oriented bounding box) from the bounding box JSON file.
MatrixXX< 4, 4, float > Matrix4f
MemoryID withEntityName(const std::string &name) const
MemoryToIceAdapter & iceMemory
DerivedT & pose(Eigen::Matrix4f const &pose)
std::optional< simox::AxisAlignedBoundingBox > loadAABB() const
Load the AABB (axis-aligned bounding-box) from the bounding box JSON file.
Box & size(Eigen::Vector3f const &s)
DerivedT & color(Color color)
std::optional< std::vector< std::string > > loadSpokenNames() const
Load names to use when verbalizing an object name.
ObjectID id() const
Return "dataset/name".
PackageFileLocation meshWrl() const
void connect(viz::Client arviz)
void visualizeClass(const MemoryID &entityID, bool showAABB=true, bool showOOBB=true)
static arondto::ObjectClass objectClassFromInfo(const ObjectInfo &info)
void updateFloorObject(const wm::CoreSegment &classCoreSegment)
Draw a the floor as a simox object.
Layer layer(std::string const &name) const
std::string getPackageName() const
void setup(const Segment &segment)
data::CommitResult commitLocking(const data::Commit &commitIce, Time timeArrived)
Accessor for the object files.
Segment(armem::server::MemoryToIceAdapter &iceMemory)