Fix to avoid TypeError with encoder count value of 'None' #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SYMPTOM: Unpredictable errors occurring at runtime
File "roboclaw_node.py", line 232, in run
rospy.logdebug(" Encoders %d %d" % (enc1, enc2))
TypeError: %d format: a number is required, not NoneType
SEE: Issue #13
CAUSE: Error when calling roboclaw.ReadEnc would result in encoder
values 'enc1' or 'enc2' to be None instead of a number. This triggers
TypeError as described above.
FIX: Do exactly what TypeError wants us to do: make sure both 'enc1' and
'enc2' are numbers before trying to format them as numbers for logging.
(Note this does not address root cause of ReadEnc failure, that will be
submitted as a separate fix.)
REFERENCE: Python number check courtesy of StackOverflow: https://stackoverflow.com/questions/3441358/what-is-the-most-pythonic-way-to-check-if-an-object-is-a-number