-
Notifications
You must be signed in to change notification settings - Fork 3
Using Encoders to Control Motor Position
Encoders are sensors that get the position of a motor in "counts"; there are a certain number of counts per second for each motor that can be found on the REV website and have to be adjusted for gear ratios.
Here is a page for how to code motors using encoders. It is useful for driving drivetrains certain distances (although should not be used by itself here as it does not take into account the robot slipping) and for moving arms to certain heights.)
Loop times are how long it takes for the robot to complete a loop in software. Usually, below 50 ms is a good loop time. One should not worry about loop times specifically being an issue unless you are using swerve in FTC. However, decreasing loop times in general is still good practice.
A much better explanation of bulk reads can be found in ConceptMotorBulkRead in the samples of the SDK, and you should absolutely refer to that.
TLDR: Manually clearing the cache is the most efficient way of reads.
At init(), go through all of your LynxModules (representation of Expansion Hub or Control Hub in code) and set bulk caching mode to be MANUAL.
At loop(), clear the bulk cache for every LynxModule before reading from motors.
Now you can do all the reads you want without any penalty.
For a demonstration of this in code, refer to ConceptMotorBulkRead again.
| Shortcuts: | 🧑💻 Code |
🏠 Wiki Home |
🧾 FTCLib Docs |
☑️ Project |
|---|