14 : properties(
std::move(properties))
16 , pushToMemory(
std::move(pushToMemory))
17 , pullFromMemory(
std::move(pullFromMemory))
18 , isCommitRequired(false)
19 , isUpdateRequired(true)
20 , isMemoryVizRequired(true)
21 , isMetaVizRequired(true)
23 placeholderOptions.emplace_back(
"Remove");
24 placeholderOptions.emplace_back(lineString);
38 storedPoses = update();
40 isUpdateRequired =
false;
47 isResetRequired =
false;
50 if (isMemoryVizRequired)
53 stage.
add(memoryLayer);
55 isMemoryVizRequired =
false;
58 if (isMetaVizRequired)
63 isMetaVizRequired =
false;
70 isCommitRequired =
false;
85 isMemoryVizRequired =
true;
87 return newRequestedPoses;
94 isMemoryVizRequired =
true;
104 remainingPoses.reserve(storedPoses.size());
105 for (objpose::ObjectPose & current : storedPoses)
107 bool isChanged = changes.
applyTo(current);
111 providingPoses.push_back(current.toProvidedObjectPoseGlobal());
112 objpose::ProvidedObjectPose& providing = providingPoses.back();
120 remainingPoses.push_back(current);
124 pushToMemory(providingPoses);
127 storedPoses = remainingPoses;
129 isMemoryVizRequired =
true;
132 void Editor::visualizeMemory()
136 for (objpose::ObjectPose & objectPose: storedPoses)
140 visualizeObject(objectPose);
147 void Editor::visualizeObject(objpose::ObjectPose& objectPose)
153 if (description.allowTransforming)
158 if (not description.options.empty())
165 .
pose(description.transform * objectPose.objectPoseGlobal)
170 if (description.alpha.has_value())
172 object.
alpha(description.alpha.value());
175 if (description.color.has_value())
183 changes.cloneObject(objectPose);
184 isMemoryVizRequired = true;
188 changes.deleteObject(objectPose);
189 isMemoryVizRequired = true;
193 changes.resetObject(objectPose);
194 isMemoryVizRequired = true;
196 .
onContextMenu(description.prototypeIndex, [
this, &objectPose]
198 const float defaultExtents = 100;
199 simox::OrientedBoxf box(objectPose.objectPoseGlobal, Eigen::Vector3f(defaultExtents, defaultExtents, defaultExtents));
201 box = objectPose.oobbGlobal().value_or(box);
202 box = box.transformed(changes.getTransform(objectPose));
204 placeholders.addPlaceholder(box);
205 isMetaVizRequired = true;
209 isCommitRequired = true;
213 isUpdateRequired = true;
217 isResetRequired = true;
222 isMemoryVizRequired =
true;
226 void Editor::visualizeMeta()
233 void Editor::visualizePlaceholder(PlaceholderState::Placeholder
const& placeholder,
size_t id)
239 .
set(placeholder.box.transformed(placeholder.transform))
240 .
color(simox::Color::yellow(255, 128))
243 auto& observation = observer.
addObserved(metaLayer, box)
247 isMetaVizRequired =
true;
252 isMetaVizRequired =
true;
257 std::string
const&
object = placeholderOptions[
index];
259 observation.onContextMenu(
index, [
this,
id, &
object]
263 isMetaVizRequired =
true;
264 isMemoryVizRequired =
true;
277 seq.insert(seq.begin(), newPoses.begin(), newPoses.end());
284 bool isChanged = iterator != changed.end();
288 auto& [name, change] = *iterator;
290 if (change.kind == DELETE)
305 editor->visualizeObject(objectPose);
313 auto iterator = changed.find(
object.objectID.str());
314 bool isChanged = iterator != changed.end();
316 ChangeKind kind = MOVE;
319 auto& [name, change] = *iterator;
325 size_t currentIndex = 0;
329 description.
options.emplace_back(
"Clone");
332 description.
options.emplace_back(
"Delete");
338 auto& [name, change] = *iterator;
340 description.
options.emplace_back(
"Reset");
343 description.
transform = change.transform;
345 const float alpha = 0.5;
350 description.
alpha = alpha;
363 description.
options.emplace_back(
"Create Placeholder");
366 description.
options.emplace_back(Editor::lineString);
369 description.
options.emplace_back(
"Commit All Changes");
372 description.
options.emplace_back(
"Update Unchanged");
375 description.
options.emplace_back(
"Reset All");
383 std::string suffix =
std::to_string(std::chrono::duration_cast<std::chrono::seconds>(
384 std::chrono::system_clock::now().time_since_epoch()).count());
389 const float minOffset = 100;
390 float offset = minOffset;
391 if (
object.localOOBB.has_value())
393 Eigen::Vector3f size =
object.localOOBB.value().corner_max() -
object.localOOBB.value().corner_min();
394 float objectOffset = size.maxCoeff() / 2;
396 offset =
std::max(minOffset, objectOffset);
399 Change& clonedChange = changed[newPose.
objectID.
str()];
400 clonedChange.kind = CREATE;
402 clonedChange.transform = Eigen::Affine3f(Eigen::Translation3f(offset, offset, 0)).matrix();
403 clonedChange.iterator = std::prev(newPoses.end());
405 auto iterator = changed.find(
object.objectID.str());
406 if (iterator != changed.end())
408 auto& [name, originalChange] = *iterator;
409 clonedChange.transform *= originalChange.transform;
415 std::string suffix =
std::to_string(std::chrono::duration_cast<std::chrono::seconds>(
416 std::chrono::system_clock::now().time_since_epoch()).count());
424 newPose.
objectType = objpose::ObjectType::KnownObject;
431 std::optional<armarx::ObjectInfo> info = editor->objectFinder.
findObject(
id);
432 if (info.has_value())
442 Change& createdChange = changed[newPose.
objectID.
str()];
443 createdChange.kind = CREATE;
445 createdChange.iterator = std::prev(newPoses.end());
450 changed[
object.objectID.str()].kind = DELETE;
455 auto iterator = changed.find(
object.objectID.str());
456 if (iterator != changed.end())
458 auto& [name, change] = *iterator;
460 if (change.kind == CREATE)
462 newPoses.erase(change.iterator);
465 changed.erase(iterator);
471 Change& change = changed[
object.objectID.str()];
472 change.transform =
transform * change.transform;
479 auto iterator = changed.find(
object.objectID.str());
480 if (iterator != changed.end())
482 auto& [name, change] = *iterator;
493 auto& entry = placeholders[id];
495 entry.isActive =
true;
500 for (
size_t id = 0;
id < placeholders.size();
id++)
502 auto& entry = placeholders[id];
506 editor->visualizePlaceholder(entry.placeholder,
id);
513 auto& placeholder = placeholders[id].placeholder;
514 placeholder.transform =
transform * placeholder.transform;
519 placeholders[id].isActive =
false;
524 size_t PlaceholderState::getID()
526 if (unusedIDs.empty())
528 size_t id = placeholders.size();
529 placeholders.push_back({Placeholder(),
false});
533 size_t id = unusedIDs.top();
540 auto& placeholder = placeholders[id].placeholder;
542 Eigen::Matrix4f pose = placeholder.box.transformed(placeholder.transform).transformation_centered();