Skip to content
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

Fix oled by using thread safe run_coroutine_threadsafe #39

Merged
merged 4 commits into from
Oct 27, 2023

Conversation

ArendJan
Copy link
Contributor

@ArendJan ArendJan commented Oct 26, 2023

the ros service is started on a different thread than the asyncio loop.
When using the normal loop.run_until_complete() function, both threads join in and there might be race conditions and the oled function might break faster.
With run_corotine_threadsafe, the function is started on the asyncio thread, without the ros service thread joining in and 'helping'.

Tested it with this code:

from mirte_robot import robot
mirte=robot.createRobot()
for count2 in range(100000000):
  mirte.setOLEDText('left', ('Hi' + str(count2)))

Worked for at least 10 minutes at 5Hz.

@ArendJan ArendJan added this to the 0.1 milestone Oct 26, 2023
@ArendJan ArendJan added the bug Something isn't working label Oct 26, 2023
@ArendJan ArendJan self-assigned this Oct 26, 2023
@ArendJan ArendJan requested a review from mklomp October 26, 2023 19:34
@ArendJan ArendJan marked this pull request as ready for review October 26, 2023 19:34
@ArendJan ArendJan linked an issue Oct 26, 2023 that may be closed by this pull request
@ArendJan
Copy link
Contributor Author

When it crashes, it does not crash the whole telemetrix node, but only the communication with the oled.
This is either an i2c issue or oled issue. Restarting the communication with the oled or restarting the i2c might fix this.

I think that this is not an thing to solve for v0.1, but something to look into for v0.2

Copy link
Contributor

@mklomp mklomp left a comment

Choose a reason for hiding this comment

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

Nice that it keeps running for this long. Agreed that we might need to have a more thorough look at it for v0.2.

We also might have a look at aiorospy. Initially this was used everywhere. Not sure why I removed the, except for the OLED. This might also be something to look into. Prefereably I do not use aiorospy (extra dependence, and not (yet) ported to ROS2). But as mentioned, I have no clue why I removed it almost everywhere else.

@mklomp mklomp merged commit b91d972 into mirte-robot:main Oct 27, 2023
2 checks passed
@ArendJan ArendJan deleted the fix-oled branch January 19, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

OLED makes Telemetrix crash
2 participants