11 const double gate_x,
const double gate_y,
const double gate_z,
12 const double gate_rotation,
13 const double gate_aperture) noexcept :
14 PFVisualCorrectionDecorator(std::move(visual_correction)),
15 gate_x_(gate_x), gate_y_(gate_y), gate_z_(gate_z),
16 gate_aperture_((M_PI / 180.0) * gate_aperture),
17 gate_rotation_((M_PI / 180.0) * gate_rotation)
19 ee_pose_ = VectorXd::Zero(7);
24 GatePose(std::move(visual_correction), 0.1, 0.1, 0.1, 5, 30) { }
30 void GatePose::innovation(
const Ref<const MatrixXf>& pred_states, cv::InputArray measurements, Ref<MatrixXf> innovations)
32 PFVisualCorrectionDecorator::innovation(pred_states, measurements, innovations);
38 return PFVisualCorrectionDecorator::likelihood(innovations);
44 return PFVisualCorrectionDecorator::getVisualObservationModel();
50 PFVisualCorrectionDecorator::setVisualObservationModel(std::move(visual_observation_model));
54 void GatePose::correctStep(
const Ref<const MatrixXf>& pred_states,
const Ref<const VectorXf>& pred_weights, cv::InputArray measurements,
55 Ref<MatrixXf> cor_states, Ref<VectorXf> cor_weights)
57 PFVisualCorrectionDecorator::correctStep(pred_states, pred_weights, measurements,
58 cor_states, cor_weights);
60 ee_pose_ = readPose();
62 for (
int i = 0; i < cor_states.cols(); ++i)
64 if (!isInsideEllipsoid(cor_states.col(i).head<3>()) ||
65 !isInsideCone (cor_states.col(i).middleRows<3>(3)) ||
66 !isWithinRotation (cor_states(6, i)) )
67 cor_weights(i) = std::numeric_limits<float>::min();
74 return ( (abs(state(0) - ee_pose_(0)) <= gate_x_) &&
75 (abs(state(1) - ee_pose_(1)) <= gate_y_) &&
76 (abs(state(2) - ee_pose_(2)) <= gate_z_) );
82 float ang_diff = abs(rot_angle - ee_pose_(6));
84 return (ang_diff <= gate_rotation_);
92 double half_aperture = gate_aperture_ / 2.0;
94 VectorXd test_direction = -state.cast<
double>();
96 VectorXd fwdkin_direction = -ee_pose_.middleRows<3>(3);
98 return ( (test_direction.dot(fwdkin_direction) / test_direction.norm() / fwdkin_direction.norm()) >= cos(half_aperture) );
void correctStep(const Eigen::Ref< const Eigen::MatrixXf > &pred_states, const Eigen::Ref< const Eigen::VectorXf > &pred_weights, cv::InputArray measurements, Eigen::Ref< Eigen::MatrixXf > cor_states, Eigen::Ref< Eigen::VectorXf > cor_weights) override
void setVisualObservationModel(std::unique_ptr< bfl::VisualObservationModel > visual_observation_model) override
bfl::VisualObservationModel & getVisualObservationModel() override
GatePose(std::unique_ptr< PFVisualCorrection > visual_correction, const double gate_x, const double gate_y, const double gate_z, const double gate_rotation, const double gate_aperture) noexcept
bool isInsideCone(const Eigen::Ref< const Eigen::VectorXf > &state)
bool isWithinRotation(float rot_angle)
bool isInsideEllipsoid(const Eigen::Ref< const Eigen::VectorXf > &state)
double likelihood(const Eigen::Ref< const Eigen::MatrixXf > &innovations) override
void innovation(const Eigen::Ref< const Eigen::MatrixXf > &pred_states, cv::InputArray measurements, Eigen::Ref< Eigen::MatrixXf > innovations) override