-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make it possible to sim rev flex * Make more generic * Fix bazel
- Loading branch information
1 parent
560d55d
commit 18e0884
Showing
5 changed files
with
47 additions
and
6 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
..._sim_java_revlib/src/main/java/org/snobotv2/module_wrappers/rev/RevEncoderSimWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...ot_sim_java_revlib/src/test/java/org/snobotv2/module_wrappers/rev/TestRevFlexEncoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.snobotv2.module_wrappers.rev; | ||
|
||
import com.revrobotics.CANSparkLowLevel; | ||
import com.revrobotics.RelativeEncoder; | ||
import com.revrobotics.SimableCANSparkFlex; | ||
import org.junit.jupiter.api.Test; | ||
import org.snobotv2.sim_wrappers.InstantaneousMotorSim; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class TestRevFlexEncoder | ||
{ | ||
@Test | ||
public void testEncoder() | ||
{ | ||
try (SimableCANSparkFlex sparkFlex = new SimableCANSparkFlex(1, CANSparkLowLevel.MotorType.kBrushless)) | ||
{ | ||
RelativeEncoder encoder = sparkFlex.getEncoder(); | ||
|
||
InstantaneousMotorSim motorSim = new InstantaneousMotorSim( | ||
new RevMotorControllerSimWrapper(sparkFlex), | ||
RevEncoderSimWrapper.create(sparkFlex), | ||
10); | ||
|
||
for (int i = 0; i < 100; ++i) | ||
{ | ||
sparkFlex.set(0.5); | ||
motorSim.update(); | ||
} | ||
|
||
assertEquals(10, encoder.getPosition(), 0.001); | ||
assertEquals(5, encoder.getVelocity(), 0.001); | ||
} | ||
} | ||
} |