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 serial sync errors caused by multi thread collision #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Roger-random
Copy link

SYMPTOM: Unpredictable errors when calling roboclaw API, manifesting
in several different forms such as "OSError: 11"

CAUSE: The roboclaw API is not thread-safe, but we have three different
threads potentially calling into the API simultaneously. When this
occurs, errors follow.

  1. self.run for our '/odom' publisher thread
  2. self.cmd_vel_callback as '/cmd_vel' subscriber
  3. self.check_vitals running for diagnostics

FIX: Use a threading.Lock() object to synchronize usage of roboclaw
API object. Thereby ensuring only one thread will be communicating
with roboclaw at any given time.

REFERENCES:

ROS Python API Threading Model
https://answers.ros.org/question/9543/rospy-threading-model/

StackOverflow "Semaphores on Python"
https://stackoverflow.com/questions/31508574/semaphores-on-python

SYMPTOM: Unpredictable errors when calling roboclaw API, manifesting
in several different forms such as "OSError: 11"

CAUSE: The roboclaw API is not thread-safe, but we have three different
threads potentially calling into the API simultaneously. When this
occurs, errors follow.
1. self.run for our '/odom' publisher thread
2. self.cmd_vel_callback as  '/cmd_vel' subscriber
3. self.check_vitals running for diagnostics

FIX: Use a threading.Lock() object to synchronize usage of roboclaw
API object. Thereby ensuring only one thread will be communicating
with roboclaw at any given time.

REFERENCES:

ROS Python API Threading Model
https://answers.ros.org/question/9543/rospy-threading-model/

StackOverflow "Semaphores on Python"
https://stackoverflow.com/questions/31508574/semaphores-on-python
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.

None yet

1 participant