United Kingdom
Asked

ESP32 Tank Track AI Control

Hello, I have an ESP32 running tank tracks and a waist swivel, but I'm having trouble getting the autonomous AI to control them. Can anyone help?



Related Hardware (view all EZB hardware)
Esp32 by Espressif
Control ESP32 boards with Synthiam ARC: EZB-like firmware for GPIO, PWM/servos, serial, WiFi modes, safe pins, wiring and power tips.
Wi-Fi
Servos Varies
Camera
Audio
UART Varies
I2C
ADC Varies
Digital Varies

Related Robot Skills (view all robot skills)
Movement Script by Synthiam
Trigger direction-specific scripts when ARC movement panels change; assign scripts per direction/stop, access direction and speed (JS/Python/EZ).
Custom Movement V2 panel for ARC: scripts for F/R/L, Reverse, roll left/right, up/down with speed mapping to PWM for drones, mecanum & custom drives

ARC Pro

Upgrade to ARC Pro

Experience the transformation – subscribe to Synthiam ARC Pro and watch your robot evolve into a marvel of innovation and intelligence.

Author Avatar
PRO
Canada
#1  

Thanks - this is a common setup. Below I’ll give a clear checklist, debugging tips, and ready-to-paste JavaScript examples you can put into the Custom Movement Panel v2 scripts so your ESP32 tank tracks + waist swivel respond to autonomous AI movement commands.

Before you start

  • Confirm ARC is connected to your ESP32 (EZB firmware) and that the project shows the EZB as Connected.
  • Confirm which ARC "AI/autonomy" skill you are using (Navigation, Object Avoidance, NMS, a custom script, etc.). Most ARC autonomy skills issue movement through the Movement Manager (Movement.forward(), Movement.left(), etc.). Custom Movement Panel v2 must be the active Movement Panel to receive those commands. Which skill are you using?
  • Identify how your motors are wired to the H-bridges / motor drivers:
    • Option A (common): each motor uses IN1 + IN2 for direction and an EN/ENA pin for PWM (e.g., L298 style).
    • Option B: driver uses one DIR pin + one PWM pin.
    • Tell me which ports (EZB ports like d0, d1, d2...) are wired to each signal and the waist servo port (dX or vY).

Quick checklist (do these first)

  1. Verify safe ESP32 pins are used for motors/servos (see ESP32 guide). If you see resets or jitter, move to safe pins: 2, 4, 12-19, 21-23, 25-27, 32-33.
  2. Use external 5V supply for motors/servos and connect its GND to ESP32 GND.
  3. Confirm the Custom Movement Panel v2 skill is loaded from Project -> Add robot skill and is the Movement Panel (it will register itself).
  4. Test manual control in ARC (movement panel buttons) - ensure motors respond manually before testing autonomous AI.
  5. Turn on logging inside the movement scripts (print()) to confirm the movement manager is calling the scripts and what speeds it’s sending.

Where to put the code

  • Open your Custom Movement Panel v2 skill window, click the kebab menu (three lines) -> Settings (scripts). Paste each JavaScript snippet into the matching direction script (Forward, Reverse, Left, Right, Stop, RollLeft/Right if used). Save.

Examples (replace port names with your actual ports) Below are two common wiring patterns. Use the one matching your wiring. Replace the d# constants with your ports.

  1. H-bridge with IN1/IN2 + ENA (recommended for L298, TB6612 style)
  • left IN1 = d0
  • left IN2 = d1
  • left ENA (PWM) = d2
  • right IN1 = d3
  • right IN2 = d4
  • right ENA (PWM) = d5

Forward script

// Forward script - H-bridge IN1/IN2 + ENA
var leftSpeed = Movement.getSpeedLeft();   // 0-255
var rightSpeed = Movement.getSpeedRight(); // 0-255

// map to PWM 0-100
var lPWM = Utility.map(leftSpeed, 0, 255, 0, 100);
var rPWM = Utility.map(rightSpeed, 0, 255, 0, 100);

// set forward direction
Digital.set(d0, true);  // left IN1
Digital.set(d1, false); // left IN2
Digital.set(d3, true);  // right IN1
Digital.set(d4, false); // right IN2

PWM.set(d2, lPWM); // left ENA
PWM.set(d5, rPWM); // right ENA

print("Forward L PWM:" + lPWM + " R PWM:" + rPWM);

Reverse script

// Reverse script - H-bridge
var leftSpeed = Movement.getSpeedLeft();
var rightSpeed = Movement.getSpeedRight();

var lPWM = Utility.map(leftSpeed, 0, 255, 0, 100);
var rPWM = Utility.map(rightSpeed, 0, 255, 0, 100);

// set reverse direction
Digital.set(d0, false); // left IN1
Digital.set(d1, true);  // left IN2
Digital.set(d3, false); // right IN1
Digital.set(d4, true);  // right IN2

PWM.set(d2, lPWM);
PWM.set(d5, rPWM);

print("Reverse L PWM:" + lPWM + " R PWM:" + rPWM);

Left turn (pivot) script - pivot left (left reverse, right forward)

// Left pivot - H-bridge
var leftSpeed = Movement.getSpeedLeft();
var rightSpeed = Movement.getSpeedRight();

var lPWM = Utility.map(leftSpeed, 0, 255, 0, 100);
var rPWM = Utility.map(rightSpeed, 0, 255, 0, 100);

// left reverse
Digital.set(d0, false);
Digital.set(d1, true);
PWM.set(d2, lPWM);

// right forward
Digital.set(d3, true);
Digital.set(d4, false);
PWM.set(d5, rPWM);

print("Pivot Left L PWM:" + lPWM + " R PWM:" + rPWM);

Right pivot script - pivot right (left forward, right reverse)

// Right pivot - H-bridge
var leftSpeed = Movement.getSpeedLeft();
var rightSpeed = Movement.getSpeedRight();

var lPWM = Utility.map(leftSpeed, 0, 255, 0, 100);
var rPWM = Utility.map(rightSpeed, 0, 255, 0, 100);

// left forward
Digital.set(d0, true);
Digital.set(d1, false);
PWM.set(d2, lPWM);

// right reverse
Digital.set(d3, false);
Digital.set(d4, true);
PWM.set(d5, rPWM);

print("Pivot Right L PWM:" + lPWM + " R PWM:" + rPWM);

Stop script

// Stop - H-bridge
PWM.set(d2, 0);
PWM.set(d5, 0);

// optionally release direction pins for safety
Digital.set(d0, false);
Digital.set(d1, false);
Digital.set(d3, false);
Digital.set(d4, false);

print("Stop");
  1. Driver with DIR + PWM (alternate wiring)
  • left DIR = d0, left PWM = d1
  • right DIR = d2, right PWM = d3

Forward script (DIR true for forward, false for reverse)

var leftSpeed = Movement.getSpeedLeft();
var rightSpeed = Movement.getSpeedRight();

var lPWM = Utility.map(leftSpeed, 0, 255, 0, 100);
var rPWM = Utility.map(rightSpeed, 0, 255, 0, 100);

// Direction pins -> forward
Digital.set(d0, true); // left DIR
Digital.set(d2, true); // right DIR

PWM.set(d1, lPWM);
PWM.set(d3, rPWM);

print("Forward DIR-based L PWM:" + lPWM + " R PWM:" + rPWM);

Reverse = set DIR false; Left/Right pivots: set left DIR/reverse accordingly.

Waist swivel (servo)

  • If your waist servo is a normal PWM servo on e.g., d6:
// Example: set waist to center (90)
Servo.setPosition(d6, 90);
print("Waist -> 90");
  • If you use the Custom servo Controller skill and mapped the waist to a virtual servo (v0), use:
Servo.setPosition(v0, 90);

How autonomous AI commands reach the Movement Panel

  • Autonomy skills (navigation, obstacle avoidance, NMS, custom AI) call Movement.forward(), Movement.left(), Movement.stop(), etc., or otherwise use the Movement Manager. The Custom Movement Panel v2 becomes the receiver and executes the script you put in the appropriate direction block.
  • If your AI skill is not using Movement.* calls, it won’t control the movement panel. Tell me what AI/autonomy skill you are running and I’ll confirm how it emits movement commands or show how to modify it.

Debugging tips

  • Add print() statements (already in examples) to see when scripts run and what speeds are received.
  • Use manual movement buttons in ARC to verify wiring and that PWM/direction behave as expected before enabling autonomous mode.
  • If motors don’t move or ESP32 reboots when motors move: check power supply for adequate current and shared ground.
  • If you see movement commands hitting the panel (see print logs) but motors don’t respond, double-check port assignments and test each motor independently.

Next steps - I can help further if you provide:

  1. Which ARC autonomous AI/navigation skill you are using.
  2. Exact wiring/port mapping: which EZB ports go to left IN1, left IN2, left ENA, right IN1, right IN2, right ENA (or DIR/PWM pairs), and the waist servo port.
  3. Any error messages in ARC or serial logs from the ESP32.

If you paste your port mapping I’ll customize exact scripts (including rollLeft/rollRight/up/down if you use them) and help you tune the turning behavior (pivot vs differential slip).


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#2   — Edited

Athena's feedback is mostly correct if a custom Movement Panel is needed. Athena had to "guess" an answer because much of the information is missing from the question. For example, is the drive system continuous-rotation servos? An hbridge? etc., that will determine what Movement Panel type to use.

As for the autonomous AI robot skill, there are no specifics regarding what the autonomous AI robot is not doing for you. Can you explain in more detail the issues you are experiencing and the desired outcome?

Author Avatar
PRO
Canada
#3  

Good follow-up from Synthiam_Support - they’re right: we need details about the drive hardware and what the autonomous AI skill actually does (or does not do). Below is a short debugging checklist, easy tests you can run right now, sample JavaScript snippets to add to the Custom Movement Panel v2 scripts (to confirm commands are received), and the exact information I need from you to produce ready-to-run scripts for your ESP32 robot.

Please paste answers to the numbered questions at the end so I can give you code tuned to your exact wiring and AI skill.

Quick checklist (do these first)

  • Confirm ARC shows the ESP32 (EZB firmware) as Connected.
  • Verify Custom Movement Panel v2 is the active Movement Panel in your project (only one Movement Panel can be active).
  • Verify motors/waist work with manual movement controls in ARC (movement panel buttons or manual servo/motor tests). If manual control doesn’t work, fix hardware/wiring first.
  • Use an external power supply for servos/motors. Make sure the motor/servo supply GND is connected to the ESP32 GND.
  • Use safe ESP32 pins for servos/motors (recommended: 2,4,12-19,21-23,25-27,32-33).

How to confirm autonomous commands actually reach the Custom Movement Panel

  1. Open Custom Movement Panel v2 kebab menu (three lines) Settings open the script editor for the direction you expect (e.g., Forward).
  2. Paste the small "log-only" snippet below into the Forward script and Save. This will tell you when ARC calls the Forward script and what speeds were requested:
// Forward (debug/logging) - paste into Custom  Movement Panel v2 Forward script
var dir = getVar("$Direction", "unknown");
var left = Movement.getSpeedLeft();
var right = Movement.getSpeedRight();
print("Movement Panel: Forward called | $Direction=" + dir + " | left=" + left + " right=" + right);
  1. Run your autonomous AI. Watch ARC’s Script Console (or the log view) for the print output. If you see the print, the Movement Panel is receiving commands. If you don’t see anything, the AI likely isn’t calling Movement.* or the custom panel isn’t active.

Quick test to force a movement call from ARC (use Script Control or Script Console)

// Run from Script Control to test the  Movement Panel manually
Movement.forward(); // should cause the Forward script in your Custom  Movement Panel to run

Common drive types and how AI commands must be handled

  • Continuous-rotation servos (CR servos): you set Servo.setPosition(port, value) where ~90 is stop, >90 one direction, <90 the other. Your Forward/Left/Right scripts must call Servo.setPosition() with mapped values.
  • H-bridge (IN1/IN2 + EN/PWM): you set direction pins via Digital.set() and speed via PWM.set(). Example scripts provided below.
  • DIR + PWM drivers: set DIR (Digital.set) and PWM.set for speed. Which to use depends on your motor driver - that determines what code to add to each movement direction.

Example skeletons (pick the pattern matching your hardware)

  1. H-bridge (IN1/IN2 + ENA PWM) - replace d0..d5 with your ports Forward script:
var leftSpeed = Movement.getSpeedLeft();
var rightSpeed = Movement.getSpeedRight();
var lPWM = Utility.map(leftSpeed, 0, 255, 0, 100);
var rPWM = Utility.map(rightSpeed, 0, 255, 0, 100);

// left forward
Digital.set(d0, true);  // left IN1
Digital.set(d1, false); // left IN2
PWM.set(d2, lPWM);      // left ENA

// right forward
Digital.set(d3, true);  // right IN1
Digital.set(d4, false); // right IN2
PWM.set(d5, rPWM);      // right ENA

print("Forward | L PWM:" + lPWM + " R PWM:" + rPWM);

Stop script:

PWM.set(d2, 0);
PWM.set(d5, 0);
// Optional: clear direction pins
Digital.set(d0, false); Digital.set(d1, false);
Digital.set(d3, false); Digital.set(d4, false);
print("Stop");
  1. DIR + PWM driver - replace ports accordingly Forward:
var leftSpeed = Movement.getSpeedLeft();
var rightSpeed = Movement.getSpeedRight();
var lPWM = Utility.map(leftSpeed, 0, 255, 0, 100);
var rPWM = Utility.map(rightSpeed, 0, 255, 0, 100);

// set forward direction
Digital.set(d0, true);  // left DIR
Digital.set(d2, true);  // right DIR

PWM.set(d1, lPWM); // left PWM
PWM.set(d3, rPWM); // right PWM

print("Forward DIR | L PWM:" + lPWM + " R PWM:" + rPWM);
  1. Continuous-rotation servos (single servo per track) Forward:
var leftSpeed = Movement.getSpeedLeft();   // 0-255
var rightSpeed = Movement.getSpeedRight(); // 0-255

// Map 0-255 to servo position where 90=stop. Adjust values as needed for calibration.
var lPos = Utility.map(leftSpeed, 0, 255, 90, 150);   // example mapping
var rPos = Utility.map(rightSpeed, 0, 255, 90, 30);   // reversed servo example

Servo.setPosition(d0, lPos); // left servo port
Servo.setPosition(d1, rPos); // right servo port

print("Forward CR | L pos:" + lPos + " R pos:" + rPos);

Waist swivel (standard servo example)

// Set waist to center (90) or to a dynamic value
Servo.setPosition(d6, 90);
print("Waist -> 90");

Important debugging tips

  • If you get prints showing the script runs but motors don’t move: double-check port numbers and that PWM/direction pins are wired to the ESP32 ports you used (remember: use d0..d23 in scripts without quotes).
  • If the ESP32 reboots when motors run: almost always a power problem - use a separate properly-rated 5V supply and tie grounds together.
  • If the AI does nothing and you never see the prints: the AI skill may not be calling Movement.forward()/left()/etc. Tell me which autonomy/AI skill you’re using (Navigation, Object Avoidance, NMS, custom script, 3rd party skill) so I can check how it issues movement commands.
  • Use getVar("$Direction") inside scripts to see the global direction variable.
  • Confirm only one Movement Panel is active. Another panel owning movement will intercept movement commands.

Exactly what I need from you (paste answers)

  1. Drive system type: H-bridge (IN1/IN2 + EN), DIR+PWM driver, continuous-rotation servos, motor controller model, or other?
  2. Exact EZB/ESP32 port mapping (e.g., left IN1 = d0, left IN2 = d1, left ENA = d2, right IN1 = d3, right IN2 = d4, right ENA = d5, waist servo = d6). If some signals are virtual servos (v0, etc.) say so.
  3. Name of the autonomous AI/navigation robot skill you’re using (exact skill name as shown in ARC).
  4. What happens when you enable the AI (no movement? only one side moves? jittering? ESP32 reboot? commands reach panel but motors don't move?) - be specific.
  5. If you already added the debug print() to the Forward/Left/Right scripts, paste the console output (or say you saw nothing).

If you paste 1-3 (ports, drive type, AI skill), I will:

  • Provide exact JavaScript scripts to paste into each Custom Movement Panel v2 direction (Forward, Reverse, Left, Right, Stop), including waist control,
  • Show small calibration notes (stop values for CR servos or PWM inversion),
  • Give a final test plan to validate autonomous control.

Useful links

Tell me the port mapping + drive type + AI skill name and I’ll give you the exact scripts ready to paste into the movement panel.


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.