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

Add support for the remaining sensors from the OI spec, and create request functions to better support encoder outputs. #28

Conversation

15jgme
Copy link
Contributor

@15jgme 15jgme commented Feb 17, 2024

Hi @AtsushiSakai, thanks for this awesome library!

This PR adds the remainder of the sensor packets from the Roomba Open Interface to the Sensors dict, so that they may be queried.
I need to use encoder data for my project, so I also added a few functions to make requesting the distance and angular displacement from the Roomba a bit cleaner. I also updated the examples that I thought were relevant.

I did a couple of tests with my 630 and distance and angle measurements were low by about 10% (though I do have a non-stock roomba).

The spec does contain the following note about the distance packet and a similar one is present for the angle packet:

Create 2 and Roomba 500/600 firmware versions prior to 3.3.0 return an incorrect value for
sensors measured in millimeters. It is recommended that you read the left and right encoder counts
directly (packets IDs 43 and 44) and do the unit conversion yourself.

This doesn't effect my Roomba, but in the future if it's of interest I could add a function (or change request_angle and request_distance) to do the calculation there from the encoder counts so we know it's correct.

… Create request functions to better support encoder usage. Update examples and README.
Copy link
Owner

@AtsushiSakai AtsushiSakai left a comment

Choose a reason for hiding this comment

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

Thank you for your great PR!!. I have a just document comment. PTAL.

Linear distance traversed by each wheel is defined by the following:
distance = (π * 72.0 / 508.8) * count.

:return: Output range -32767 - 32768
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
:return: Output range -32767 - 32768
:return: a tuple of (left count, right count) in range -32767 - 32768

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the quick review! I totally agree on the return doc comment, e91534f should correct it.

@AtsushiSakai
Copy link
Owner

After, merge this PR, I will release v0.3.0.

Copy link
Owner

@AtsushiSakai AtsushiSakai left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!!

@AtsushiSakai AtsushiSakai merged commit 271c2ae into AtsushiSakai:master Feb 18, 2024
@15jgme 15jgme deleted the feature/add-sensors-and-encoder-support branch February 18, 2024 02:49
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

2 participants