CTRE has a ton of amazing examples that you can look at which explain lots of concepts. The focus of this section is mainly PID tuning. All the examples are in the java folder. The best ones to look at are:
MotionMagic
MotionMagicExpo
VelocityClosedLoop
Open WPILib VSCode and select Clone Git Repository
Click Clone from GitHub
Paste "CrossTheRoadElec/Phoenix6-Examples"
In your VSCode window:
Click File
Open Folder
Navigate to the PID Example that you would like to simulate
Click the WPILib icon in the top right
Simulate Robot Code
Once the code has completed building, select Sim GUI, then okay
This should open a window called Robot Simulation
In the top left under Robot State, select Teleoperated
Install Phoenix Tuner X from the Microsoft Store or App Store (Linux users can install by reading their documentation)
Since the simulation is running, you should see some devices
Select One
Select Plot
Select Signals
In the search bar, search velocity/position, depending on the type of PID tuning
Check velocity/position and reference (under PIDVelocity/PIDMotion)
Click the graph symbol under the wrench
Click the plus sign to add a new group
Move the signals to the new group
Click Control
Select Control Mode (this is the type of PID tuning that you want to practice)
Set the parameters
Click the wrench icon
Select Slot 0
Before continuing, make sure Slots 1 & 2 are empty
Slot 0 is where you input your tuning constants
Every time you change a tuning constant, you must click the motor with an arrow icon to update them
Enable the motor and hit play to view the graph