|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Can I use gyro to drive straight in teleop period?
I wanted to know if you can drive straight using the gyro sensor because we don't have encoder to correct the speed of each motor. We're using tankdrive and right now the problem we're facing is that it's not going in the direction we wanted. For instance, if we move left and right stick to up direction the robot doesn't go straight, and for some reason, I think the speed of left side of the robot is going faster then the right side.
Also, I wanted to know if we can use it in autonomous mode. Like I need help with turning the robot with gyro (corresponding the wheel with the gyro angle.) This is our first year so we're rookie, and their no programming mentor to mentor us. |
|
#2
|
||||
|
||||
|
Re: Can I use gyro to drive straight in teleop period?
It would be very helpful with encoders but it is possible to do it without. Consider the differential of the two tank sticks is directly proportional to the turning rate of the robot. The bigger the difference, the faster the robot should turn. And the turning rate of the robot is the raw output of the gyro (rotational velocity). So in theory, you can do this:
Code:
double drivePower = (leftStick + rightStick)/2.0; double stickDifferential = leftStick - rightStick; double motorDifferential = Kp*(stickDifferential - gyro.getScaledRotationRate()); leftMotor.set(drivePower + motorDifferential); rightMotor.set(drivePower - motorDifferential); Last edited by mikets : Today at 02:54. |
|
#3
|
||||
|
||||
|
Re: Can I use gyro to drive straight in teleop period?
Quote:
EDIT: I didn't internalize that you were using tank drive. You could still try to use this, but it might be a little harder to adapt. I suppose if you run this method only when both joystick values are within some value of each other, it might work. Last edited by soundfx : Today at 02:09. Reason: Didn't internalize whole post, needed to update. |
|
#4
|
|||
|
|||
|
Re: Can I use gyro to drive straight in teleop period?
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|