LEGO SPIKE move_tank_for_degrees Path Composer
Executive Summary
The LEGO SPIKE move_tank_for_degrees Path Composer is a specialized tool designed for robotics educators and students who need precise control over robot movements using wheel rotations. This interactive platform allows you to choreograph exact tank-drive sequences by setting independent wheel distances, visualizing the resulting robot pose, and layering multiple movement steps into complete routines. The tool exports structured Python code with student-friendly annotations, making it ideal for STEM classrooms where accuracy and understanding matter.
Unlike velocity-based approaches, move_tank_for_degrees specifies how far each wheel should rotate, giving you deterministic control over both straight-line travel and turning maneuvers. Whether you’re programming a robot to navigate a maze, follow a specific path, or execute a choreographed performance, this Path Composer provides the visual feedback and planning capabilities needed to design complex routines before deploying them on hardware.
Key Benefits:
- Precision Planning: Design multi-step robot paths with exact wheel rotation values
- Visual Feedback: See real-time pose estimates as you compose your sequence
- Educational Focus: Generated code includes comments explaining each step
- Sequence Management: Layer, reorder, and fine-tune multiple movement steps
- Export Ready: One-click Python code export for immediate testing on LEGO SPIKE Prime
Feature Tour
Interactive Step Composer
The heart of the Path Composer is its step-by-step sequence builder. For each movement step, you specify the left and right wheel rotation angles in degrees. The tool immediately calculates the expected translation and rotation of your robot, updating a visual pose estimate that shows where your robot will be after executing the entire sequence.
This visual feedback is invaluable when planning complex maneuvers like figure-eight patterns, pivot turns, or precision navigation through obstacles. You can see exactly how each step contributes to the overall path, making it easy to spot errors or optimize movements before testing on real hardware.
Multi-Step Sequence Editor
Create sophisticated robot routines by adding multiple move_tank_for_degrees commands in sequence. The timeline-style interface lets you visualize all steps at once, reorder them by dragging, duplicate successful patterns, and delete steps that don’t work. Each step displays its wheel rotation values alongside the cumulative pose effect, helping you understand how movements compound.
For classroom projects requiring specific endpoint positions or orientations, the sequence editor becomes your virtual testing ground. Students can experiment with different wheel combinations, learn how differential drive mechanics work, and develop spatial reasoning skills—all before consuming valuable class time with physical robots.
Pose Visualization and Prediction
As you build your sequence, the integrated pose visualizer tracks your robot’s predicted position (x, y coordinates) and heading angle. Starting from an initial pose (typically origin with 0° heading), each step updates the cumulative transformation. The visualization uses arrows or robot outlines to show the progression, making abstract rotation math concrete and understandable.
This feature is especially powerful for educational scenarios. Students can see immediately that a step with equal left and right wheel rotations produces forward movement, while unequal values create turns. The pose prediction helps develop intuition about tank drive kinematics without requiring advanced mathematics.
Python Code Generator
Once your sequence is complete, click the “Export Python” button to generate ready-to-run code for LEGO SPIKE Prime. The generated code includes:
- Import statements for the
MotorPairclass - Motor pair initialization code
- A loop or series of commands iterating through your composed sequence
- Inline comments explaining each step’s purpose and wheel rotation values
- Optional stopping behavior parameters
The code follows LEGO Education Python API conventions and includes helpful annotations for students, such as “Step 1: Move forward 720° on both wheels for approximately 2 rotations.” This educational scaffolding helps learners connect the visual planning with the actual code they’ll deploy.
Presets and Templates
Speed up common tasks with built-in presets for standard maneuvers:
- Forward/Backward Movement: Equal wheel rotations at 360°, 720°, or custom values
- Point Turn: One wheel forward, one backward at equal magnitudes for spinning in place
- Pivot Turn: One wheel stationary (0°), the other rotating to swing around
- Gentle Arc: Slightly different wheel values for curved paths
Select a preset, adjust values to fit your robot’s wheel spacing and tire type, and add it to your sequence. Presets serve as learning templates, showing students proven patterns they can modify for their specific challenges.
Usage Scenarios
Scenario 1: Maze Navigation Challenge
In a classroom maze challenge, students need their robot to make precise 90-degree turns and travel exact distances. Using the Path Composer, they plan a sequence:
- Move forward 1080° (three wheel rotations) to reach the first intersection
- Execute a point turn: left wheel 360° forward, right wheel 360° backward to turn 90° left
- Move forward 720° to the next intersection
- Pivot turn: left wheel 0°, right wheel 540° to swing right
The pose visualizer confirms the final heading and position match the maze exit. They export the code, upload to their SPIKE Prime hub, and successfully navigate the maze on the first try—saving time and building confidence.
Scenario 2: Choreographed Robot Performance
For a school robotics demonstration, students want their robot to “dance” by executing a figure-eight pattern. They use the Path Composer to design:
- Alternating curved paths using differential wheel speeds (e.g., left 900°, right 720°)
- Tight turning loops with one wheel at half the rotation of the other
- Synchronized movements timed to music cues
The sequence editor lets them preview the entire path, adjust loop shapes for aesthetic appeal, and export a polished routine. The resulting performance demonstrates precision control and earns praise from the audience.
Scenario 3: Educational Lab on Differential Drive Kinematics
A teacher uses the Path Composer as a lab tool to teach differential drive principles. Students experiment with various wheel rotation combinations and observe the resulting robot poses:
- Equal positive values → straight forward
- Equal negative values → straight backward
- Opposite signs with equal magnitudes → point turn
- One wheel zero → pivot turn
- Small differences → large radius arc
By manipulating values and seeing immediate visual feedback, students develop deep understanding of tank drive mechanics without needing complex math derivations. The lab report asks them to export code for three different movement types and explain the wheel rotation relationships.
Code Examples
Example 1: Three-Step Forward Path
from spike import MotorPair
# Initialize motor pair (ports A and B)
motor_pair = MotorPair('A', 'B')
# Step 1: Move forward 2 rotations (720 degrees each wheel)
motor_pair.move_tank_for_degrees(720, 100, 100)
# Step 2: Move forward another 3 rotations (1080 degrees)
motor_pair.move_tank_for_degrees(1080, 100, 100)
# Step 3: Move forward 1.5 rotations (540 degrees)
motor_pair.move_tank_for_degrees(540, 100, 100)
# Total distance: 6.5 wheel rotations forward
Use Case: Traveling a known distance by breaking it into manageable segments, useful for multi-stage navigation tasks.
Example 2: 90-Degree Point Turn Sequence
from spike import MotorPair
motor_pair = MotorPair('A', 'B')
# Move forward to position
motor_pair.move_tank_for_degrees(720, 80, 80)
# Execute 90-degree point turn (spin in place)
# Left wheel forward, right wheel backward
motor_pair.move_tank_for_degrees(360, 50, -50)
# Continue forward after turn
motor_pair.move_tank_for_degrees(720, 80, 80)
Use Case: Navigate a right-angle turn in a maze or obstacle course with precision.
Example 3: Figure-Eight Choreography
from spike import MotorPair
motor_pair = MotorPair('A', 'B')
# First loop: curved path with differential speeds
motor_pair.move_tank_for_degrees(1080, 100, 70) # Left faster → curve right
# Transition turn
motor_pair.move_tank_for_degrees(540, 60, -60) # Point turn
# Second loop: mirror curve
motor_pair.move_tank_for_degrees(1080, 70, 100) # Right faster → curve left
# Return to start
motor_pair.move_tank_for_degrees(540, -60, 60) # Reverse point turn
Use Case: Create artistic or demonstration routines showcasing smooth curved motion and symmetry.
Example 4: Pivot Turn Around Right Wheel
from spike import MotorPair
motor_pair = MotorPair('A', 'B')
# Move to pivot position
motor_pair.move_tank_for_degrees(540, 100, 100)
# Pivot turn: right wheel stays still, left rotates
motor_pair.move_tank_for_degrees(720, 0, 80) # Right=0, left rotates
# Continue forward
motor_pair.move_tank_for_degrees(540, 100, 100)
Use Case: Execute tight turns in constrained spaces where a point turn radius is too large.
Troubleshooting
Issue: Robot’s final position doesn’t match the predicted pose in the visualizer.
Solutions:
- Verify your robot’s wheel diameter and spacing match assumed defaults (typically 56mm SPIKE wheels at 110mm spacing)
- Check for tire slippage on smooth surfaces; add rubber bands for better traction
- Calibrate motor encoders by resetting them before running the sequence
- Ensure battery charge is adequate; low power affects motor torque and accuracy
Issue: Exported code runs but movements seem inconsistent across multiple runs.
Solutions:
- Add
motor_pair.set_stop_action('brake')before your sequence to use active braking instead of coasting - Ensure motors are properly secured to the hub and wires aren’t loose
- Test on a consistent surface; carpet vs. tile can produce different friction
- Use lower speed values (60-80 instead of 100) for more reliable, consistent motion
Issue: Complex curves don’t match the predicted path.
Solutions:
- Break long curved segments into shorter steps with intermediate speed adjustments
- Remember that
move_tank_for_degreesuses constant speeds per step, not gradual acceleration - Test wheel rotation ratios incrementally: start with 10% difference, then 20%, etc.
- Use the Path Composer’s pose visualizer to iteratively refine wheel values
Issue: The sequence editor becomes cluttered with too many steps.
Solutions:
- Use the “Group Steps” feature (if available) to collapse related movements into logical sections
- Delete experimental steps that didn’t work rather than keeping them for reference
- Save intermediate sequences as separate compositions for complex projects
- Export code for working segments and start fresh sequences for new sections
Issue: Students struggle to understand the relationship between wheel degrees and robot movement.
Solutions:
- Start with simple equal-value steps (both wheels at 360°) to demonstrate forward motion
- Progress to point turns with opposite-sign equal magnitudes (360° vs. -360°)
- Use physical demonstrations with hand-cranked motors to show how degrees map to rotations
- Assign lab exercises comparing predicted poses to actual robot positions measured with rulers
Frequently Asked Questions
1. What’s the difference between move_tank and move_tank_for_degrees?
move_tank controls wheel velocities for a continuous duration, while move_tank_for_degrees specifies exact wheel rotation amounts. Use move_tank when you need immediate responsive control (like joystick driving) and move_tank_for_degrees when you need precise, repeatable movements (like autonomous navigation). The Path Composer focuses on the latter because it’s more suitable for planned sequences and educational projects requiring accuracy.
2. How do I convert a distance (like 50 cm) into wheel rotation degrees?
Calculate using the formula: degrees = (distance / wheel_circumference) × 360°. For SPIKE Prime 56mm diameter wheels, circumference ≈ 176mm. So 50 cm (500mm) requires approximately (500/176) × 360° ≈ 1023 degrees. The Path Composer includes a distance-to-degrees calculator in the settings panel to help with this conversion.
3. Can I use this tool for robots with different wheel spacings?
Yes! Access the robot configuration settings and input your actual wheel spacing (distance between left and right wheel centers). The pose visualizer will recalculate turning radii and rotations based on your custom dimensions. This is especially important for robots with wide or narrow track widths, as it significantly affects turning behavior.
4. Why doesn’t my robot turn exactly 90 degrees when I use equal opposite wheel rotations?
Several factors affect real-world accuracy: wheel diameter variations, surface friction, motor encoder precision, and battery voltage. The Path Composer uses idealized kinematics. For precise angle control, you may need to empirically calibrate by testing and adjusting. Try running a 360° point turn, measure the actual rotation, then scale your degree values proportionally.
5. How can I synchronize movements with time, like in a music performance?
While move_tank_for_degrees focuses on position rather than time, you can estimate duration using motor speed and rotation amount. For time-critical choreography, consider using the LEGO SPIKE move_tank_for_time Motion Sequencer instead, which is specifically designed for timed sequences. You can use both tools together—plan positions with this Path Composer, then convert to time-based sequences.
6. Can I import existing Python code into the Path Composer?
Currently, the tool is designed for forward workflow (compose → export). However, you can manually recreate sequences by entering the degree values from your existing code into new steps. This is useful for visualizing and optimizing legacy code. A future update may include code parsing and import functionality.
7. How do I handle multi-step sequences that need sensor feedback between movements?
The Path Composer generates pure motion sequences without sensor integration. For sensor-driven decisions (like “stop if distance < 10cm”), you’ll need to manually edit the exported code to add conditional logic between steps. Use the composition as your motion template, then insert sensor checks using if statements in your Python code.
References and Further Learning
- LEGO SPIKE Prime Python API Documentation: Official reference for
move_tank_for_degreesand related methods - Gray-wolf Tools: LEGO SPIKE Turning Simulator Enhanced: Companion tool for understanding turn radius calculations and wheel speed relationships
- Gray-wolf Tools: LEGO SPIKE move_tank Maneuver Studio: Explore velocity-based tank drive control for comparison with degree-based methods
- Gray-wolf Tools: LEGO SPIKE move_tank_for_time Motion Sequencer: Time-based motion planning for choreographed performances
- Differential Drive Robotics Tutorial - Carnegie Mellon Robotics Academy: Deep dive into tank drive kinematics and turning calculations
Accessibility Note: The Path Composer includes keyboard navigation for all controls (Tab to navigate, Enter to activate), screen reader labels for all input fields and buttons, and high-contrast visual indicators for the pose visualizer. Visual feedback is supplemented with numeric readouts of position and heading values for users with visual impairments.
Get Started: Visit the LEGO SPIKE move_tank_for_degrees Path Composer and begin planning your next robot routine with precision and confidence.