How Can We Help?
Steps to get Motion Profiling Working
- Determine what UOM you will use (ft, in, m, mm), measure everything in that unit
- Ensure robot moves forward when given positive voltage
- Ensure encoders increase when robot moves forward
- Ensure gyro angle increases when turning right (CW) and negate output
- (Most MP code assumes CCW rotation is positive)
- Determine encoder PPR (pulses per revolution) and ensure it is reading correctly
- Roll robot forward 1 wheel rotation to be sure it is close enough
- Determine gear-ratio between the encoder and the shaft (may be 1/GR)
- Determine the wheel-base – wheel center to wheel center
- Determine effective wheel-size which will ensure correct distance/velocity calculations
- This value may change from robot to robot and even over a season
- Hand-roll robot forward a precise, well-measured distance and count encoder ticks
- Distance travelled = distance-per-pulse * pulses
- DPP = (EWS * PI) / (PPR * GR)
- Solving for EWS – Distance / pulses = EWS * PI / (PPR * GR)
- EWS = (PPR * GR * Distance) / (pulses * PI)
- If miscalculated, try inverting the gear-ratio
- Hand-roll robot different precise distances (5, 10, 15, 20 ft)
- Compute EWS at each distance
- Compute an average EWS
- Put the AEWS into the robot characterizer and characterize
- kV will be the FF value for the SmartController (SparkMax, TalonSRX)
- ArbitraryFF = kA * Accel + kS
- Set with the new velocity target if using kA
- If not using kA, just set ArbitraryFF = kS
- PID values – at least P & D set on SmartController PID
- Extrapolate theoretical maxVelocity from maxVel = (12 – kS) / kV
- If needed, get theoretical maxAccel from maxAcc = (12 – kS) / kA
- Use max velocity and acceleration when creating trajectories in PathWeaver
- Probably can cut it back to 80% or even ½
- Check out PathWeaver guidance on this
- Write 3 functions in the DriveTrain class
- A function which calculates the current Pose2d using the Odometry classes
- A function that takes 2 wheel velocities and sets the velocity control of the SC
- Use the guidance from previous point, especially WRT kA & ArbitraryFF
- A function which returns the current Pose2d
- Use these functions to create a RamseteCommand that takes the last 2 functions
- Make Auto use this with the requested Trajectory, or put it on a button
- Test simple paths, then harder paths
- Multiple runs (3-5), look for consistency before worrying about correct targeting
- Determine how much deviation there is between end locations
- Mark end location of a particular corner of the robot
- What is the diameter of a circle around those points?
- Adjust P values up in small increments, see if consistency or targeting improves
- Run longer and more difficult paths
- Write a Callable that can generate Trajectories using a Future
- Use to generate selected trajectory at startup rather than waiting for all
- Write a FunctionalCommand that executes the runnable on init and finishes when the future is done, storing the trajectory in a static location
- Use .andThen() to run the RamseteCommand
- And – use it to generate vision-target trajectories!