Anyone have any working code for TankDrive on bot? Our first year using tank drive and we’re trying to find an example. Last year we did mecanum and that worked well. We’re having issues building the tank drive code to the robot though this year and am looking to isolate whats wrong. Whether it is an error in building the code that isn’t being shown or if the code itself is wrong.
Usually, with the code on the robot right now, whenever it is run, only the right side of the robot runs and the joystick has no effect on it.
This is the code we built that is currently not working.
/----------------------------------------------------------------------------/
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. /
/ Open Source Software - may be modified and shared by FRC teams. The code /
/ must be accompanied by the FIRST BSD license file in the root directory of /
/ the project. /
/----------------------------------------------------------------------------*/
package frc.robot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.PWMVictorSPX;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.drive.RobotDriveBase;
/**
- This is a demo program showing the use of the RobotDrive class, specifically
- it contains the code necessary to operate a robot with tank drive.
*/
public class Robot extends TimedRobot {
private DifferentialDrive m_myRobot;
private static final int kJoystickChannel = 0;
private Joystick m_stick;
int rightMotorPort = 0;
int leftMotorPort = 1;
Talon left = new Talon(leftMotorPort);
Talon right = new Talon(rightMotorPort);;
@Override
public void robotInit() {
m_stick = new Joystick(kJoystickChannel);
}
@Override
public void teleopPeriodic() {
m_myRobot.tankDrive(m_stick.getY(), m_stick.getX());
}
}