Closed SiddharthZokarkar closed 1 year ago
Hello, @SiddharthZokarkar I do not see any usleep inside rclc_executor_spin_some
. Could you send a link to the line?
Hello @pablogs9 ,
I think i phrased the question incorrectly . So sorry for that.
I am talking about the usleep(100000) used inside the while loop .
while(1){ rclc_executor_spin_some(&executor, RCL_MS_TO_NS(100)); usleep(100000); } Line 48 in the below link: []((https://github.com/micro-ROS/freertos_apps/blob/humble/apps/int32_subscriber/app.c)
I am curious , why the delay of usleep(100000) is used inside the while loop?
Is there any specific reason?
This code (int32_subscriber) came as an example when I gitclone the repository git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro_ros_setup.git src/micro_ros_setup
I guess that the specific reason for that is to allow the FreeRTOS kernel to execute tasks with lower priority and to avoid the micro-ROS task taking the whole CPU.
Thanks for the real quick reply . Ok It seems to be reasonably important to use usleep(100000). and I think the value inside the usleep() can also be changed according to the number of tasks.
It looks like in rclc_executor_spin(&executor); function the FreeRTOS kernel is giving all the priority to the micro-ROS task and it is taking the whole CPU . Is it correct?
It depends on the board and toolchain that you are using, but normally the user application shall have a priority between the inner tasks (timers, ethernet...) and the idle one.
Ok Thank you so much !!
Hello @pablogs9 ,
In function RCCHECK(rclc_executor_add_subscription(&executor, &subscriber, &msg, &subscription_callback, ON_NEW_DATA));
Instead of "ON_NEW_DATA" , I used "ALWAYS" just to observe the subscriber behaviour.
And I observed that it is also calling the subscription_callback function only when the new data is arrived.
I have not used any kind of trigger conditions like a "timer" etc.
For reference I just changed "ON_NEW_DATA" to "ALWAYS" in the below link code:
https://github.com/micro-ROS/freertos_apps/blob/iron/apps/int32_subscriber/app.c
So is it true that by default , "ALWAYS" also behaves similar to "ON_NEW_DATA" unless a trigger condition has been changed?
Hello @pablogs9 ,
I am using the below mentioned code of int32_subscriber (below link). [](url)
I am curious , why the delay of usleep(100000) is used inside the rclc_executor_spin_some() function? Is there any specific reason?
As after removing the delay the performance is better.
Thanks in advance!!