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

Switch all Encoders and Sparks to SimDevices #10

Merged
merged 4 commits into from
Dec 27, 2020
Merged

Conversation

CoolSpy3
Copy link
Member

Fixes #8.

Comment on lines 15 to 20
public MockedSparkEncoder(String name) {
this.name = name;
// Match motor on CAN 0 with channels [0, 1], CAN 1 to channels [2, 3], etc.
// Probably not the best way to do it but it works
encoder = new EncoderSim(id);
webotsEncoder = Simulation.getRobot().getMotor(name).getPositionSensor();
encoder = new SimDeviceSim(name);
webotsEncoder = Simulation.getRobot().getMotor(name.substring(11)).getPositionSensor();
Copy link
Member

Choose a reason for hiding this comment

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

Parse out the motor name and CAN ID in SimRegisterer.java (where you are already interpreting the device string), and pass them into the constructor. That should make it clearer how the device name is formatted. Please also add a comment with the parsing, that makes it clear what the expected format is.

@CoolSpy3 CoolSpy3 requested a review from brettle December 27, 2020 00:59
@CoolSpy3 CoolSpy3 merged commit fb3e0d1 into master Dec 27, 2020
@brettle brettle deleted the fix-encoders branch January 1, 2021 04:24
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.

Encoder registration too specific
2 participants