-
Notifications
You must be signed in to change notification settings - Fork 0
Changes for native posix builds #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
usleep() in main loop under native posix causes the app to stop responding. Changing to zephyr's k_msleep() fixes this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while(1){ | ||
rclc_executor_spin_some(&executor, 100); | ||
usleep(100000); | ||
k_msleep(100); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
prj_native_posix.conf
Outdated
#CONFIG_POSIX_API=y | ||
#CONFIG_PICOLIBC=y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove them.
There was a problem hiding this comment.
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.
prj_native_posix.conf
Outdated
|
||
#CONFIG_POSIX_API=y | ||
#CONFIG_PICOLIBC=y | ||
CONFIG_PTHREAD_IPC=n |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
No description provided.