19 bool useKalmanFilter) :
20 useKalmanFilter(useKalmanFilter)
26 lastDetectedHuman = human;
52 ukf = std::make_unique<UnscentedKalmanFilter<SystemModelT>>(Q, R, alpha, state0, P0);
66 human.
pose = fromUkfState(ukf->getCurrentState());
85 ukf->update(observation);
87 newPose = fromUkfState(ukf->getCurrentState());
88 newPose.linear() = pose.linear();
103 Eigen::Vector2f ds = p2.pose - p1.pose;
104 double dt = (p2.time * 1000.0) / (p1.time * 1000.0);
105 Eigen::Vector2f linVelocity = ds /
dt;
106 if (linVelocity.norm() > 1000)
108 linVelocity = linVelocity.normalized();
111 newVelocity = linVelocity;
115 newVelocity = Eigen::Vector2f::Zero();
131 human.
pose = newPose;
135 Eigen::Vector2f{pose.translation()}});
138 pastPoses.pop_front();
141 lastDetectedHuman = human;
160 return {{pose.translation().x() / 1000,
161 pose.translation().y() / 1000,
170 pose2d.translation().x() = pose.
pose.x() * 1000;
171 pose2d.translation().y() = pose.
pose.y() * 1000;
172 pose2d.linear() = Eigen::Rotation2Df(0 ).toRotationMatrix();
178 HumanFilter::toUkfControl(
const Eigen::Vector2f& vel)
181 const auto& global_R_human = human.
pose.linear();
182 const auto human_V_vel = global_R_human.inverse() * vel;
185 return {{human_V_vel.x() / 1000, human_V_vel.y() / 1000, 0}};
194 HumanFilter::TimedVector2f
195 HumanFilter::getAveragedTimedPose(
unsigned int start_idx,
unsigned int end_idx)
197 std::int64_t avgTime = 0;
198 Eigen::Vector2f avgPose = Eigen::Vector2f::Zero();
199 auto it = pastPoses.begin();
200 for (std::int64_t i = 0; i < start_idx; ++i)
204 const auto numItems = end_idx - start_idx;
205 for (std::int64_t i = start_idx; i < end_idx; i++)
207 const auto& [time, pose] = *it;
209 avgTime += time / numItems;
215 return {avgTime, avgPose};