Team 3244
Motion Magic
Team 3244
About Us
Corey Applegate
Motion Magic
Natalie Fischer
Team 3244
How are some ways we control our systems?
Motion Magic
Team 3244
Motion Magic
Closed Loop Control
PID
Team 3244
Motion Magic
Closed Loop Control
Motion Magic
Team 3244
Motion Magic
Closed Loop Control
Motion Profile
Team 3244
What we will cover
Motion Magic
Team 3244
Tools we will Use
Motion Magic
Team 3244
Download and configure sample code to fit our system
Page 1 of 3
Motion Magic
Team 3244
Download and configure Page 2 of 3
*Review Sample logic then continue
Motion Magic
Team 3244
Download and configure Page 3 of 3
// https://youtu.be/U4pgviiEwLg Citrus Circuits 1678, Presented by 973's Lead Mentor Adam Heard.
Motion Magic
Team 3244
Warning
The Example supplied by CTRE assumes no hard limits.
We need to adjust the Motion Magic Code if(button) statements to be sure we
Command the system to operate in the constraints of the robot.
Motion Magic
Team 3244
Warning
Add to the program a way to get the native Units min/max and other setpoints the subsystem can operate safely in.
SmartDashboard.putNumber(“Elevator Position”, _talon.getSelectedSensorPosition(0));
Or
Use the Plot Tool
Motion Magic
Team 3244
Warning
Change if(button)..
if (_joy.getRawButton(1)) {
/* Motion Magic */
double targetPos = minTravlePos;
_talon.set(ControlMode.MotionMagic, targetPos);
... //Keep the String builder
}else if (_joy.getRawButton(2)) { //Delete Button 2 condition and use for our second setpoint
/* Motion Magic */
double targetPos = maxTravlePos;
_talon.set(ControlMode.MotionMagic, targetPos);
... //Keep the String builder
}else{......... //command talon in percentOutput
Motion Magic
Team 3244
Test Motor Direction and Sensor Phase
Motion Magic
*We can now record our Min/Max Travels
Team 3244
Feed Forward
This term is used to tell the system how to scale velocity native units
per 100ms to 100% Output
https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html#how-to-calculate-kf
Motion Magic
Team 3244
Set Cruise Velocity And Acceleration
*Start with modest values here and work your way up to full speed
** These value are integers so round to a whole number
Motion Magic
Team 3244
Warning
Set the
minTravlePos
maxTravlePos
Motion Magic
Team 3244
Set kp (proportional value)
https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html#dialing-kp
Motion Magic
Team 3244
Set kd (derivative value)
https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html#dialing-kd
Motion Magic
Team 3244
Set ki (integral value)
https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html#dialing-ki
Motion Magic
Team 3244
Arbitrary FeedForward (gravity Compensation)
// get the radians of the arm Horizontal = 0 Vertical = 90
double theta = Math.toRadians(CurrentArmAngle());
// get a range of 0 to 1 to multiply by feedforward.
// when in horizontal position, value should be 1
// when in vertical up or down position, value should be 0
double gravityCompensation = Math.cos(theta);
// horizontalHoldOutput is the minimum power required to hold the arm up when horizontal
// this is a range of 0-1
double arb_feedForward = gravityCompensation * horizontalHoldOutput;
_talon.set(ControlMode.MotionMagic, targetPos, DemandType.ArbitraryFeedForward, arb_feedForward);
Motion Magic
Team 3244
Other Considerations
Motion Magic
Team 3244
Questions