You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "raiden00pl (via GitHub)" <gi...@apache.org> on 2025/11/29 20:58:34 UTC
[PR] WIP: initial support for fixed-point data for sensors [nuttx]
raiden00pl opened a new pull request, #17408:
URL: https://github.com/apache/nuttx/pull/17408
## Summary
WIP code for fixed-math data type for sensors.
All sensor math operations will require modification to use `sensor_data_xxx` macros.
At the moment, no sensor is modified to handle this properly. I'll probably choose the easiest sensor to port with a small amount of math operations to provide PoC.
Ultimately, all sensor units must be checked to see if the data unit make sense for the b16_t type.
Doing this work all at once is a lot of work which I don't want to do, so I suggest introducing this change gradually:
1. introducing a configurable sensor data type and raise compilation error in all sensors that don't support fixed-point data type
2. gradually port sensors to use fixed-point data and remove compilation errors
3. on the app side we need to modify uorb tools to work with fixed-point data. At this moment we can just raise compilation error for fixed-point data type, and add `depends on SENSORS_USE_FLOAT`
## Impact
## Testing
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#issuecomment-4150426653
I've done some tests with thingy53 and it works well. The only problem is that `b16_t` saturates faster than float and for some sensors full sensor range can't be achieved. But this is something we have to accept when choosing this type of data.
Here sensors with float:
<img width="3006" height="1764" alt="thingy53_f32" src="https://github.com/user-attachments/assets/5945671b-676d-4a48-b5dd-3c17d467c171" />
Here sensors with b16_t (you can observe that rgb0 saturate at ~32k) :
<img width="3006" height="1764" alt="thingy53_b16" src="https://github.com/user-attachments/assets/1307ad7b-2100-4202-b860-1981a761b1c5" />
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r2586393879
##########
drivers/sensors/Kconfig:
##########
@@ -17,6 +17,24 @@ config USENSOR
---help---
Allow application to register user sensor by /dev/usensor.
+choice
+ prompt "Sensor framework data type"
+ default SENSORS_USE_FLOAT
+
+config SENSORS_USE_FLOAT
+ bool "Use float as data type for sensors"
+ ---help---
+ Use float as data type for sensors.
+ This option is recommended if for targets with FPU support.
+
+config SENSORS_USE_B16
Review Comment:
Makes sense! I thought b16 was 16-bit.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "lupyuen (via GitHub)" <gi...@apache.org>.
lupyuen commented on PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#issuecomment-4097593071
Hi @raiden00pl: I'm testing a new way to Build PRs in Our Own NuttX Repos, wonder if you would like to try out, and give your feedback to @simbit18 and me? Thank you so much :-)
1. [Demo Video in YouTube](https://youtu.be/19w_CeaANLw) <br> [Demo Video in Google Drive](https://drive.google.com/file/d/10RUJ2gnj2UqmTZZrKCmwhEw8DT3LYFh0/view?usp=drive_link)
2. Browse to [github.com/NuttX/manual-nuttx-ci](http://github.com/NuttX/manual-nuttx-ci)
3. Click "Fork" to clone the repo
4. Click "Actions > Enable GitHub Actions"
5. Click "Manually Build NuttX > Run Workflow"
6. Enter the following:
- Repo for NuttX: raiden00pl/nuttx
- NuttX Branch: sensors_fixedmath
- Repo for NuttX Apps: apache/nuttx-apps
- NuttX Apps Branch: master
- Host Platform: all
7. And the PR Build should start. Lemme know if it doesn't work thanks!
8. Why are we doing this? Earlier this year, we saw very high usage of GitHub Runners. By building PRs in Our Own NuttX Repos, we will greatly reduce our usage of GitHub Runners, so that ASF Infrastructure Team won't revoke our access to GitHub CI. So we hope everyone can help out thanks :-)
<img width="2144" height="1669" alt="Screenshot 2026-03-20 at 5 00 45 PM" src="https://github.com/user-attachments/assets/3d006d00-b0c2-4161-9919-3c0240f164e6" />
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #17408:
URL: https://github.com/apache/nuttx/pull/17408
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#issuecomment-3979478693
It would be best to choose sensor units that make sense for both float and fixed-point.
With this architecture it should be possible to add other data types for sensors, but using 64-bit data seems like a overkill to me. So far, the highest resolution of data in commercial available sensors that I have seen is 24 bits.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3172613658
##########
drivers/sensors/goldfish_sensor_uorb.c:
##########
@@ -45,6 +45,31 @@
* Pre-processor Definitions
****************************************************************************/
+/* Only float data type supported now */
+
+#ifdef CONFIG_SENSORS_USE_B16
+# error fixed-point data type not supported yet
+#endif
+
+#define GOLDFISH_ACCELERATION 0
Review Comment:
why add
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#issuecomment-4352519171
I am traveling today so I'll give this a thorough review while on the train if it's ready to merge! Exciting feature!
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3168219591
##########
drivers/sensors/lis2mdl_uorb.c:
##########
@@ -49,6 +49,12 @@
* Pre-processor Definitions
****************************************************************************/
+/* Only float data type supported now */
+
+#ifdef CONFIG_SENSORS_USE_B16
Review Comment:
why? fixedmath is much slower and bigger than hardware FPU, it isn't good to switch to fixedmath blindly.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#issuecomment-4336007691
> @linguini1 the purpose of introducing b16 is to reduce memory footprint for small systems without FPU. Using b16 allows us to use standard math operations available on 32bit CPUs. With b32 we introduce 64-bit math, which may require the compiler to introduce soft support for 64 int, essentially defeating the purpose of reducing memory footprint. In such a case, it's worth considering whether it would't be better to simply use soft-float.
>
> I haven't tested this, but I think b32 will still use less memory than soft-float, so this idea makes sense. This just needs to be confirmed by compilation. The overall architecture of this change allows us to add any number format we want, b32 or even double. If there's a need for it among users, we should add it.
That makes sense. I suppose I'd be using a 32b RISCV MCU which probably wouldn't like 64bit integers. I would still use 64b if it was faster computation than floats, regardless of memory. I guess the downside of having a unified interface if having something that works everywhere; a lot of these sensors already return their measurements as integers, just in non-SI units.
What else needs to be added/tested before we merge this? I can help test some more.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#issuecomment-4320231292
I'm hoping to try using this with an upcoming project; do you think we could add an option so that the user can choose between b16 and b32? I'm using a barometer in a rocket which should experience a pretty wide range of pressures, I'd like to avoid saturation but like the integer format.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3172691500
##########
drivers/sensors/goldfish_sensor_uorb.c:
##########
@@ -45,6 +45,31 @@
* Pre-processor Definitions
****************************************************************************/
+/* Only float data type supported now */
+
+#ifdef CONFIG_SENSORS_USE_B16
+# error fixed-point data type not supported yet
+#endif
+
+#define GOLDFISH_ACCELERATION 0
Review Comment:
garbage after rebase, removed
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3168341493
##########
drivers/sensors/lis2mdl_uorb.c:
##########
@@ -49,6 +49,12 @@
* Pre-processor Definitions
****************************************************************************/
+/* Only float data type supported now */
+
+#ifdef CONFIG_SENSORS_USE_B16
Review Comment:
why do you assume that every arch has FPU ? this was the fundamental flaw when creating the new sensor framework. There are modern CPUs without FPU and they still are useful in new applications (low power apps, low cost apps). After all, nothing is being replaced blindly here, the default is float implementation.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r2586281285
##########
drivers/sensors/Kconfig:
##########
@@ -17,6 +17,24 @@ config USENSOR
---help---
Allow application to register user sensor by /dev/usensor.
+choice
+ prompt "Sensor framework data type"
+ default SENSORS_USE_FLOAT
+
+config SENSORS_USE_FLOAT
+ bool "Use float as data type for sensors"
+ ---help---
+ Use float as data type for sensors.
+ This option is recommended if for targets with FPU support.
+
+config SENSORS_USE_B16
Review Comment:
Is there a b32_t equivalent? Maybe that would be good to increase precision.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3168219591
##########
drivers/sensors/lis2mdl_uorb.c:
##########
@@ -49,6 +49,12 @@
* Pre-processor Definitions
****************************************************************************/
+/* Only float data type supported now */
+
+#ifdef CONFIG_SENSORS_USE_B16
Review Comment:
why? fixedmath is much slower and bigger than hardware FPU, it isn't good to switch to fixedmath blindly on the modem cpu.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3170816636
##########
Documentation/components/drivers/special/sensors/sensors_uorb.rst:
##########
Review Comment:
I think we should add something like:
```rst
.. warning::
Using fixed-point math instead of floating point may cause sensors measurements to saturate where they wouldn't before. Verify that fixed-point data types are sufficient for your application. Just because a driver has fixed-point support _does not mean_ it can support the sensor's full range.
```
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3170816636
##########
Documentation/components/drivers/special/sensors/sensors_uorb.rst:
##########
Review Comment:
I think we should add something like:
```rst
.. warning::
Using fixed-point math instead of floating point may cause sensors measurements to saturate where they wouldn't before. Verify that fixed-point data types are sufficient for your application. Just because a driver has fixed-point support *does not mean* it can support the sensor's full range.
```
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r2586292709
##########
drivers/sensors/Kconfig:
##########
@@ -17,6 +17,24 @@ config USENSOR
---help---
Allow application to register user sensor by /dev/usensor.
+choice
+ prompt "Sensor framework data type"
+ default SENSORS_USE_FLOAT
+
+config SENSORS_USE_FLOAT
+ bool "Use float as data type for sensors"
+ ---help---
+ Use float as data type for sensors.
+ This option is recommended if for targets with FPU support.
+
+config SENSORS_USE_B16
Review Comment:
b32 is 64 bit number which is as bad for small systems as floats :)
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3168341493
##########
drivers/sensors/lis2mdl_uorb.c:
##########
@@ -49,6 +49,12 @@
* Pre-processor Definitions
****************************************************************************/
+/* Only float data type supported now */
+
+#ifdef CONFIG_SENSORS_USE_B16
Review Comment:
why do you assume that every arch has FPU ? this was the fundamental flaw when creating the new sensor framework. There are modern CPUs without FPU and they still are useful in new applications. After all, nothing is being replaced blindly here, the default is float implementation.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3167595333
##########
drivers/sensors/lis2mdl_uorb.c:
##########
@@ -49,6 +49,12 @@
* Pre-processor Definitions
****************************************************************************/
+/* Only float data type supported now */
+
+#ifdef CONFIG_SENSORS_USE_B16
Review Comment:
why not add SENSORS_HAVE_B16 option and let SENSORS_USE_B16 depend on SENSORS_HAVE_B16, so sensor which suppot b16_t could select SENSORS_HAVE_B16 in Kconfig
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3170790077
##########
Documentation/components/drivers/special/sensors/sensors_uorb.rst:
##########
@@ -48,11 +48,61 @@ sensor events are sent to the ring buffer in the upper layer.
:width: 800px
:align: center
-Problems to solve
-=================
+Sensor data type
+================
+
+The framework supports two types of sensor data:
+
+#. ``float`` if ``CONFIG_SENSORS_USE_FLOAT=y``, not recommended for
+ targets without FPU.
+
+#. ``b16_t`` if ``CONFIG_SENSORS_USE_B16=y``, recommended for targets without
+ FPU.
+
+Currently all sensors support ``float``, support for ``b16_t`` is work-in-progress.
+
+To create generic drivers that support both data types, you should use the dedicated
+sensor data type:
+
+.. code:: C
+
+ /* Data type for sensors */
+
+ #ifdef CONFIG_SENSORS_USE_B16
+ typedef b16_t sensor_data_t;
+ #else
+ typedef float sensor_data_t;
+ #endif
+
+Mathematical operations on this type should only be performed using dedicated
+macros:
+
+- ``sensor_data_ftof(f1)`` - convert float to sensor data number.
+ Should be used only for compile-time constants.
+
+- ``sensor_data_itof(i)`` - convert int to sensor data number.
+
+- ``sensor_data_inv(i)`` - invert int and convert to sensor data number
+
+- ``sensor_data_add(f1, f2)`` - add two sensor data numbers
+
+- ``sensor_data_sub(f1, f2)`` - subtract two sensor data numbers
+
+- ``sensor_data_subi(f1, i)`` - subtract int from sensor data number
+
+- ``sensor_data_mul(f1, f2)`` - multiplicate two sensor data numbers
+
+- ``sensor_data_muli(f1, i)`` - multiplicate sensor data with int
Review Comment:
multiplicate -> multiply
##########
include/nuttx/uorb.h:
##########
@@ -36,10 +36,80 @@
#include <nuttx/sensors/ioctl.h>
+#ifdef CONFIG_SENSORS_USE_B16
+# include <fixedmath.h>
+#endif
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+/* Sensor data math operations. Sensors driver must use these macros to
+ * create portable code!
+ *
+ * Available macros:
+ *
+ * - sensor_data_ftof(f1) - convert float to sensor data number.
+ * Should be used only for compile-time constants.
+ *
+ * - sensor_data_itof(i) - convert int to sensor data number.
+ *
+ * - sensor_data_inv(i) - invert int and convert to sensor data
+ * number
+ *
+ * - sensor_data_add(f1, f2) - add two sensor data numbers
+ *
+ * - sensor_data_sub(f1, f2) - subtract two sensor data numbers
+ *
+ * - sensor_data_subi(f1, i) - subtract int from sensor data number
+ *
+ * - sensor_data_mul(f1, f2) - multiplicate two sensor data numbers
+ *
+ * - sensor_data_muli(f1, i) - multiplicate sensor data with int
Review Comment:
ditto
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3170816636
##########
Documentation/components/drivers/special/sensors/sensors_uorb.rst:
##########
Review Comment:
I think we should add something like:
```rst
.. warning::
Using fixed-point math instead of floating point may cause sensors measurements to saturate where they wouldn't before. Verify that fixed-point data types are sufficient for your application.
```
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r2573198040
##########
include/nuttx/uorb.h:
##########
@@ -630,184 +630,184 @@
* reported.
*/
-struct sensor_event /* Type: Sensor Common Event */
+struct sensor_event /* Type: Sensor Common Event */
{
- uint64_t timestamp; /* Units is microseconds */
- uint32_t event; /* Common events */
+ uint64_t timestamp; /* Units is microseconds */
+ uint32_t event; /* Common events */
};
-struct sensor_accel /* Type: Accerometer */
+struct sensor_accel /* Type: Accerometer */
{
- uint64_t timestamp; /* Units is microseconds */
- float x; /* Axis X in m/s^2 */
- float y; /* Axis Y in m/s^2 */
- float z; /* Axis Z in m/s^2 */
- float temperature; /* Temperature in degrees celsius */
+ uint64_t timestamp; /* Units is microseconds */
+ sensor_data_t x; /* Axis X in m/s^2 */
+ sensor_data_t y; /* Axis Y in m/s^2 */
+ sensor_data_t z; /* Axis Z in m/s^2 */
+ sensor_data_t temperature; /* Temperature in degrees celsius */
};
-struct sensor_mag /* Type: Magnetic Field */
+struct sensor_mag /* Type: Magnetic Field */
{
- uint64_t timestamp; /* Units is microseconds */
- float x; /* Axis X in Gauss or micro Tesla (uT) */
- float y; /* Axis Y in Gauss or micro Tesla (uT) */
- float z; /* Axis Z in Gauss or micro Tesla (uT) */
- float temperature; /* Temperature in degrees celsius */
- int32_t status; /* Status of calibration */
+ uint64_t timestamp; /* Units is microseconds */
+ sensor_data_t x; /* Axis X in Gauss or micro Tesla (uT) */
+ sensor_data_t y; /* Axis Y in Gauss or micro Tesla (uT) */
+ sensor_data_t z; /* Axis Z in Gauss or micro Tesla (uT) */
+ sensor_data_t temperature; /* Temperature in degrees celsius */
+ int32_t status; /* Status of calibration */
};
-struct sensor_orientation /* Type: Orientation */
+struct sensor_orientation /* Type: Orientation */
{
- uint64_t timestamp; /* Units is microseconds */
- float x; /* azimuth */
- float y; /* pitch */
- float z; /* roll */
+ uint64_t timestamp; /* Units is microseconds */
+ sensor_data_t x; /* azimuth */
Review Comment:
@raiden00pl seems like you used some script to change the float to sensor_data_t, but the alignment of the variables from previous and following lines became wrong.
I think you can use the script to fix the "uint64_t timestamp;" alignment, but the other fields will need some manual work
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#issuecomment-4350343109
@linguini1 I think it's ready for merge. I was just waiting for more people to look at it and give some feedback. But we might as well open this PR now (along with the apps part)
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "linguini1 (via GitHub)" <gi...@apache.org>.
linguini1 commented on PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#issuecomment-3961327886
One more thing about this; we should investigate if b16 is ever too small for a sensor's resolution. I would imagine `float` might have this same problem when compared to `double` for high-resolution sensors, but if there are any values that would fit in float and not b16, we should consider:
a) having those sensors depend on the float representation, so users can only use them with floats
b) allowing the user to choose b16 vs b32 (and maybe also float vs double)?
What do you think?
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] initial support for fixed-point data for sensors [nuttx]
Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on code in PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#discussion_r3167762366
##########
drivers/sensors/lis2mdl_uorb.c:
##########
@@ -49,6 +49,12 @@
* Pre-processor Definitions
****************************************************************************/
+/* Only float data type supported now */
+
+#ifdef CONFIG_SENSORS_USE_B16
Review Comment:
This way, I think we can encourage users to port more sensors to fixedpoint math. If we hide the sensors in Kconfig, it can be more discouraging to use sensors with b16 than returning a compilation error. We want to have all sensors ported to use this new math operation (if possible), but this requires users involvement. This way, we can better engage potential users. But it's not something I'm going insist on, I might as well change it to the kconfig option.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] WIP: initial support for fixed-point data for sensors [nuttx]
Posted by "raiden00pl (via GitHub)" <gi...@apache.org>.
raiden00pl commented on PR #17408:
URL: https://github.com/apache/nuttx/pull/17408#issuecomment-4333953463
@linguini1 the purpose of introducing b16 is to reduce memory footprint for small systems without FPU. Using b16 allows us to use standard math operations available on 32bit CPUs. With b32 we introduce 64-bit math, which may require the compiler to introduce soft support for 64 int, essentially defeating the purpose of reducing memory footprint. In such a case, it's worth considering whether it would't be better to simply use soft-float.
I haven't tested this, but I think b32 will still use less memory than soft-float, so this idea makes sense. This just needs to be confirmed by compilation. The overall architecture of this change allows us to add any number format we want, b32 or even double. If there's a need for it among users, we should add it.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org