Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ekf2: fix optical_flow_vel publication #22260

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/modules/ekf2/EKF2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ void EKF2::PublishOpticalFlowVel(const hrt_abstime &timestamp)
{
const hrt_abstime timestamp_sample = _ekf.aid_src_optical_flow().timestamp_sample;

if ((timestamp_sample != 0) && (timestamp_sample > _status_optical_flow_pub_last)) {
if ((timestamp_sample != 0) && (timestamp_sample > _optical_flow_vel_pub_last)) {

vehicle_optical_flow_vel_s flow_vel{};
flow_vel.timestamp_sample = _ekf.aid_src_optical_flow().timestamp_sample;
Expand All @@ -2205,6 +2205,8 @@ void EKF2::PublishOpticalFlowVel(const hrt_abstime &timestamp)
flow_vel.timestamp = _replay_mode ? timestamp : hrt_absolute_time();

_estimator_optical_flow_vel_pub.publish(flow_vel);

_optical_flow_vel_pub_last = timestamp_sample;
}
}
#endif // CONFIG_EKF2_OPTICAL_FLOW
Expand Down
1 change: 1 addition & 0 deletions src/modules/ekf2/EKF2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ class EKF2 final : public ModuleParams, public px4::ScheduledWorkItem

uORB::PublicationMulti<estimator_aid_source2d_s> _estimator_aid_src_optical_flow_pub{ORB_ID(estimator_aid_src_optical_flow)};
hrt_abstime _status_optical_flow_pub_last{0};
hrt_abstime _optical_flow_vel_pub_last{0};

perf_counter_t _msg_missed_optical_flow_perf{nullptr};
#endif // CONFIG_EKF2_OPTICAL_FLOW
Expand Down
Loading