Skip to content

Commit

Permalink
Merge pull request #1177 from tier4/fix/tracking_object_merger_bugfix
Browse files Browse the repository at this point in the history
fix(tracker_object_merger): add sanity check for tracker merger (autowarefoundation#6386)
  • Loading branch information
shmpwk authored Mar 6, 2024
2 parents f834da8 + 1d40cf9 commit ecdc576
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions perception/tracking_object_merger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ We use the `existence_probability` to manage tracklet.
- When we create a new tracklet, we set the `existence_probability` to $p_{sensor}$ value.
- In each update with specific sensor, we set the `existence_probability` to $p_{sensor}$ value.
- When tracklet does not have update with specific sensor, we reduce the `existence_probability` by `decay_rate`
- Object can be published if `existence_probability` is larger than `publish_probability_threshold`
- Object will be removed if `existence_probability` is smaller than `remove_probability_threshold`
- Object can be published if `existence_probability` is larger than `publish_probability_threshold` and time from last update is smaller than `max_dt`
- Object will be removed if `existence_probability` is smaller than `remove_probability_threshold` and time from last update is larger than `max_dt`

![tracklet_management](./image/tracklet_management.drawio.svg)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class TrackerState
std::function<void(TrackedObject &, const TrackedObject &)> update_func);
// const functions
bool hasUUID(const MEASUREMENT_STATE input, const unique_identifier_msgs::msg::UUID & uuid) const;
bool isValid() const;
bool isValid(const rclcpp::Time & current_time) const;
bool canPublish() const;
TrackedObject getObject() const;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,6 @@ bool DecorativeTrackerMergerNode::decorativeMerger(
{
// get current time
const auto current_time = rclcpp::Time(input_objects_msg->header.stamp);
if (input_objects_msg->objects.empty()) {
return false;
}
if (inner_tracker_objects_.empty()) {
for (const auto & object : input_objects_msg->objects) {
inner_tracker_objects_.push_back(createNewTracker(input_sensor, current_time, object));
Expand Down
10 changes: 8 additions & 2 deletions perception/tracking_object_merger/src/utils/tracker_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,14 @@ bool TrackerState::hasUUID(
return input_uuid_map_.at(input) == uuid;
}

bool TrackerState::isValid() const
bool TrackerState::isValid(const rclcpp::Time & current_time) const
{
// check dt from last update
double dt = (current_time - last_update_time_).seconds();
if (std::abs(dt) > max_dt_) {
return false;
}

// check if tracker state is valid
if (existence_probability_ < remove_probability_threshold_) {
return false;
Expand Down Expand Up @@ -302,7 +308,7 @@ TrackedObjects getTrackedObjectsFromTrackerStates(
// sanitize and get tracked objects
for (auto it = tracker_states.begin(); it != tracker_states.end();) {
// check if tracker state is valid
if (it->isValid()) {
if (it->isValid(current_time)) {
if (it->canPublish()) {
// if valid, get tracked object
tracked_objects.objects.push_back(it->getObject());
Expand Down

0 comments on commit ecdc576

Please sign in to comment.