Overview
Now that you understand kinematics, it’s time to make the robot move! Trajectory planning involves:- Path Definition - Specify where the robot should go
- Trajectory Generation - Convert path to time-stamped positions
- Velocity Computation - Calculate required velocities
- Wheel Command Calculation - Use inverse kinematics
- Simulation - Integrate motion and visualize results
Deliverable D1.2: Simulate at least 3 different trajectories and analyze robot performance
Trajectory Types
Required Trajectories
You must implement at least these three trajectories:1. Square Path (1m × 1m) - Constant Orientation
1. Square Path (1m × 1m) - Constant Orientation
Requirements:
- Robot moves in a 1m × 1m square
- Robot orientation remains constant (e.g., always facing “North”)
- Uses combination of forward and sideways motion
- Omnidirectional motion
- Sharp corners or smooth transitions
- Coordinated Vx and Vy control
2. Circle (1m diameter) - Constant Orientation
2. Circle (1m diameter) - Constant Orientation
Requirements:
- Robot follows circular path (0.5m radius)
- Robot orientation fixed (e.g., always facing North)
- Smooth continuous motion
- Simultaneous Vx and Vy
- Circular motion without rotation
- Smooth velocity transitions
3. Circle - Tangent Orientation
3. Circle - Tangent Orientation
Requirements:
- Robot follows circular path
- Robot always faces tangent to circle (like a car)
- Combines translation and rotation
- Coordinated angular velocity
- Smooth ω with translation
- Realistic motion pattern
Bonus Trajectories (Optional)
Impress with additional trajectories:- Figure-8 path - Tests reverse motion and smooth transitions
- Parallel parking - Sideways motion utility
- Spiral - Variable radius circular motion
- Custom logo/shape - Get creative!
Implementation Approach
Method 1: Velocity-Based (Recommended)
Generate velocity commands at each time step:Method 2: Position-Based
Define exact position trajectory, then differentiate:Example: Square Trajectory
Approach: Piecewise Linear Segments
Smooth Corners (Advanced)
Use ramp functions to smooth velocity transitions:Example: Circular Trajectory
Constant Orientation Circle
Tangent Orientation Circle
Robot faces direction of motion (like a car turning):Alternative: Inward-Facing Circle
Robot always faces center of circle:Complete Simulation Script
Visualization Functions
Animated Robot Visualization
Analysis and Reporting
What to Include in Your Report
-
Trajectory Definitions:
- Mathematical equations or description
- Velocity profiles
- Total path length and duration
-
Simulation Results:
- Path plots showing robot successfully followed trajectory
- Position vs. time graphs
- Velocity command profiles
- Wheel velocity profiles
-
Parameter Analysis:
Create a study showing effects of:
- Wheel radius: Smaller wheels → higher wheel speeds for same robot speed
- Wheelbase/Track width: Affects rotation speed requirements
- Speed: Higher speeds → higher wheel velocities (check motor limits!)
-
Validation:
- Does circular path actually form a circle? (Check using x² + y² = r²)
- Do wheel velocities stay within motor limits?
- Are velocity commands smooth (no discontinuities)?
Sample Analysis Code
Common Issues and Solutions
Path doesn't close (circle not circular)
Path doesn't close (circle not circular)
Cause: Integration error accumulates over timeSolutions:
- Use smaller time step (dt)
- Use higher-order integration (ode45 instead of Euler)
- Switch to position-based trajectory
Discontinuous wheel velocities
Discontinuous wheel velocities
Cause: Abrupt changes in desired velocity (e.g., sharp corners)Solutions:
- Add smooth transitions between segments
- Use sinusoidal or polynomial blending
- Plan trajectories with continuous derivatives
Wheel velocities exceed motor limits
Wheel velocities exceed motor limits
Cause: Commanded robot velocity too high for robot parametersSolutions:
- Reduce desired speed
- Increase wheel radius (if possible in design)
- Add velocity saturation in inverse kinematics
Robot drifts from path
Robot drifts from path
Cause: Integration error, incorrect coordinate frame transformationsSolutions:
- Check rotation matrix from body to global frame
- Verify initial conditions
- Use smaller dt
Tips for Success
Start Simple
Begin with straight line, then add complexity. Debug each motion type separately.
Validate Numerically
For circle: verify x² + y² ≈ r². For square: check distances match 1m.
Professional Plots
Use labels, titles, legends, grid. Export high-res images for report.
Save Your Data
Save simulation results to .mat files for later analysis without re-running.
Next Steps
Hardware Specs
Use real motor specs for realistic simulation
WP2: CAD Design
Start designing the physical robot
WP3: Motor Control
Implement control on ESP32 hardware
Code Examples
See PID implementation for real hardware