diff --git a/index.html b/index.html index ed90a96..d4e9dc3 100644 --- a/index.html +++ b/index.html @@ -25,18 +25,18 @@
Translation & Rotation -
- - - 0 -
-
0
+
+ + + 0 +
+
@@ -51,7 +51,7 @@
- + 0
@@ -106,9 +106,173 @@

About This Project

How To Use +
+

Getting Started

+

This interactive visualizer demonstrates how a swerve drive robot moves based on commanded + velocities. Use the controls to experiment with different configurations and movement patterns. +

+ +

Drive Controls

+ + +

Preset Configurations

+

Choose from 9 pre-built robot configurations ranging from 2 to 16 wheels. Each preset + demonstrates different module arrangements:

+ + +

Custom Configurations

+

Create your own robot configuration:

+
    +
  1. Enter the desired number of modules (Minimum of 2)
  2. +
  3. Click Generate Position Inputs to create input fields
  4. +
  5. For each module, specify: +
      +
    • Module Name: A label for the module
    • +
    • X Position: Distance from robot center (pixels, positive = right) +
    • +
    • Y Position: Distance from robot center (pixels, positive = up)
    • +
    +
  6. +
  7. Click Apply Custom Configuration to see your design
  8. +
  9. Use Remove Position Inputs to clear the custom fields. This does not reset + the robot, only clears the input box
  10. +
+ +

Understanding the Visualization

+ + +

Module States Panel

+

Displays real-time information for each module:

+ +
- Explaination of Swerve Kinematics + Explanation of Swerve Kinematics +
+

What is Swerve Drive?

+

Swerve drive (also called holonomic drive) is a drivetrain design where each wheel module can + independently rotate and drive in any direction. This allows the robot to move in any direction + while simultaneously rotating, providing exceptional maneuverability.

+ +

Kinematic Equations

+

The simulator calculates each module's state using inverse kinematics. Given a desired robot + velocity (vx, vy) and rotation rate (ω), we calculate each module's + required velocity.

+ +

Field-Relative vs Robot-Relative

+

This simulator uses field-relative control, meaning the velocity commands are + relative to the field, not the robot's current orientation. The inputs are transformed to + robot-relative coordinates using the current gyro heading:

+
+vrobot_x = vfield_x × cos(-θ) - vfield_y × sin(-θ)
+vrobot_y = vfield_x × sin(-θ) + vfield_y × cos(-θ)
+                    
+

Where θ is the robot's heading angle (gyro reading).

+ +

Module Velocity Calculation

+

For each module at position (xi, yi) relative to the robot's center of + rotation:

+
    +
  1. Translation component: The robot's linear velocity (vrobot_x, + vrobot_y)
  2. +
  3. Rotation component: Perpendicular to the position vector, with magnitude + proportional to distance from center: +
    +vrot_x = -yi × ω
    +vrot_y = xi × ω
    +                            
    +
  4. +
  5. Combined velocity: Vector sum of translation and rotation: +
    +vmodule_x = vrobot_x + vrot_x
    +vmodule_y = vrobot_y + vrot_y
    +                            
    +
  6. +
+ +

Module Angle and Speed

+

From the module's velocity vector, we calculate:

+ + +

Speed Normalization

+

If any module's calculated speed exceeds the maximum allowed speed, all module velocities are + scaled proportionally. This preserves the movement direction while respecting hardware limits: +

+
+scale = max_speed / max(calculated_speeds)
+if scale < 1:
+    all_module_speeds × scale
+                    
+ +

Gyro Integration

+

The robot's heading (gyro angle) is continuously updated by integrating the rotation rate:

+
new = θold + ω × Δt
+                    
+

Where Δt is the time step. The heading is normalized to stay within the range [-π, π].

+ +

Real-World Applications

+

Swerve drive systems are commonly used in:

+ + +

Key Advantages

+ + +

Implementation Considerations

+ +