acassis commented on code in PR #20567:
URL: https://github.com/apache/nuttx/pull/20567#discussion_r4233480325


##########
include/nuttx/uorb.h:
##########
@@ -1136,6 +1148,15 @@ struct sensor_charge        /* Type: Charge */
   int64_t charge;           /* Accumulated charge. Unit is uC. */
 };
 
+struct sensor_inclinometer   /* Type: Inclinometer */
+{
+  uint64_t      timestamp;   /* Units is microseconds */
+  sensor_data_t x;           /* X axis inclination in degrees */

Review Comment:
   (A)I'd keep degrees, for three reasons.
   
   1) Angle types in uORB already use degrees. `SENSOR_TYPE_ORIENTATION` 
   (azimuth/pitch/roll), the hinge angle (`sensor_angle.angle`) and the GNSS 
   latitude/longitude are all in degrees. Radians are used for rates 
(gyroscope, 
   rad/s) and for the rotation vector's accuracy. An inclination is an absolute 
   angle like orientation or hinge angle, so degrees keeps it consistent with 
   those.
    
   2) Degrees are exact; radians always round. The datasheet defines the angle 
   output as ANG = raw / 2^14 * 90°.
   - In degrees, the conversion is a multiply by 90 and a divide by a power of 
two.
   That's exact in `float`, and exact in `CONFIG_SENSORS_USE_B16` too (b16 
value =
   raw * 360, an integer). The published value is the sensor's own reading with 
no
   rounding at all.
   - In radians, the conversion is raw * pi / 2^15. pi makes every value 
inexact, 
   and in B16 the step becomes 1/65536 rad = 0.00087°. That adds a rounding 
error 
   of up to about 16% of the sensor's 0.0055° LSB.
   
   For the dam monitoring use case, where we're looking for changes of 
hundredths 
   of a degree, I'd rather publish the exact value than add an error the sensor 
   doesn't have.
    
   3) Users and alarm thresholds work in degrees. The datasheet, the 
   inclinometer industry and structural monitoring standards all state tilt in 
   degrees (or mdeg/arcsec). An application can still convert to radians with 
one 
   multiply if it needs to, but it can't undo rounding that already happened in 
the
   driver.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to