Skip to content

Instantly share code, notes, and snippets.

View pleasehelpme798's full-sized avatar

pleasehelpme798

View GitHub Profile
package frc.robot.commands;
import java.util.function.Supplier;
import edu.wpi.first.wpilibj.SlewRateLimiter;
import edu.wpi.first.wpilibj.kinematics.ChassisSpeeds;
import edu.wpi.first.wpilibj.kinematics.SwerveModuleState;
import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.Constants.DriveConstants;
import frc.robot.Constants.OIConstants;
import frc.robot.Subsystems.SwerveSubsystem;
@pleasehelpme798
pleasehelpme798 / Mr. Purring with wheel independent PID control
Last active July 1, 2023 00:32
Mr. Purring with wheel independent PID control
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.TimedRobot;
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package frc.robot;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj.TimedRobot;
/*
Arduino and MPU6050 Accelerometer and Gyroscope Sensor Tutorial
by Dejan, https://howtomechatronics.com
*/
#include <Wire.h>
const int MPU = 0x68; // MPU6050 I2C address
float AccX, AccY, AccZ;
float GyroX, GyroY, GyroZ;
float accAngleX, accAngleY, gyroAngleX, gyroAngleY, gyroAngleZ;
float roll, pitch, yaw;
int pin = 9;
int value;
float xn1= 0;
float yn1 = 0;
int k = 0;
void setup (){
//PID constants
double kp = 1;
double ki = 0;
double kd = 0;
unsigned long currentTime, previousTime;
double elapsedTime;
double error;
double lastError;
double input, output;
//PID constants
double kp = 8;
double ki = 1;
double kd = 6;
unsigned long currentTime, previousTime;
double elapsedTime;
double error;
double lastError;
double input, output;