Hello all,
I am from team 4687, and I am having some trouble coding the encoders for a mecanum wheel robot. I currently have some code developed to read the encoder values, but I am unsure of how to change the speeds of the wheels based off of these values. Here is what I would like to do:
I would like to use 1 wheel and call it the master wheel. This wheel will provide me with an encoder value. This encoder value will then be used to “enslave” the other wheels, which will then match the master wheel’s rpm. The only differences in the wheels will happen when I change the direction of the wheels to move in the directions I need them to move in.
If you guys have any other way to implement some encoder code into a mecanum wheel drive to get all the wheels to move the same speed all the time, it would be great if you could advise me on that too. I will leave you all with my current code, with encoders implemented but doing nothing.
Thank you all in advance for your help in this project.
//I do my brackets differently than most
//import statements
public class RobotTemplate extends SimpleRobot
{
RobotDrive drive =- new RobotDrive(1,2,3,4);
Joystick joystick = new Joystick(1);
Encoder wheelOne = new Encoder(8,7);
Encoder wheelTwo = new Encoder(4,3);
Encoder wheelThree = new Encoder(6,5);
Encoder wheelFour = new Encoder (2,1);
public void OperatorControl()
{
while(true && isOperatorControl() && isEnabled())
{
drive.mecanumDrive_Cartesian(joystick.getX(), joystick.getY(), -1*joystick.getTwist(), 0);
Timer.delay(0.001);
int one = wheelOne.get();
int two = wheelTwo.get();
int three = wheelThree.get();
int four = wheelFour.get();
}
}
}