Open gavinjalberghini opened 1 year ago
1/11/23 Started working on Pigeon IMU Gyro for balancing looking at Wyvern code where it was originally used in End Game
Can get data from the pigeon by first creating the necessary objects with
import com.ctre.phoenix.sensors.PigeonIMU;
private WPI_TalonSRX pidgeonTalon = new WPI_TalonSRX(Constants.PIGEON_TALON_PORT_ID);
private PigeonIMU _pigeon = new PigeonIMU(pidgeonTalon);
then using
_pigeon.getYawPitchRoll(yawPitchRoll);
to get the value for the future PID input
1/12/23 Started looking into PID loops, began looking on a FRC PID Control documentation page
public class Drive(){
int P, I, D = 1;
int integral, previous_error, setpoint = 0;
Gyro gyro;
DifferentialDrive robotDrive;
public Drive(Gyro gyro){
this.gyro = gyro;
}
public void setSetpoint(int setpoint)
{
this.setpoint = setpoint;
}
public void PID(){
error = setpoint - gyro.getAngle(); // Error = Target - Actual
this.integral += (error*.02); // Integral is increased by the error*time (which is .02 seconds using normal IterativeRobot)
derivative = (error - this.previous_error) / .02;
this.rcw = P*error + I*this.integral + D*derivative;
}
public void execute()
{
PID();
robotDrive.arcadeDrive(0, rcw);
}
}
reference code from the above page
They have a library to handle all the calculations, probably going to go with that
Problem: The robot is able to climb onto the charging pad and balance the pad (not necessarily on the pad alone).
Possible Sensors:
Possible Solutions:
Sub-Tasks: