Comments (3)
It's very possible that your encoders are not connected correctly. And therefore not generating pulses to be counted. The code sample shows reading two sets of numbers from the motor controller hardware registers. This looks perfectly OK.
You say that "I know that PID is working because the motor ramps up it's power after moving."
But this in not conclusive. If you are requesting a constant slow speed, and the encoders are not connected properly, then the motor controller will start with low power, and then continue to ramp up the power in an attempt to generate encoder counts. Eventually it will max out the power. To me, this an indication of a disconnected encoder.
Please verify that the encoder is plugged into the correct motor channel (1 or 2) and that the encoder cable has been plugged in the correct way around (yellow wire near the outside edge of the motor controller).
I true indication that the encoders are being read correctly is that you can run the motors slow for several seconds and run them fast for several seconds.
from ftc_app.
I just verified that it is not a hardware issue. Instead it is a software bug (either on my part or in compiled FTC provided code).
It seems to be a combination of two problems
- Not reseting the encoders
- Not waiting for pending writes before switching to READ_ONLY mode.
The reason I know that this is a software bug is because I wrote a test program in which I can see getCurrentPosition() correctly updating by adding a delay before switching to READ_ONLY mode. I verified that it works
The initalization is the same except I start with RESET_ENCODERS and later switch to RUN_TO_POSITION. I added a global variable called loopcnt which is of type int.
Here is my code for loop.
if(loopcnt==24) {
arm[0].setMode(DcMotorController.RunMode.RUN_TO_POSITION );
}else if(loopcnt==64) {
telemetry.addData("Arm", "Set");
arm[0].setTargetPosition(128);
arm[0].setPower(.25);
}else if(loopcnt==128){
armzeroctl.setMotorControllerDeviceMode(DcMotorController.DeviceMode.READ_ONLY);
}else if(loopcnt>128&&(armzeroctl.getMotorControllerDeviceMode()==DcMotorController.DeviceMode.READ_ONLY)){
telemetry.addData("Arm", String.format("Position: %d Target: %d busy: %b", arm[0].getCurrentPosition(),arm[0].getTargetPosition(),arm[0].isBusy()));
}
if(loopcnt<Integer.MAX_VALUE)
++loopcnt;
If I use a very small delay the motor will not move at all because the writes were never done to the controller telling it to move the motor. The issue is most likely because any pending writes are not completed during SWITCHING_TO_READ_MODE..
If this is a feature and not a bug how do I wait for writes to be completed before switching to READ_ONLY mode? Could someone add a function such as pendingRW() which returns true if there are any pending reads or writes. Using a hardcoded value is not a good idea for a delay.
Are any pending writes supposed to be flushed while in SWITCHING_TO_READ_MODE? If so then this is a software bug in the FTC Application.
Leaving the encoder in WRITE_ONLY mode allows for correct behavior of the rotary encoder. Because of this new information I have changed the title of the issue.
from ftc_app.
All reads and writes to motor controllers are synchronous with this season's SDK. For this reason I believe your problem here is solved. If you are still having trouble please post a question over on the forums.
from ftc_app.
Related Issues (20)
- Hardware remains powered on app restart HOT 6
- Incorrect motor configuration data HOT 6
- How to send data through i2c? trying to communicate with Pixy2 camera HOT 3
- OnBot SDK is different than Android Studio SDK HOT 13
- v5.0 SDK Available HOT 4
- no link to 5.0 HOT 1
- Robot Controller Does not See Rev Expansion Hub
- BUG: OnBot Java overwrites files HOT 19
- Robot Controller does not detect more than 1 device HOT 6
- Pairing and troubleshooting instructions absent HOT 1
- OnBotJava loses Intellisense HOT 1
- Error in code is pointing to non existent source files HOT 4
- Op mode stuck in the init (HELP) how do we get rid of this message HOT 1
- I can't press the Init Button HOT 8
- RC stuck in initialization w/ warning contains RUN_TO_POSITION HOT 3
- Robot Controller Will Not Connect To REV Expansion Hub HOT 8
- Webcam Consistently Crashing on Init HOT 11
- Wiki update: no instant run in AS v. 3.5 or higher HOT 2
- LynxModule retransmitting happens randomly in autonomous run, block TeamCode from execution half second to 2 seconds. HOT 4
- Driver for Grove AS5600 magnetic rotary position sensor HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ftc_app.