Skip to content

Commit 109be1f

Browse files
committed
Return key pairs rejected by pcm
1 parent a3a7e5e commit 109be1f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

cpp/include/pairwise_consistency_maximization/distributed_pcm/distributed_pcm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace distributed_pcm {
3939
* @param graph_and_values is the collection of factors of all graph used for evaluation
4040
* @returns size of the maximum clique of pairwise consistent measurements and number of outliers rejected
4141
*/
42-
static std::pair<int, int> solveDecentralized(const int& other_robot_id,
42+
static std::pair<std::pair<int, int>, std::set<std::pair<gtsam::Key, gtsam::Key>>> solveDecentralized(const int& other_robot_id,
4343
boost::shared_ptr<distributed_mapper::DistributedMapper>& dist_mapper,
4444
gtsam::GraphAndValues& local_graph_and_values,
4545
robot_measurements::RobotLocalMap& robot_local_map,
@@ -62,7 +62,7 @@ namespace distributed_pcm {
6262
std::vector<gtsam::GraphAndValues>& graph_and_values_vector,
6363
const double& confidence_probability);
6464

65-
static std::pair<int, int> executePCMDecentralized(const int& other_robot_id, robot_measurements::RobotLocalMap& robot_local_map,
65+
static std::pair<std::pair<int, int>, std::set<std::pair<gtsam::Key, gtsam::Key>>> executePCMDecentralized(const int& other_robot_id, robot_measurements::RobotLocalMap& robot_local_map,
6666
const robot_measurements::RobotLocalMap& other_robot_local_info,
6767
boost::shared_ptr<distributed_mapper::DistributedMapper>& dist_mapper,
6868
gtsam::GraphAndValues& local_graph_and_values,

cpp/src/pairwise_consistency_maximization/distributed_pcm/distributed_pcm.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace distributed_pcm {
3333
return std::make_pair(total_max_clique_sizes, total_outliers_rejected);
3434
}
3535

36-
std::pair<int, int> DistributedPCM::solveDecentralized(const int& other_robot_id,
36+
std::pair<std::pair<int, int>, std::set<std::pair<gtsam::Key, gtsam::Key>>> DistributedPCM::solveDecentralized(const int& other_robot_id,
3737
boost::shared_ptr<distributed_mapper::DistributedMapper>& dist_mapper,
3838
gtsam::GraphAndValues& local_graph_and_values,
3939
robot_measurements::RobotLocalMap& robot_local_map,
@@ -167,7 +167,7 @@ namespace distributed_pcm {
167167
return std::make_pair(max_clique.size(), max_clique_info.second);
168168
}
169169

170-
std::pair<int, int> DistributedPCM::executePCMDecentralized(const int& other_robot_id, robot_measurements::RobotLocalMap& robot_local_map,
170+
std::pair<std::pair<int, int>, std::set<std::pair<gtsam::Key, gtsam::Key>>> DistributedPCM::executePCMDecentralized(const int& other_robot_id, robot_measurements::RobotLocalMap& robot_local_map,
171171
const robot_measurements::RobotLocalMap& other_robot_local_info,
172172
boost::shared_ptr<distributed_mapper::DistributedMapper>& dist_mapper,
173173
gtsam::GraphAndValues& local_graph_and_values,
@@ -193,16 +193,18 @@ namespace distributed_pcm {
193193
// Retrieve indexes of rejected measurements
194194
auto separators_ids = dist_mapper->separatorEdge();
195195
std::vector<int> rejected_separator_ids;
196+
std::set<std::pair<gtsam::Key, gtsam::Key>> rejected_key_pairs;
196197
for (int i = 0; i < separators_ids.size(); i++) {
197198
if (isSeparatorToBeRejected(max_clique, separators_ids[i], roboti_robotj_separators_transforms,
198199
interrobot_measurements.getLoopClosures(), dist_mapper)) {
199200
rejected_separator_ids.emplace_back(i);
200201

201-
// Update robot local map
202+
// Update robot local map and store keys
202203
auto separator_factor = boost::dynamic_pointer_cast<gtsam::BetweenFactor<gtsam::Pose3> >(dist_mapper->currentGraph().at(separators_ids[i]));
203204
robot_local_map.removeTransform(std::make_pair(separator_factor->keys().at(0), separator_factor->keys().at(1)));
204205
dist_mapper->eraseSeparatorsSymbols(std::make_pair(separator_factor->keys().at(0), separator_factor->keys().at(1)));
205206
dist_mapper->eraseSeparatorsSymbols(std::make_pair(separator_factor->keys().at(1), separator_factor->keys().at(0)));
207+
rejected_key_pairs.insert(std::make_pair(separator_factor->keys().at(0), separator_factor->keys().at(1)));
206208
}
207209
}
208210
// Remove measurements not in the max clique
@@ -230,7 +232,7 @@ namespace distributed_pcm {
230232
}
231233
dist_mapper->setSeparatorIds(new_separator_ids);
232234

233-
return std::make_pair(max_clique.size(), max_clique_info.second);
235+
return std::make_pair(std::make_pair(max_clique.size(), max_clique_info.second), rejected_key_pairs);
234236
}
235237

236238
bool DistributedPCM::isSeparatorToBeRejected(const std::vector<int>& max_clique, const int& separtor_id, const graph_utils::Transforms& separators_transforms,

0 commit comments

Comments
 (0)