How to Tune PIDF for PedroPathing (Learn Java for FTC Robotics)
PIDF Control for FTC Robots
Introduction to PIDF Control
- Coach Pratt introduces the topic of tuning PIDF control for FTC robots, specifically for Pedro pathing. The goal is to enable the robot to self-correct its path effectively.
- He shares his extensive experience in teaching robotics and design, setting the stage for a detailed tutorial on setting up the constants file necessary for tuning.
Prerequisites for Tuning
- Before diving into setup, viewers are advised to have the Pedro pathing repository installed and a Wi-Fi plugin ready for wireless connection to the robot. Additionally, Android Studio must be installed on their device. A link to a full video tutorial is provided for initial setup guidance.
Test Setup Overview
- Coach Pratt describes his test setup using a holonomic drive with four mechanum wheels from Nexus Robotics, noting their hardness which contributes to wheel slip—an important factor in testing Pedro pathing tools. He uses a Go Build A Pinpoint computer V2 and specific odometry pods from East Loop Components.
- The motors used are 435 RPM connected directly to the wheels, with an emphasis on achieving balanced weight distribution despite potential challenges due to wheel slip during operation. This will be critical in evaluating PIDF tuning effectiveness later on.
Initial Robot Behavior Without Tuning
- Demonstrating manual drive without any tuning reveals significant drifting behavior of the robot when moving forward or backward, highlighting challenges that need addressing through effective PIDF control adjustments. The lateral movement while strafing also shows instability that needs correction through proper tuning methods.
Setting Up Constants in Code
- The first step involves accessing the team code folder and modifying Java files within Pedro pathing by setting up mass parameters correctly (in kilograms) based on actual measurements taken using a weight scale method described by Coach Pratt. This ensures accurate calculations during tuning processes.
- Next steps include configuring drivetrain settings specific to mechanum wheels and ensuring motor names match those defined in configuration files; this includes checking motor directionality (e.g., left motors often reversed). Proper syntax must be maintained throughout these changes in code files as well as adding necessary localization setups depending on chosen localizer types (like pinpoint localizer).
Setting Up Robot Localization
Configuring Constants and Pod Locations
- The setup begins with defining constants, including the localizer being used. The speaker uses a pinpoint constant for their mechanum drive.
- The pod locations are crucial as they represent offsets from the robot's center to the dead wheel centers on both X and Y pods. This can be measured using CAD or a tape measure.
- Offsets must be converted into inches if initially measured in millimeters; for example, 182 mm is converted by dividing by 2.54.
- It's important to select the correct distance unit (millimeters in this case), ensuring consistency with hardware map names set up in Go builder.
Encoder Setup and Testing
- For encoder resolution, if using custom encoders, specific calculations are necessary. The East Loop components encoder has 4,000 ticks divided by the wheel circumference (2 * π * radius).
- There’s uncertainty about whether custom resolution should be in inches or millimeters; previous attempts have been made in millimeters without issues.
Initializing Telemetry and Testing Directions
- To test encoder directions, use the driver station to initialize telemetry and select localization tests via controller inputs.
- As the robot moves forward, X values should increase while moving left increases Y values; any discrepancies indicate that one of the encoders may need reversing.
Adding Localizer and Verifying Functionality
- After confirming encoder directions, add the localizer within your follower code using
dot pinpoint localizeralong with constants defined earlier.
- Connect to the robot's Wi-Fi network again to build code and run localization tests to ensure proper functionality of X and Y value adjustments during movement.
Testing Automatic Tuners
Forward Velocity Tuner Setup
- With initial setups complete, it's time to test automatic tuners for tuning parameters like forward velocity.
- The forward velocity tuner assesses maximum speed when moving at full throttle; adequate space is required since it defaults to 48 units forward.
Importance of Battery Charge
- A fully charged battery is essential for accurate testing results; low battery levels may lead to incorrect data during tests.
Robot Tuning and Testing Procedures
Setting Up the Robot
- The speaker prepares to run tests with a robot, ensuring it is aligned straight on the field for accurate movement.
- A specific X velocity will be monitored in the telemetry section; pressing 'B' on the keypad can stop the robot if necessary.
Initial Forward Velocity Test
- The first test runs but results in the robot veering off course due to low grip from its wheels; adjustments are needed.
- After tuning, a more accurate forward velocity test is conducted, and values are copied into the mechanum constants section of code.
Adjusting X Velocity
- Pressing 'A' allows temporary setting of X velocity based on test results, which will persist until the robot is turned off.
- The next phase involves testing lateral velocity, crucial for sideways movement accuracy.
Lateral Velocity Testing
- The speaker sets up for lateral velocity testing while noting that wheel grip issues may affect performance.
- Initialization occurs again in driver station settings to prepare for lateral tests; pressing 'B' can halt operations if needed.
Observations During Tests
- Multiple attempts reveal common challenges in robotics tuning, such as slippage affecting lateral speed measurements.
- Successful tests yield lower stray velocities due to significant slippage from Nexus wheels; adjustments are made accordingly.
Forward Zero Power Acceleration Test
- This test measures how long it takes for the robot to drift after power cut-off, essential for brake tuning and path accuracy.
- Values from this test are recorded but added to follower constants instead of mechanum constants to ensure proper functionality.
Final Lateral Zero Power Acceleration Test
- Similar procedures apply as with forward acceleration tests but focus on lateral movement; setup requires careful attention to initial direction.
PID Controller Tuning in Robotics
Introduction to PID Controllers
- The discussion begins with the setup of lateral zero power acceleration and the introduction of tuning P controllers, emphasizing that this video will not fully explain PIDF controllers.
Understanding Proportional Control
- A brief overview of proportional control is provided, explaining how a PID controller allows for motor speed adjustments as it approaches a target value.
- An analogy is made using the act of drinking coffee, illustrating how one instinctively slows down when bringing a cup closer to avoid spilling.
Components of PID Controllers
- The components of a PID controller are outlined:
- Proportional (P)
- Integral (I)
- Derivative (D)
- Feed Forward (F), which helps predict future motion.
Pathing Systems in Robotics
- Discussion on Pedro pathing systems indicates that most teams can effectively use a single P system without needing perfection, as "good enough" often suffices in robotics.
The Art and Science of Tuning PIDs
- Emphasizes that tuning PIDs is both an art and science; practical tuning will be demonstrated throughout the session.
Translational PF Tuning Process
- The first focus is on translational PF tuning to ensure straight-line movement without lateral deviation.
- Manual adjustment of PF values begins, highlighting the importance of setting initial values correctly for effective robot control.
Initializing and Adjusting Values
- All coefficients are initially set to zero before testing robot movement capabilities. If values aren't confirmed after entry, they won't be saved.
Observations During Testing
- Without PF control, pushing the robot shows no response; thus, effective tuning must allow for corrective movements against external forces.
Tuning Feed Forward Controller
- Focus shifts to adjusting the feed forward constant to balance motor power against frictional forces.
- High or low values are tested iteratively to find an optimal setting where motors respond without overcoming friction excessively.
Finding Optimal Values for F Controller
- A systematic approach is taken by testing various high and low values until finding an appropriate level where slight motor noise indicates readiness without excessive movement.
Final Checks on F Controller Settings
- After determining suitable settings for the F controller, checks are performed by physically interacting with the robot to ensure stability at selected values.
This structured summary captures key insights from the transcript while providing timestamps for easy reference back to specific parts of the video.
Robot Tuning and Control Adjustments
Proportional Control Testing
- The process of conducting push tests on the robot begins, focusing on its ability to self-correct back to a center point.
- Initial observations indicate some jitter in the robot's response, suggesting that the proportional gain (F) might be set too high.
- A series of adjustments are made to find an optimal proportional value; starting from 0.1, then lowering it to 0.05, which proves insufficient for correction.
- Further testing with values like 0.75 shows overcorrection, leading to a search for a balanced setting around 0.6 or lower.
- The tuning process is described as both a science and an art, emphasizing the need for careful adjustments based on observed behavior.
Derivative Control Adjustments
- After settling on a satisfactory proportional value, attention shifts to derivative control aimed at slowing down corrections towards the center goal point.
- High derivative values (e.g., 0.9) lead to overly aggressive corrections; thus, adjustments are made downwards until reaching more effective settings like 0.001.
- With proper tuning of derivative control, smoother returns to center are achieved compared to previous attempts with only proportional control.
Final Tuning Considerations
- Emphasis is placed on spending adequate time fine-tuning parameters rather than rushing through; achieving good enough values is crucial for performance.
- Specific coefficients are noted: P value at 0.06, integral at 0, and derivative at 0.001 after tuning efforts have been completed.
Heading PF Tuning Process
- Transitioning focus towards lateral movement and heading adjustments begins with setting initial proportional values low before gradually increasing them during testing.
- Initial tests show that higher feed forward values may be necessary due to lateral forces; adjustments lead towards finding suitable coefficients around 0.25.
- Proportional control for heading adjustment starts high (e.g., 0.1), but further increases reveal better responsiveness when set closer to around 0.4.
Conclusion of Tuning Session
- Derivative controls are adjusted again for heading correction; lower settings yield slower but more controlled responses back toward desired headings.
- The session concludes with notes about varying PF values across different setups and emphasizes stopping programs when running tests in panels dashboard environments.
Tuning PF Coefficients for Robot Control
Introduction to PF Coefficients
- The speaker discusses the setup of PF coefficients in Android Studio and recording software, emphasizing the importance of tuning these values for optimal robot performance.
- Key values mentioned include a power coefficient of 0.71, an integral value of 0, a derivative value of 0.002, and a feed-forward value of 0.025.
Tuning Drive PF
- The drive PF tuning is crucial for maintaining consistent forward and backward motion strength during braking and path following.
- Braking strength significantly affects how abruptly or smoothly the robot stops; higher values lead to shorter stop periods while lower values allow for smoother stops.
Adjusting Braking Strength
- Default braking strength is set at one, with options to adjust where along the path braking begins (e.g., at the end or earlier).
- The speaker prepares to tune braking parameters using a manual test with the drive tuner that alternates between forward and backward movements.
Testing Braking Parameters
- During testing, adjustments are made to braking strength; too low results in premature stopping while too high causes overshooting.
- A balance is sought around a braking strength of 1.5 to avoid both early stops and overshooting paths.
Finalizing Drive PF Settings
- The discussion shifts towards tuning the drive PF itself; higher coefficients increase speed along paths while lower ones slow down movement.
- Initial tests indicate that adjustments need to be made on power coefficients due to slippage issues with wheels; further testing continues until optimal settings are found.
Tuning Robot Movement and Line Following
Initial Adjustments to Movement
- The robot's movement is improving, suggesting a need for slight adjustments with a 0.001 undifferential to enhance performance.
- There appears to be an issue with one wheel having different friction, affecting the robot's initial kick-off.
Testing Line Following Capability
- The robot shows signs of drifting over time, indicating a potential need to increase the translational heading tuner for better stability.
- After initial movement, the robot stabilizes at speed, prompting updates in code related to follower constants and drive coefficients.
Drive Coefficients Configuration
- New drive P coefficients are established: power at 0.6, integral at 0.0, derivative at 0.001, t value at 0.6 (common filter), and feed forward at 0.025.
Central Tuner Setup
- The central tuner is configured for curve following; adjustments are made based on whether the robot is inside or outside of curves.
- A malfunction occurs where the quick start does not run as expected; feedback from viewers is requested regarding this issue.
Challenges with Central Scaling
- Observations indicate that centrial scaling adjustments do not significantly impact performance due to slippery mechanum wheels.
- Default centrial scaling of 0.05 is set despite limited effectiveness observed during testing.
Final Testing and Observations
- After completing configurations, tests will verify if the robot can maintain its line path after being nudged laterally.
- Despite challenges posed by slippery wheels, the robot demonstrates commendable ability to hold its path under current conditions.