Skip to content

Commit 11e6a56

Browse files
authored
Add a method to convert a return code to a human readable string (#174)
1 parent 416810d commit 11e6a56

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

include/albatross/src/models/ransac.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,26 @@ typedef enum ransac_return_code_e {
6262
RANSAC_RETURN_CODE_FAILURE
6363
} ransac_return_code_t;
6464

65+
inline std::string to_string(const ransac_return_code_t &return_code) {
66+
switch (return_code) {
67+
case RANSAC_RETURN_CODE_INVALID:
68+
return "invalid";
69+
case RANSAC_RETURN_CODE_SUCCESS:
70+
return "success";
71+
case RANSAC_RETURN_CODE_NO_CONSENSUS:
72+
return "no_consensus";
73+
case RANSAC_RETURN_CODE_INVALID_ARGUMENTS:
74+
return "invalid_arguments";
75+
case RANSAC_RETURN_CODE_EXCEEDED_MAX_FAILED_CANDIDATES:
76+
return "exceeded_max_failed_candidates";
77+
case RANSAC_RETURN_CODE_FAILURE:
78+
return "failure";
79+
default:
80+
assert(false);
81+
return "unknown return code";
82+
}
83+
}
84+
6585
inline bool ransac_success(const ransac_return_code_t &rc) {
6686
return rc == RANSAC_RETURN_CODE_SUCCESS;
6787
}

0 commit comments

Comments
 (0)