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>
16 #include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h>
26 SpecializedCoreSegment(memoryToIceAdapter,
28 arondto::ObjectClass::ToAronType(),
40 SpecializedCoreSegment::defineProperties(defs, prefix);
42 defs->optional(p.objectsPackage,
43 prefix +
"ObjectsPackage",
44 "Name of the objects package to load from.");
45 defs->optional(p.loadFromObjectsPackage,
46 prefix +
"LoadFromObjectsPackage",
47 "If true, load the objects from the objects package on startup.");
55 SpecializedCoreSegment::init();
57 if (p.loadFromObjectsPackage)
83 this->objectFinder = finder;
94 const bool checkPaths =
false;
95 std::vector<ObjectInfo> infos = objectFinder.
findAllObjects(checkPaths);
99 ARMARX_INFO <<
"Loading up to " << infos.size() <<
" object classes from '"
107 info.setLogError(
false);
116 update.instancesData = {objectClass.toAron()};
142 std::optional<arondto::ObjectClass> aron =
doLocked(
143 [
this, &entityID]() {
147 if (not aron.has_value())
152 if (not aron->simoxXmlPath.package.empty())
155 .
file(aron->simoxXmlPath.package, aron->simoxXmlPath.path)
162 .
pose(pose * simox::math::pose(aron->aabb.center))
163 .
size(aron->aabb.extents)
164 .
color(simox::Color::cyan(255, 64)));
169 .
pose(pose * simox::math::pose(aron->oobb.center,
170 aron->oobb.orientation))
171 .
size(aron->oobb.extents)
172 .
color(simox::Color::lime(255, 64)));
177 ARMARX_INFO <<
"Failed to visualize object class " << entityID <<
"."
178 <<
"\nReason: " << e.what();
182 ARMARX_INFO <<
"Failed to visualize object class " << entityID <<
"."
183 <<
"\nReason: " << e.what();
187 arviz.
commit({layerObject, layerOrigin, layerAABB, layerOOBB});
193 namespace fs = std::filesystem;
197 arondto::ObjectClass
data;
200 auto setPathIfExists =
203 if (fs::is_regular_file(location.absolutePath))
213 setPathIfExists(
data.urdfPath, info.
urdf());
214 setPathIfExists(
data.sdfPath, info.
sdf());
229 toAron(
data.oobb, oobb ? oobb.value() : simox::OrientedBoxf());
233 data.names.recognized = recogNames.value();
237 data.names.spoken = spokenNames.value();
271 reloadButton.setLabel(
"Reload");
274 maxHistorySize.setRange(1, 1e6);
279 grid.
add(reloadButton, {row, 0}, {1, 2});
281 grid.
add(
Label(
"Max History Size"), {row, 0}).add(maxHistorySize, {row, 1});
283 grid.
add(
Label(
"Infinite History Size"), {row, 0}).add(infiniteHistory, {row, 1});
294 if (reloadButton.wasClicked())
300 if (infiniteHistory.hasValueChanged() || maxHistorySize.hasValueChanged())
306 infiniteHistory.getValue() ? -1 : maxHistorySize.getValue();
309 segment.segmentPtr->setMaxHistorySize(
310 long(segment.properties.maxHistorySize));
322 showOptionsIndex.clear();
328 showComboBox.addOption(
option.str());
329 showOptionsIndex.push_back(entity.
id());
331 if (showOptionsIndex.empty())
333 showComboBox.addOption(
"<none>");
335 showButton.setLabel(
"Visualize Object Class");
339 grid.
add(showComboBox, {row, 0}, {1, 2});
341 grid.
add(showButton, {row, 0}, {1, 2});
352 if (showButton.wasClicked())
354 const size_t index =
static_cast<size_t>(showComboBox.getIndex());
355 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)
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)