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 original SCI protocol #25

Merged
merged 1 commit into from Aug 23, 2016
Merged

Add support for the original SCI protocol #25

merged 1 commit into from Aug 23, 2016

Conversation

lopsided98
Copy link
Contributor

@lopsided98 lopsided98 commented Jul 14, 2016

This PR adds support for the original SCI protocol used by the Discovery and 400 series (though apparently not all of them) Roombas.

Since three robots are now supported, the existing system of specifying which model to use did not work that well. Therefore, I decided to create a new RobotModel class, which encapsulates the the wheelbase width, baud rate, and protocol version, as well as any other parameters that might differ between models.

I added a new ProtocolVersion enum which largely replaces the old RobotModel enum in the various conditionals that decide how to communicate with the robot. The three protocol versions are based on the three documents that describe them:

Like we talked about, I split the Serial class into SerialStream and a new SerialQuery class which uses the Sensors command to retrieve data.

Since V_1 does not include the "drive direct" command, and this is a very important command for create_autonomy, I decided to emulate it using the "drive" command.

I also had to emulate the mode retrieval and requested wheel velocities because they are not supported in V_1. I decided to not request the requested velocity sensor packets (even when they are supported) since the exact same functionality can be gained by just caching the last requested velocities in driveWheels().

I found that the odometry on my Roomba 400 is much better than on my Create because the angle field is implemented as "the right wheel distance minus the left wheel
distance, divided by two" and it does not have the same bug as the angle field on the Create 1.

I tested this on my Roomba and my Create, but there is a possibility that I broke the odometry on the Create 2, so I would recommend testing it.

Let me know what you think. I will have a PR for create_autonomy soon that supports these changes.

ADD_PACKET(ID_CLIFF_RIGHT, 1, "cliff_right", V_ALL);
ADD_PACKET(ID_VIRTUAL_WALL, 1, "virtual_wall", V_ALL);
ADD_PACKET(ID_OVERCURRENTS, 1, "overcurrents", V_1);
ADD_PACKET(ID_DIRT_DETECT_LEFT, 1, "dirt_detect_left", V_1 | V_2);
Copy link
Member

Choose a reason for hiding this comment

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

I think for DIRT_DETECT_LEFT it should be V_ALL

@jacobperron
Copy link
Member

Nice work
👍 for RobotModel and separate serial classes.

I'll try it out on the Create 2 and let you know how it goes.

@jacobperron
Copy link
Member

Tried out the changes on a Create 1 and a Create 2. Everything seems to be OK 👍

@jacobperron
Copy link
Member

@lopsided98 Could you please add a brief section to the README with links to the three supported protocols? Thanks.

@jacobperron
Copy link
Member

Thanks, if you squash your commits I'll merge 👍

@jacobperron jacobperron merged commit 2297d1d into AutonomyLab:master Aug 23, 2016
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