Skip to content
Snippets Groups Projects
Commit f73113a3 authored by Corvin-N's avatar Corvin-N
Browse files

Create parameter struct in header file for human tracking parameters

Not quite sure if it builds though as I edited this in the online editor, should be checked at some time
parent 9001172e
No related branches found
No related tags found
2 merge requests!38human tracker skeleton,!28Draft: Dev -> Main
This commit is part of merge request !38. Comments created here will be created in the context of that merge request.
...@@ -40,13 +40,10 @@ namespace armarx::navigation::components::dynamic_scene_provider ...@@ -40,13 +40,10 @@ namespace armarx::navigation::components::dynamic_scene_provider
void void
HumanTracker::update(const Measurements& measurements) HumanTracker::update(const Measurements& measurements)
{ {
//TODO: proper time to live
Duration maxAge = Duration::MilliSeconds(500);
for (auto it = trackedHumans.begin(); it != trackedHumans.end();) for (auto it = trackedHumans.begin(); it != trackedHumans.end();)
{ {
auto& human = *it; auto& human = *it;
if ((measurements.detectionTime - human.human.detectionTime) >= maxAge) if ((measurements.detectionTime - human.human.detectionTime) >= parameters.maxTrackingAge)
{ {
it = trackedHumans.erase(it); it = trackedHumans.erase(it);
} }
...@@ -135,12 +132,9 @@ namespace armarx::navigation::components::dynamic_scene_provider ...@@ -135,12 +132,9 @@ namespace armarx::navigation::components::dynamic_scene_provider
// associate leftover humans by their distances // associate leftover humans by their distances
const auto sortedDistances = getSortedDistances(trackedHumans, detectedHumans); const auto sortedDistances = getSortedDistances(trackedHumans, detectedHumans);
//TODO max distance parameter
float maxDistance = 600;
for (auto& posDistance : sortedDistances) for (auto& posDistance : sortedDistances)
{ {
if (posDistance.distance > maxDistance) if (posDistance.distance > parameters.maxAssociationDistance)
{ {
break; break;
} }
...@@ -161,16 +155,13 @@ namespace armarx::navigation::components::dynamic_scene_provider ...@@ -161,16 +155,13 @@ namespace armarx::navigation::components::dynamic_scene_provider
trackedHuman->associated = true; trackedHuman->associated = true;
detectedHuman->associated = true; detectedHuman->associated = true;
// TODO alpha parameter
float a = 0.7;
float dt = float dt =
(detectedHuman->detectionTime - trackedHuman->human.detectionTime).toSecondsDouble(); (detectedHuman->detectionTime - trackedHuman->human.detectionTime).toSecondsDouble();
Eigen::Vector2f ds = Eigen::Vector2f ds =
(detectedHuman->pose.translation() - trackedHuman->human.pose.translation()); (detectedHuman->pose.translation() - trackedHuman->human.pose.translation());
Eigen::Vector2f linVelocity = ds / dt; Eigen::Vector2f linVelocity = ds / dt;
Eigen::Vector2f velocity = a * linVelocity + (1 - a) * trackedHuman->human.linearVelocity; Eigen::Vector2f velocity = parameters.velocityAlpha * linVelocity + (1 - parameters.velocityAlpha) * trackedHuman->human.linearVelocity;
trackedHuman->human = {detectedHuman->pose, velocity, detectedHuman->detectionTime}; trackedHuman->human = {detectedHuman->pose, velocity, detectedHuman->detectionTime};
trackedHuman->trackingId = detectedHuman->trackingId; trackedHuman->trackingId = detectedHuman->trackingId;
......
...@@ -37,6 +37,16 @@ namespace armarx::navigation::components::dynamic_scene_provider ...@@ -37,6 +37,16 @@ namespace armarx::navigation::components::dynamic_scene_provider
bool associated; bool associated;
}; };
struct Parameters
{
// the duration after which tracked humans will be erased if no new measurement for this human is found
Duration maxTrackingAge = Duration::MilliSeconds(500);
// the maximum distance in millimeters of two human measurements to be associated with each other
float maxAssociationDistance = 600;
// alpha value from interval [0,1] to determine how much the new (and respectively the old) velocity should be weighted
float velocityAlpha = 0.7;
};
void update(const Measurements& measurements); void update(const Measurements& measurements);
std::vector<human::Human> getTrackedHumans() const; std::vector<human::Human> getTrackedHumans() const;
...@@ -49,5 +59,6 @@ namespace armarx::navigation::components::dynamic_scene_provider ...@@ -49,5 +59,6 @@ namespace armarx::navigation::components::dynamic_scene_provider
private: private:
std::vector<TrackedHuman> trackedHumans; std::vector<TrackedHuman> trackedHumans;
Parameter parameters;
}; };
} // namespace armarx::navigation::components::dynamic_scene_provider } // namespace armarx::navigation::components::dynamic_scene_provider
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