![]() |
[FTC]: Programming a TETRIX Encoder - Wheel Problem
Hey Chief Delphi,
Today we were testing the beginning portion of our autonomous program, where the robot drives off the ramp. The robot was not going down straight, so we added PIDControl to the pragmas. Although it went down straight this time, it kept going for an unlimited amount of time. In addition, it did not go at the speed that we wanted it to go - it just went at full power. Code:
#pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, HTMotor)Also, we were wondering how to program the robot with encoders (on the back wheels). Using the pragmas from the program above, can you create a sample program which tells the robot to move forward for 2 feet (wheel diameter 3.96 in)? All help is appreciated. Thanks, Charging Champions |
Re: [FTC]: Programming a TETRIX Encoder - Wheel Problem
Hi Charging Champions!
I would recommend a function like the one below to use encoders. void forward( int rotations, int power ){ motor[motor1] = 0; motor[motor2] = 0; //Resets the motor encoder readings. while( nMotorEncoder[motor1] < rotations ){ motor[motor1] = power; motor[motor2] = power; }//goes forward until one of the two sides has rotated enough } Be sure to remember that it takes a lot of rotations to travel any distance at all! Good Luck! |
| All times are GMT -5. The time now is 17:21. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi