]> git.taranathan.com Git - motionmagic-presentation.git/commitdiff
presentation main
authormoo <moogoesmeow123@gmail.com>
Tue, 20 Oct 2026 16:48:39 +0000 (09:48 -0700)
committermoo <moogoesmeow123@gmail.com>
Tue, 20 Oct 2026 16:48:39 +0000 (09:48 -0700)
.gitignore [new file with mode: 0644]
examples/new.java [new file with mode: 0644]
examples/old.java [new file with mode: 0644]
ironclaw.png [new file with mode: 0644]
justfile [new file with mode: 0644]
main.typ [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..f0de8a3
--- /dev/null
@@ -0,0 +1 @@
+main.pdf
diff --git a/examples/new.java b/examples/new.java
new file mode 100644 (file)
index 0000000..270215a
--- /dev/null
@@ -0,0 +1,45 @@
+
+
+
+public class Roller extends SubsystemBase {
+  private TalonFX motor;
+  private MotionMagicVelocityVoltage request = new MotionMagicVelocityVoltage(0);
+
+  public Roller() {
+    motor = new TalonFX(0, Constants.CANIVORE_CAN);
+
+    TalonFXConfiguration config = new TalonFXConfiguration();
+
+    // config Slot 0 PID params
+    var slot0Configs = config.Slot0;
+    slot0Configs.kP = 5.0;
+    slot0Configs.kI = 0.0;
+    slot0Configs.kD = 0.0;
+    slot0Configs.kV = 0.0;
+    slot0Configs.kA = 0.0;
+
+    // set the brake mode
+    config.MotorOutput.withNeutralMode(NeutralModeValue.Brake);
+
+
+    // configure MotionMagic
+    MotionMagicConfigs motionMagicConfigs = config.MotionMagic;
+
+    motionMagicConfigs.MotionMagicCruiseVelocity = 420;
+    motionMagicConfigs.MotionMagicAcceleration = 69;
+
+    // apply the configuration
+    motor.getConfigurator().apply(config);
+    
+    // invert motors
+    motor.getConfigurator().apply(
+        new MotorOutputConfigs().withInverted(InvertedValue.Clockwise_Positive)
+        .withNeutralMode(NeutralModeValue.Coast)
+    );
+   
+  }
+
+  public void spin(double speedRps) {
+    motor.setControl(request.withVelocity(speedRps));
+  }
+}
diff --git a/examples/old.java b/examples/old.java
new file mode 100644 (file)
index 0000000..d010e4b
--- /dev/null
@@ -0,0 +1,13 @@
+
+
+public class Roller extends SubsystemBase {
+  private TalonFX motor;
+
+  public Roller() {
+    motor = new TalonFX(0, Constants.CANIVORE_CAN);
+  }
+
+  public void spin(double speed) {
+    motor.set(speed);
+  }
+}
diff --git a/ironclaw.png b/ironclaw.png
new file mode 100644 (file)
index 0000000..8f1833e
Binary files /dev/null and b/ironclaw.png differ
diff --git a/justfile b/justfile
new file mode 100644 (file)
index 0000000..09b495e
--- /dev/null
+++ b/justfile
@@ -0,0 +1,16 @@
+default: build
+
+build:
+    typst compile main.typ
+    zathura main.pdf &
+
+watch: noview-build
+    zathura main.pdf &
+    typst watch main.typ
+
+clean:
+    rm -rf *.pdf
+
+[private]
+noview-build:
+    typst compile main.typ
diff --git a/main.typ b/main.typ
new file mode 100644 (file)
index 0000000..dcb99fb
--- /dev/null
+++ b/main.typ
@@ -0,0 +1,79 @@
+#import "@local/robotics:0.1.0": ting
+#show: ting
+
+#set document(title: "Motion Magic Intro")
+
+#import "@local/touying:0.7.3": *
+#import themes.ironclaw: *
+
+#show link: set text(blue)
+#show link: underline
+
+#import "@local/codly:1.3.1": *
+#import "@preview/codly-languages:0.1.10": *
+#show: codly-init.with()
+
+#show raw: set text(size: 20pt, font: "Miracode")
+
+#import "@preview/fletcher:0.5.8" as fletcher: diagram, edge, node
+#import fletcher.shapes: circle, diamond, ellipse, parallelogram, pill, rect
+
+#let logo = image("./ironclaw.png")
+ 
+
+#title-slide()[
+  #text(36pt)[#heading(level: 3)[#title()]]
+  #linebreak()
+  #datetime.today().display("[month repr:long] [day] [year]")
+  #linebreak()
+  #box(height: 20%)[#logo]
+]
+
+== What is Motion Magic?
+- Basically, a more advanced API to control motors
+- Abstracts away direct PID and Feedforward calculations
+- Is a bit verbose imo :(
+
+== Resources
+- #link("https://v6.docs.ctr-electronics.com/en/stable/docs/api-reference/device-specific/talonfx/talonfx-control-intro.html")[CTRE Guide]
+- #link("https://api.ctr-electronics.com/phoenix6/stable/java/index.html")[API Docs] (#link("https://api.ctr-electronics.com/phoenix6/latest/java/index.html")[wpilib alpha])
+- #link("https://frcteam3255.github.io/Wiki/Lessons%20(Software)/MotionMagic/")[SuperNURDS]
+
+
+== Old Way
+
+== New Way
+
+== When to NOT use MotionMagic
+- The alternative is `motor.setThrottle`
+- Sets motor output as percentage of full power
+- No feedback or position control
+- Basically just when you want to spin a roller really fast with no regard for velocity
+
+
+== Tips
+- There are a lot of Control Request types
+  - VSCode autocomplete is the goat for this
+- Make one request and reuse it
+- Be careful with your tuning
+
+== PID Review
+#link("https://docs.google.com/presentation/d/1ldI8mJS26nq8nHIjNz_SLeJR6j8HoKEYOPCpbXV1PzY/edit?usp=sharing")[Activities Slide Deck]
+
+
+= Feedforward
+
+== What is Feedforward
+- A component of *Closed Loop Control*
+  - works _with_ PID usually
+- Compensates for system characteristics
+  - eg. Friction, Inertia, Gravity
+- #link("https://docs.google.com/presentation/d/1g4LiEVMSLd43Ues3Nt_aV0utcySI1vf5iADmorDXjzA/edit?slide=id.g2ed2767c617_0_60#slide=id.g2ed2767c617_0_60")[Activities Slides]
+
+
+== How to use Feedforward with Motion Magic
+- Basically just modify the constants during motor configuration
+- To tune, do this! #link("https://v6.docs.ctr-electronics.com/en/stable/docs/api-reference/device-specific/talonfx/manual-pid-tuning.html")[fun activity]
+
+== Practice Task
+If you still have the basic little intake subsystem that I assigned you before the rewrite, use that, but otherwise just do this on your rewrite subsystem. Try to modify the control to use Motion Magic. Ask questions :)