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
+2 -5
View File
@@ -1,7 +1,4 @@
uint64 timestamp # time since system start (microseconds) 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
float32 rpm_estimate # filtered revolutions per minute
float32 rpm_raw # measured rpm float32 rpm_raw # measured rpm
float32 rpm_estimate # filtered rpm
+1 -3
View File
@@ -196,12 +196,10 @@ void PCF8583::RunImpl()
// Calculate RPM and accuracy estimation // Calculate RPM and accuracy estimation
float indicated_rpm = (((float)diffCount / _param_pcf8583_magnet.get()) / ((float)diffTime / 1e6f)) * 60.f; 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 // publish data to uorb
rpm_s msg{}; rpm_s msg{};
msg.indicated_frequency_rpm = indicated_rpm; msg.rpm_estimate = indicated_rpm;
msg.estimated_accurancy_rpm = estimated_accurancy;
msg.timestamp = hrt_absolute_time(); msg.timestamp = hrt_absolute_time();
_rpm_pub.publish(msg); _rpm_pub.publish(msg);
@@ -66,8 +66,7 @@ int rpm_simulator_main(int argc, char *argv[])
// prpepare RPM data message // prpepare RPM data message
rpm.timestamp = timestamp_us; rpm.timestamp = timestamp_us;
rpm.indicated_frequency_rpm = frequency; rpm.rpm_estimate = frequency;
rpm.estimated_accurancy_rpm = frequency / 100.0f;
// Publish data and let the user know what was published // Publish data and let the user know what was published
rpm_pub.publish(rpm); rpm_pub.publish(rpm);
+1 -1
View File
@@ -68,7 +68,7 @@ private:
mavlink_raw_rpm_t msg{}; mavlink_raw_rpm_t msg{};
msg.index = i; msg.index = i;
msg.frequency = rpm.indicated_frequency_rpm; msg.frequency = rpm.rpm_estimate;
mavlink_msg_raw_rpm_send_struct(_mavlink->get_channel(), &msg); mavlink_msg_raw_rpm_send_struct(_mavlink->get_channel(), &msg);
updated = true; updated = true;
@@ -388,14 +388,12 @@ void SimulatorMavlink::handle_message(const mavlink_message_t *msg)
break; break;
case MAVLINK_MSG_ID_RAW_RPM: case MAVLINK_MSG_ID_RAW_RPM:
mavlink_raw_rpm_t rpm; mavlink_raw_rpm_t rpm_mavlink;
mavlink_msg_raw_rpm_decode(msg, &rpm); mavlink_msg_raw_rpm_decode(msg, &rpm_mavlink);
rpm_s rpmmsg{}; rpm_s rpm_uorb{};
rpmmsg.timestamp = hrt_absolute_time(); rpm_uorb.timestamp = hrt_absolute_time();
rpmmsg.indicated_frequency_rpm = rpm.frequency; rpm_uorb.rpm_estimate = rpm_mavlink.frequency;
rpmmsg.estimated_accurancy_rpm = 0; _rpm_pub.publish(rpm_uorb);
_rpm_pub.publish(rpmmsg);
break; break;
} }
} }