Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions nocturne/cpp/include/scenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ class Scenario : public sf::Drawable {
// void removeVehicle(Vehicle* object);
bool RemoveObject(const Object& object);

// Return the last timestamp where the object is valid
int64_t ExpertLastValid(const Object& object) const {
// expert_valid_masks is an array of 0s and 1s
// we want to return the last index where the object is valid
// so we reverse the array and find the first index where the object is valid
// and then subtract that from the size of the array
const auto& valid_mask = expert_valid_masks_.at(object.id());
auto it = std::find(valid_mask.rbegin(), valid_mask.rend(), true);
return valid_mask.size() - std::distance(valid_mask.rbegin(), it);
}

// Returns expert position for obj at timestamp.
geometry::Vector2D ExpertPosition(const Object& obj,
int64_t timestamp) const {
Expand Down
1 change: 1 addition & 0 deletions nocturne/pybind11/src/scenario.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void DefineScenario(py::module& m) {
.def("expert_pos_shift", &Scenario::ExpertPosShift)
.def("expert_heading_shift", &Scenario::ExpertHeadingShift)
.def("expert_position", &Scenario::ExpertPosition)
.def("expert_last_valid", &Scenario::ExpertLastValid)

// TODO: Deprecate the legacy interfaces below.
.def("getVehicles", &Scenario::vehicles,
Expand Down