Skip to content
Snippets Groups Projects
Commit 098a19c6 authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

Merge branch 'validate-pose' into 'master'

validate poses (hmd/origin) before saving

See merge request nicolas.pope/ftl!339
parents 0556e6a3 61efce0a
Branches
Tags
1 merge request!339validate poses (hmd/origin) before saving
Pipeline #29265 failed
...@@ -608,9 +608,17 @@ void Camera::setOriginToCursor() { ...@@ -608,9 +608,17 @@ void Camera::setOriginToCursor() {
auto response = f.response(); auto response = f.response();
auto &rgbdf = response.cast<ftl::rgbd::Frame>(); auto &rgbdf = response.cast<ftl::rgbd::Frame>();
auto &calib = rgbdf.setCalibration(); auto &calib = rgbdf.setCalibration();
calib = f.cast<ftl::rgbd::Frame>().getCalibration(); calib = f.cast<ftl::rgbd::Frame>().getCalibration();
// apply correction to existing one // apply correction to existing one
calib.origin = cur*calib.origin; cv::Mat new_origin = cur*calib.origin;
if (ftl::calibration::validate::pose(new_origin)) {
calib.origin = new_origin;
}
else {
// TODO: add error message to gui as well
LOG(ERROR) << "Bad origin update (invalid pose)";
}
} }
}; };
} }
......
...@@ -330,7 +330,16 @@ bool OpenVRRender::retrieve(ftl::data::Frame &frame_out) { ...@@ -330,7 +330,16 @@ bool OpenVRRender::retrieve(ftl::data::Frame &frame_out) {
if (headset_origin.size() > 0) { if (headset_origin.size() > 0) {
ftl::operators::Poser::get(headset_origin, horigin); ftl::operators::Poser::get(headset_origin, horigin);
} }
initial_pose_ = horigin*viewPose.inverse(); Eigen::Matrix4d new_pose = horigin*viewPose.inverse();
// validate new values before saving
const Eigen::Matrix3d rot(new_pose.block<3, 3>(0, 0));
if ((abs(rot.determinant() - 1.0) < 0.0001) && (new_pose(3, 3) == 1.0)) {
initial_pose_ = new_pose;
}
else {
LOG(ERROR) << "Bad pose update";
}
if (host_->value("reset_pose", false) && ftl::timer::get_time() < pose_calibration_start_ + host_->value("calibration_time",10000)) { if (host_->value("reset_pose", false) && ftl::timer::get_time() < pose_calibration_start_ + host_->value("calibration_time",10000)) {
pose_calibrated_.clear(); pose_calibrated_.clear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment