gauteh / sfy

🌊 A lightweight wave buoy for near-shore deployments.
MIT License
39 stars 6 forks source link

wire: start serializing as u16 #113

Closed gauteh closed 1 year ago

gauteh commented 1 year ago

@jerabaul29 I get about two decimals accuracy when doing round-trip serializations.

https://github.com/gauteh/sfy/pull/113/files#diff-b9a853ae65eda204eb14283f1428b451ff30095919f8ae0890aa1127c37def99R71

gauteh commented 1 year ago
test waves::wire::tests::round_trip_integers ... ok
accel half avg diff: 0.0024894755
accel half max diff: 0.0078125
test waves::wire::tests::round_trip_accel_half16 ... ok
accel u16 avg diff: 0.00044897446
accel u16 max diff: 0.0008983612
test waves::wire::tests::round_trip_accel ... ok
gyro u16 avg diff: 0.00009988881
gyro u16 max diff: 0.00019979477
test waves::wire::tests::round_trip_gyro ... ok
gyro half avg diff: 0.0005784875
gyro half max diff: 0.001953125
test waves::wire::tests::round_trip_gyro_half16 ... ok

Seems like it does perform better.

gauteh commented 1 year ago

Resolution obviously depends on range, now I use a fixed range of:

2 * 3 * 9.81 for accel, unit m/2^2
2 * 3 * 125 * DPS_TO_RAD for gyro, unit rad/s

rads is better than dps, maybe using g's would be better. conversion is done in f64 to avoid overflow.