Multiple Sensors on one microcontroller node

asked 2022-04-17 06:24:53 -0500

mkrug gravatar image

Dear all,

First of all, I'm new in ROS but quite experienced in embedded programming. My question is, how can it be realized to have several sensors connected to a uC that runs micro ROS and is publishing this data? In my case I have 10 ultrasonic sensors, 6 DOF acc/gyro, 3 PWM signals (capture time events). All of them are sampled with different rates (10ms/20ms/100ms). Additionally I subscribe to a message that is a multibyte array at the moment. All information is published via a single serial line to a ROS host. The application on the uC requires a RTOS.

I looked into rosserial and was pretty much disappointed about the way it is realized there. It will only work if you have one single endless loop - so this is for my really far below a reasonable level of software engineering. So I moved to micro ROS. Things getting more organized but here are my questions:

  • The Transfer (publish/subscribe) can be done via DMA. This is great. However, there is no protection at all that several publish calls will interfere with each other. In real applications they will very likely interfere if they are issued in different tasks with different sampling rates. So I maybe missed something - please give me advice how to overcome this problem.
  • Even if the DMA transfer is issued only from a single task there is a risk, that the previous transfer is not finished yet. For me this risk is real, because the ROS messages have a huge overhead and the serial line is limited in its bandwidth. I'm using a STM32 device. In their DMA calls there is a check if the DMA is able to execute that call. If not, the call is ignored and an error number is returned. The error number is read by the micro ROS code - but with the consequence to wait until that error number will change into 'success'. That will never happen in the way it is implemented in the micro ROS code. So you run into an dead-end and maybe only a timeout will help you out. But I'm not sure if a timeout is implemented. In any case I think this is a really bad implementation.
  • In the micro ROS code there are several osDelay() calls. At least in the FreeRTOS version. But the introduced delay has nothing to do with the purpose. The purpose is actually to wait and not to delay. So why is there no implementation with semaphores (that can be combined with delay if needed)?
  • To use micro ROS you are requested to use docker first to generate the micro ROS library. I understand that this allows a self-contained environment to generate that lib. But is this really meaningful? Why not setting up a directory tree with all the library source code that is added to the individual project. It will be compiled only once anyway. Probably I can do this myself - but ...
edit retag flag offensive close merge delete