Skip to content

Fix to avoid TypeError with encoder count value of 'None'#16

Open
Roger-random wants to merge 1 commit into
sonyccd:masterfrom
Roger-random:encoder-is-number-pr
Open

Fix to avoid TypeError with encoder count value of 'None'#16
Roger-random wants to merge 1 commit into
sonyccd:masterfrom
Roger-random:encoder-is-number-pr

Conversation

@Roger-random

@Roger-random Roger-random commented Sep 6, 2018

Copy link
Copy Markdown

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

SYMPTOM: Unpredictable erros 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

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
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.

1 participant