25 LookForObjects::init(
const Base::SpecializedInitInput& in)
27 return ::armarx::skills::Skill::InitResult{
32 LookForObjects::main(
const Base::SpecializedMainInput& in)
36 std::set<armarx::ObjectID> requiredObjectClassIDs;
37 for (
const auto& objectID : in.parameters.requiredObjectClassIDs)
42 const size_t numberOfRequiredObjectClassIDs = requiredObjectClassIDs.size();
44 const std::vector<Eigen::Vector3f> gazePositions =
47 const Duration duration =
55 size_t nextTargetIndex = 0;
63 srv_->objectPoseClient.fetchObjectPoses();
65 for (
const objpose::ObjectPose& objectPose : objectPoses)
68 if (objectPose.timestamp < tsStart)
74 <<
"Detected object " << objectPose.objectID.str();
76 const ObjectID objectPoseClassID = objectPose.objectID.getClassID();
77 if (requiredObjectClassIDs.erase(objectPoseClassID) > 0)
79 toAron(result.foundObjectInstanceIDs.emplace_back(), objectPose.objectID);
83 if (requiredObjectClassIDs.empty())
93 if (now > nextTargetDueTime)
95 if (nextTargetIndex >= gazePositions.size())
102 const Eigen::Vector3f& position = gazePositions.at(nextTargetIndex);
104 ARMARX_INFO <<
"Looking to position #" << (nextTargetIndex + 1) <<
"/"
105 << gazePositions.size() <<
" (" << position.transpose() <<
")";
107 const gaze_targets::GazeTarget gazeTarget =
110 srv_->viewSelectionClient.commitGazeTarget(gazeTarget);
111 this->latestGazeTarget_ = gazeTarget;
114 nextTargetDueTime = now + duration;
116 metronome.waitForNextTick();
128 metronome.waitForNextTick();
135 result.allRequiredObjectClassesFound =
136 result.foundObjectInstanceIDs.size() == numberOfRequiredObjectClassIDs;
142 LookForObjects::onStopRequested()
144 if (latestGazeTarget_.has_value())
146 gaze_targets::GazeTarget deletedTarget = latestGazeTarget_.value();
147 deletedTarget.priority =
149 deletedTarget.keepInQueue =
false;
152 srv_->viewSelectionClient.commitGazeTarget(deletedTarget);
156 ::armarx::skills::SkillDescription
160 toAron(defaults.requiredObjectClassIDs.emplace_back(),
163 defaults.scanLocation = arondto::ScanLocationParams::FromAron(
169 .rootProfileDefaults = defaults.toAron(),
171 .parametersType = Params::ToAronType(),
172 .resultType = Result::ToAronType(),
static DateTime Now()
Current time on the virtual clock.
static Duration Minutes(std::int64_t minutes)
Constructs a duration in minutes.
static Duration Seconds(std::int64_t seconds)
Constructs a duration in seconds.
static Duration SecondsDouble(double seconds)
Constructs a duration in seconds.
static Frequency HertzDouble(double hertz)
SpamFilterDataPtr deactivateSpam(float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
disables the logging for the current line for the given amount of seconds.
A known object ID of the form "Dataset/ClassName" or "Dataset/ClassName/InstanceName".
static MainResult MakeSucceededResult(aron::data::DictPtr data=nullptr)
void throwIfSkillShouldTerminate(const std::string &abortedMessage="") const
arondto::LookForObjectsResult Result
::armarx::skills::SimpleSpecializedSkill< Params > Base
arondto::LookForObjectsParams Params
static armarx::skills::SkillDescription DefaultSkillDescription()
LookForObjects(const Services &srv)
static gaze_targets::GazeTarget MakeGazeTarget(const Eigen::Vector3f &position, const arondto::ScanLocationParams ¶meters)
static std::vector< Eigen::Vector3f > MakeGazeTargetPositions(const arondto::ScanLocationParams ¶meters)
static armarx::skills::SkillDescription DefaultSkillDescription()
#define ARMARX_INFO
The normal logging level.
armarx::core::time::Duration Duration
void fromAron(const T &dto, T &bo)
std::vector< ObjectPose > ObjectPoseSeq
@ TaskDriven
Task-Driven attention has highest priority.
@ Aborted
target was out of reach and thus deactivated by controller
const armarx::skills::SkillID LookForObjects
This file is part of ArmarX.
void toAron(arondto::PackagePath &dto, const PackageFileLocation &bo)
A result struct for skill initialization.
A result struct for th main method of a skill.