Skip to content

Commit

Permalink
Make sure that find data packs work for single agents too
Browse files Browse the repository at this point in the history
  • Loading branch information
bpapaspyros committed May 23, 2023
1 parent e601334 commit 329a489
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/tools/find_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,21 @@ namespace aegean {
std::get<2>(_uni_data[key][exp_num]) = _traj[key][skey].second;
}
else {
int ridx1 = _traj[key][skey].second;
int ridx0 = std::get<2>(_uni_data[key][viter->second]);

// there is a chance that the split experiments will have different robot indices (this is because
// they are indeed analyzed by a different instance of the tracking software). Here, we swap the
// columns to make sure that both experiments that are about to be joined have the same robot index
if (ridx0 != ridx1) {
_traj[key][skey].first.col(ridx0 * 2).swap(_traj[key][skey].first.col(ridx1 * 2));
_traj[key][skey].first.col(ridx0 * 2 + 1).swap(_traj[key][skey].first.col(ridx1 * 2 + 1));
_vels[key][skey].first.col(ridx0 * 2).swap(_vels[key][skey].first.col(ridx1 * 2));
_vels[key][skey].first.col(ridx0 * 2 + 1).swap(_vels[key][skey].first.col(ridx1 * 2 + 1));
_traj[key][skey].second = ridx0;
_vels[key][skey].second = ridx0;
if (_traj[key][skey].first.cols() > 2) {
int ridx1 = _traj[key][skey].second;
int ridx0 = std::get<2>(_uni_data[key][viter->second]);

// there is a chance that the split experiments will have different robot indices (this is because
// they are indeed analyzed by a different instance of the tracking software). Here, we swap the
// columns to make sure that both experiments that are about to be joined have the same robot index
if (ridx0 != ridx1) {
_traj[key][skey].first.col(ridx0 * 2).swap(_traj[key][skey].first.col(ridx1 * 2));
_traj[key][skey].first.col(ridx0 * 2 + 1).swap(_traj[key][skey].first.col(ridx1 * 2 + 1));
_vels[key][skey].first.col(ridx0 * 2).swap(_vels[key][skey].first.col(ridx1 * 2));
_vels[key][skey].first.col(ridx0 * 2 + 1).swap(_vels[key][skey].first.col(ridx1 * 2 + 1));
_traj[key][skey].second = ridx0;
_vels[key][skey].second = ridx0;
}
}

std::get<0>(_uni_data[key][viter->second]).push_back(std::move(_traj[key][skey].first));
Expand Down

0 comments on commit 329a489

Please sign in to comment.