RPM: clean up message

This commit is contained in:
Matthias Grob 2024-11-27 14:51:28 +01:00
parent a60591378c
commit c463cc42d0
5 changed files with 11 additions and 19 deletions

View File

@ -1,7 +1,4 @@
uint64 timestamp # time since system start (microseconds)
float32 indicated_frequency_rpm # indicated rotor Frequency in Revolution per minute
float32 estimated_accurancy_rpm # estimated accuracy in Revolution per minute
uint64 timestamp # time since system start (microseconds)
float32 rpm_estimate # filtered revolutions per minute
float32 rpm_raw # measured rpm
float32 rpm_estimate # filtered rpm

View File

@ -196,12 +196,10 @@ void PCF8583::RunImpl()
// Calculate RPM and accuracy estimation
float indicated_rpm = (((float)diffCount / _param_pcf8583_magnet.get()) / ((float)diffTime / 1e6f)) * 60.f;
float estimated_accurancy = 1 / (float)_param_pcf8583_magnet.get() / ((float)diffTime / 1e6f) * 60.f;
// publish data to uorb
rpm_s msg{};
msg.indicated_frequency_rpm = indicated_rpm;
msg.estimated_accurancy_rpm = estimated_accurancy;
msg.rpm_estimate = indicated_rpm;
msg.timestamp = hrt_absolute_time();
_rpm_pub.publish(msg);

View File

@ -66,8 +66,7 @@ int rpm_simulator_main(int argc, char *argv[])
// prpepare RPM data message
rpm.timestamp = timestamp_us;
rpm.indicated_frequency_rpm = frequency;
rpm.estimated_accurancy_rpm = frequency / 100.0f;
rpm.rpm_estimate = frequency;
// Publish data and let the user know what was published
rpm_pub.publish(rpm);

View File

@ -68,7 +68,7 @@ private:
mavlink_raw_rpm_t msg{};
msg.index = i;
msg.frequency = rpm.indicated_frequency_rpm;
msg.frequency = rpm.rpm_estimate;
mavlink_msg_raw_rpm_send_struct(_mavlink->get_channel(), &msg);
updated = true;

View File

@ -388,14 +388,12 @@ void SimulatorMavlink::handle_message(const mavlink_message_t *msg)
break;
case MAVLINK_MSG_ID_RAW_RPM:
mavlink_raw_rpm_t rpm;
mavlink_msg_raw_rpm_decode(msg, &rpm);
rpm_s rpmmsg{};
rpmmsg.timestamp = hrt_absolute_time();
rpmmsg.indicated_frequency_rpm = rpm.frequency;
rpmmsg.estimated_accurancy_rpm = 0;
_rpm_pub.publish(rpmmsg);
mavlink_raw_rpm_t rpm_mavlink;
mavlink_msg_raw_rpm_decode(msg, &rpm_mavlink);
rpm_s rpm_uorb{};
rpm_uorb.timestamp = hrt_absolute_time();
rpm_uorb.rpm_estimate = rpm_mavlink.frequency;
_rpm_pub.publish(rpm_uorb);
break;
}
}