Skip to content

Conversation

chris-hl
Copy link
Collaborator

No description provided.

usleep() in main loop under native posix causes the app to stop responding.
Changing to zephyr's k_msleep() fixes this.
@chris-hl chris-hl requested a review from yashi October 28, 2022 01:47
Copy link
Owner

@yashi yashi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prj_native_posix{,_64}.conf feels not minimum. Have you used save config in menuconfig?
image

while(1){
rclc_executor_spin_some(&executor, 100);
usleep(100000);
k_msleep(100);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm. I'm not sure why. Would you mind enlightening me?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming that with host's usleep() Zephyr doesn't schedule the sleeping thread.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your assumption is correct.
This change helped this application work better, but there is still the problem that the ROS and uROS libs use usleep()
Example: modules/lib/rclc/src/rclc/sleep.c

However, I wasn't too concerned about this as it only has to work well enough for CI tests on native_posix builds.
For bare-metal builds Zephyr's usleep() will be used.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example: modules/lib/rclc/src/rclc/sleep.c

That's easy to fix. See yashi/rclc#1

@@ -1 +1,39 @@
CONFIG_MAIN_THREAD_PRIORITY=3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind explaining to me why the main thread must be priority 3?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONFIG_MAIN_THREAD_PRIORITY=3
comes directly from the original prj.conf file of the micro_ros_zephyr_module application.

There was no indication why it was set to that value in the original project.
I had no reason to change it so left it as is.

Comment on lines 4 to 5
#CONFIG_POSIX_API=y
#CONFIG_PICOLIBC=y
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do - I will convert all the prj_XXX.conf files to their minimal form.


#CONFIG_POSIX_API=y
#CONFIG_PICOLIBC=y
CONFIG_PTHREAD_IPC=n
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is default n if !POSIX_API. Why do we need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will convert all the prj_XXX.conf files to their minimal form.

Copy link
Owner

@yashi yashi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've wrote this a while ago but didn't publish it. Better late than never.

while(1){
rclc_executor_spin_some(&executor, 100);
usleep(100000);
k_msleep(100);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example: modules/lib/rclc/src/rclc/sleep.c

That's easy to fix. See yashi/rclc#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants