Choppy driving using iterative

so recently i switched over from time based to iterative in order to get my commands to work and now my driving on my robot is a lot more choppy.

this is my code:

Thank you,

Why are you multiplying your joyticks by 0.2? This probably isn’t enough power to drive.

I multiplied it by .2 because of my limited driving space, but occasionally I’ll see my Victor SPX’S flash oarnge even when the joysticks are pushed down all the way

I recommend scaling these using a quadratic function. We do this:

Math.signum(value) * Math.abs(Math.pow(value, 2))

You can also change the 2 to something else. The highest it is, the slower the speed increases. Obviously a value of 1 is always 1.

Thank you I’ll have to try it out but my issue is that the robot stops and goes not that it speeds up inconsistentaly

Just a note: WPILib already squares the drive inputs by default; doing this is redundant if you are using the RobotDrive function. It appears the OP is not using this, but just a note for anyone else.

I received the same issue with the differential drive but I got the error saying drive train wasn’t updated enough so I thought switching to control the Victor SPX’S directly would fix it but I had the same issue but with no errors

Honestly the error where the differential drive isn’t updated enough is almost meaningless. There are plenty of robots and times were the error would appear to no issues when driving the robot.

I know but the error isn’t the issue the problem is that the robot physically shows the problem, if I turn the robot using tank drive it stops and goes even when I hold the joysticks in the same position

Does the stop and go behavior persist when the robot is taken off of the ground / put on blocks?

Yeah at first I thought maybe it was a gearbox issue but then I can see the motor controllers flashing orange(meaning that there is no power to the motors) and green(meaning that it’s giving power to the motors) whenever it gets choppy.

I think you actually want to be doing

public void driveWithSticks(double left, double right){
    RobotMap.driveTrain.tankDrive(left, right);

in your subsystem instead of setting the talons. Not sure if having the DifferentialDrive set up is actually messing you up or not.

Also, I highly recommend switching to arcade drive instead of tank drive.

Also, here are some presentations on Java that our team has put together that may help you.

I still had issues with robot map drivetrain.tankdrive, this problem occured when I switched to iterative

notmattlythgoe is definitely onto something – both RobotMap.driveTrain (type type edu.wpi…DifferentialDrive) and Robot.driveTrain (frc.robot.subsystems.DriveTrain) have access to the objects that communicate with your motor controllers. Likely, they are both calling the set() methods on your m_driveTrain… VictorSPX objects and thus “fighting”. I suspect it is related to motor safety code called from DifferentialDrive.

I suggest starting by removing public…DifferentialDrive driveTrain; (line 43) and driveTrain = new DifferentialDrive…(line 87) in OI. If you want to use DifferentialDrive, I would recommend putting all of it inside your frc.robot.subsystems.DriveTrain class instead.

I’ll try out timedrobot thank you, maybe that would fix my issue with the choppy driving, it felt like my problem was with the code not updating enough so that’s make sense why timed robot could fix it

TimedRobot and IterativeRobot are very very similar. IterativeRobot is deprecated this year. Basically IterativeRobot updates whenever a packet is received and TimedRobot defaults to updating every 20 ms.

Unless you have overruns in your console, either one should update at a high enough rate.

Did you see the part about DifferentialDrive above? I believe that is what will fix your driving problem.

I’ll try that out too but originally I didn’t have a issue with my placement of Differential drive the problem occured when I switched from timed to.itterative. originally I thought the timedrobot was causing my commands not to run but really it was because I forgot to add the scheduler

I would suggest maybe creating a new CommandBased project from the template and starting over. It really sounds like you’re trying to built it up from scratch instead.

Is there anything wrong with creating a timedbased rather than a command based