Ramping acceleration issues

I’ve been scratching my head this whole week about this issue. I have 2 methods to drive the robot, one is direct tank drive and one is tank drive with a pid loop. Here’s the code:


        public void drive(double left, double right) {
		
		// Probably too low
		double kP = .02;
		
		m1.set(pControl(left, kP, m1.getSpeed()));
		m2.set(pControl(right, kP, m2.getSpeed()));
		m3.set(pControl(left, kP, m3.getSpeed()));
		m4.set(pControl(right, kP, m4.getSpeed()));
	}
	
	public double pControl(double setPoint, double kP, double cur) {
		double error = setPoint - cur;
		return cur + (error * kP);
	}
	
	public void setSpeed(double left, double right) {
		m1.set(left);
		m2.set(right);
		m3.set(left);
		m4.set(right);
	}
	

	

The setSpeed method works perfectly, but the drive method only turns the right side wheels. There’s no issue with the speed controllers or joystick because setSpeed works fine and I even put the getSpeed values to the smart dashboard which seem correct. In the pControl method, I printed the values to the smart dashboard and error, setpoint, and kP all appear correct but the return value is always 0. Anyone know why this is happening?

Which motor controllers are you using?

We’re using Victor SPs

Do I understand that you’re printing the inputs and output of calls to pControl and are finding that when you have the joysticks full forward you get

pControl(1, 0.2, 0) == 0

for the right side wheels, when you would expect 0.2?

Also, note that this method will cause the applied speed to exponentially decay towards the set point, not reach it in 50 (1/kP) cycles. Is this what you wanted?

Yes, that’s correct.