Skip to content
Snippets Groups Projects
Commit 357d5e63 authored by Joana Plewnia's avatar Joana Plewnia
Browse files

using spoken name for objects, tested in simulation

parent 7afaf1dd
No related tags found
No related merge requests found
......@@ -26,6 +26,9 @@ armarx_add_library(object_last_seen_at_core
armarx_symbolic_planning::symbolic_scene_memory_client
armarx_speech::object_last_seen_at_core_ice
# for object memory queries
armem_objects
#armarx speech skill:
#armarx_speech:skills
......
......@@ -31,6 +31,7 @@
#include <memory>
#include <armarx/symbolic_planning/armem/symbolic_scene_memory/client/reader/SymbolicSceneReader.h>
#include <RobotAPI/libraries/armem_objects/client/class/ClassReader.h>
#include <RobotAPI/libraries/armem/client/Reader.h>
#include <algorithm>
......@@ -93,29 +94,42 @@ namespace armarx::speech::object_last_seen_at::core
secondPart = secondPart.substr(0, colonPos);
}
/**
size_t firstSlash = object_location.find('/');
std::string location_name_human_readable = "";
if (firstSlash != std::string::npos) {
// Find the second slash, starting after the first one
size_t secondSlash = object_location.find('/', firstSlash + 1);
// If there is a second slash, extract the part between
if (secondSlash != std::string::npos) {
location_name_human_readable = object_location.substr(firstSlash + 1, secondSlash - firstSlash - 1);
//as a spoken name take the spoken name of the object from the object memory (class core segment):
std::string object_id = object_description.second.id;
//find the last / in the object id and use the part before it as a string:
size_t lastSlashPosLocation = object_id.find_last_of('/');
std::string object_name = object_id.substr(lastSlashPosLocation + 1);
//use this ID to query the Object Memory
try{
armem::obj::clazz::ClassReader object_class_reader;
auto object_class = object_class_reader.getObjectClass("PriorKnowledgeData", object_name);
std::string answer;
if(object_class.has_value()) {
auto object_spoken_names = object_class->names.spoken;
// if the object (of the location) has a spoken name, use it for verbalization:
if (object_spoken_names.empty()) {
ARMARX_DEBUG << "No spoken name found for object " << object_name;
answer = "I have last seen the " + object_name + " " + firstPart + " the " + secondPart + ".";
} else {
auto first_spoken_name = object_spoken_names[0];
answer = "I have last seen the " + object_name + " " + firstPart + " the " + first_spoken_name + ".";
}
} else {
// If no second slash, the second part goes till the end of the string
location_name_human_readable = object_location.substr(firstSlash + 1);
// object class query did not work correctly, as this always should have a value if the object class exists:
ARMARX_DEBUG << "You are trying to query the object class info of an object, but the object class object has no value";
answer = "I have last seen the " + object_name + " " + firstPart + " the " + secondPart + ".";
}
}
*/
ARMARX_INFO << "Object " << object_name << " (" << object_description.second.id << ") is at " << object_description.second.objectAt;
//std::string answer = "I have last seen the " + object_name + " at " + location_name_human_readable + ".";
std::string answer = "I have last seen the " + object_name + " " + firstPart + " the " + secondPart + ".";
this->subskills.say(answer);
ARMARX_INFO << "Object " << object_name << " (" << object_description.second.id << ") is at " << object_description.second.objectAt;
this->subskills.say(answer);
} catch (const std::exception& e) {
ARMARX_DEBUG << "Error while querying the object class info of an object: " << e.what();
std::string answer = "I have last seen the " + object_name + " " + firstPart + " the " + secondPart + ".";
this->subskills.say(answer);
}
return true;
} else { // if the location or object could not be found it is currently not visible and we need to leverage the LTM
// TODO: LTM integration
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment