scaralang

Python toolchain and compiler for the SCARA Robotics


Project maintained by vroncevic Hosted on GitHub Pages — Theme by mattgraham

SCARA Domain-Specific Language (DSL) Specification & Reference Manual

Version: 1.0.2
Target: Industrial SCARA Robotic Manipulators
Toolchain: scaralang (scarac compiler & binary protocol engine)
Author: Vladimir Roncevic
License: GPL-3.0 / Apache-2.0


Table of Contents

  1. Introduction
  2. Lexical Structure & Syntax
  3. Language Instructions Reference
  4. Static Analysis & Linter Rules
  5. Complete Industrial Example Scripts

1. Introduction

The SCARA Domain-Specific Language (DSL) is a high-level, human-readable robotic programming language designed specifically for Selective Compliance Assembly Robot Arm (SCARA) 4-axis manipulators ($X, Y, Z, \Phi$).

Unlike generic CNC G-code, SCARA DSL is natively aware of:


2. Lexical Structure & Syntax

2.1 Line-Oriented Statements

A .scara program consists of sequence lines. Each line contains at most one statement. A statement starts with a command keyword, followed by optional or required parameters:

MOVE_L X 150.0 Y 45.0 Z 20.0
PUMP ON
WAIT 150

2.2 Case Insensitivity

All command keywords and parameter identifiers are case-insensitive:

MOVE_L X 100.0 Y 50.0 Z 10.0
move_l x 100.0 y 50.0 z 10.0
Move_L X 100.0 Y 50.0 Z 10.0

All three variants produce identical AST nodes and binary instructions.

2.3 Parameter Passing Styles

Parameters may be passed either using whitespace separation (KEY VALUE) or explicit assignment (KEY=VALUE):

# Whitespace style
MOVE_L X 150.0 Y 75.0 Z 20.0 P 45.0

# Assignment style
MOVE_L X=150.0 Y=75.0 Z=20.0 P=45.0

# Mixed style (fully supported)
JUMP X 150.0 Y=75.0 Z 20.0 ARCH=35.0

2.4 Comments and Whitespace

2.5 Coordinate System & Standard Units

Dimension Axis Unit Description
Linear Coordinates X, Y, Z Millimeters (mm) Absolute or frame-relative Cartesian position.
Tool Orientation P / PHI Degrees (°) 4th-axis end-effector yaw rotation ($\pm 180^\circ$).
Arc Center Offsets I, J Millimeters (mm) Incremental vector offset from starting point to arc center.
Feedrate SPEED mm/s Tool center point (TCP) linear speed.
Acceleration ACCEL mm/s² Linear path acceleration and deceleration.
Time Delay WAIT / WAIT_MS Milliseconds (ms) Hardware execution dwell.
Joint Angles deg Degrees (°) Joint 1, Joint 2 arm angles, Joint 4 yaw.

3. Language Instructions Reference

Category 1: Cartesian & Joint Motion


MOVE_J

Rapid Joint Point-to-Point Motion

Moves the robot arm to the target Cartesian coordinates using non-interpolated joint motion. Both arm joints articulate simultaneously at maximum speed without enforcing a straight-line Cartesian path. Best used for clearance travel and rapid repositioning.


MOVE_L

Linear Cartesian Interpolated Motion

Executes a linear, straight-line trajectory from the current position to the destination coordinates at the currently active working feedrate (SPEED WORK).


ARC_CW

Clockwise Circular Arc Interpolation

Interpolates a circular arc in the XY plane in a clockwise direction. The arc begins at the current robot position and terminates at (X, Y). The circle center is defined relative to the starting position via I (X offset) and J (Y offset).


ARC_CCW

Counter-Clockwise Circular Arc Interpolation

Interpolates a circular arc in the XY plane in a counter-clockwise direction from the current position to (X, Y) around the center offset (I, J).


APPROACH

Relative Vertical Descent

Performs a relative vertical descent along the negative Z axis from the current position by the specified clearance distance. Used to move down safely from clearance plane to pickup or placement plane.


RETRACT

Relative Vertical Ascent

Performs a relative vertical ascent along the positive Z axis from the current position by the specified clearance distance. Used to lift the tool up safely away from workpiece and fixtures before horizontal moves.


JOG_AXIS

Manual Incremental Cartesian Jog

Commands a single-axis relative jog displacement along a chosen Cartesian degree of freedom. Used primarily in manual setup, calibration, and REPL control.


JOG_JOINT

Manual Incremental Joint Jog

Rotates an individual robotic actuator joint by a relative angle.


PROBE

Tactile Surface Search

Drives the Z-axis downwards at a controlled speed until a tactile touch probe or microswitch sensor triggers. Upon contact, the current coordinate is registered, motion halts cleanly, and subsequent commands proceed from the probed plane.


Category 2: High-Level Macros & Palletization


JUMP

3D Parabolic Arch Pick & Place

The quintessential robotic pick-and-place command. Expands into a smooth, time-optimal 3D motion consisting of:

  1. Smooth vertical lift-off along Z to apex height ARCH.
  2. High-speed horizontal transfer in XY plane.
  3. Smooth vertical descent to destination (X, Y, Z).

Eliminates discrete corner stops and optimizes cycle times.


PALLET_DEF

Matrix Pallet Grid Definition

Defines a structured 2D Cartesian pallet matrix of components or trays. Establishes the grid layout with row count, column count, and pitch offsets between cells.


MOVE_PALLET

Pallet Index Positioning

Moves the robot to the specified 1-indexed cell within a previously defined pallet matrix. Automatically computes the Cartesian coordinates based on row and column index.


Category 3: Actuator & Tool Control


PUMP

Vacuum Generator Actuation

Controls the vacuum suction generator pump for end-effector pneumatic pick-and-place grippers.


VALVE

Vacuum Blow-Off Release Valve

Actuates the pneumatic release blow-off valve to exhaust vacuum pressure and instantaneously release gripped parts.


TOOL

Vertical Slide Stage Actuation

Controls a secondary high-speed pneumatic or motorized vertical slide stage mounted on the tool head.


TOOL_ORIENT

End-Effector Orientation Mode

Configures the 4th-axis tool yaw tracking behavior during multi-axis path execution.


Category 4: Dynamics & Trajectory Shaping


SPEED

Travel and Working Feedrate Limit

Sets the maximum Cartesian linear velocity for subsequent motion segments. Supports separate definitions for rapid positioning (RAPID) and working contact travel (WORK).


ACCEL

Path Acceleration Limit

Configures the maximum linear path acceleration and deceleration for trajectory planning.


OVERRIDE

Dynamic Real-Time Speed Override

Applies a dynamic global percentage scaling factor to all path feedrates without modifying programmed velocity coordinates.


ZONE

Corner Path Blending & Rounding Mode

Controls corner rounding and trajectory continuous path blending between adjacent motion segments.


Category 5: Work Coordinates & Kinematic Configuration


CONFIG ELBOW

Kinematic Arm Solution Branch

Specifies the inverse kinematics arm solution configuration. For any SCARA Cartesian coordinate within the workspace, two valid joint angles exist: Elbow Left or Elbow Right.


CONFIG MOTOR

Stepper Drive Feedback Mode

Selects the actuation drive mode of the robot joint steppers.


FRAME_SET / FRAME

Work Coordinate System (WCS)

Defines a local User Coordinate System offset from the robot base. All subsequent motion coordinates are interpreted relative to this frame.


FRAME_RESET

Reset Coordinate System to World Base

Clears all active work coordinate transformations, restoring the global robot base origin as the reference coordinate frame.


HOME

Multi-Axis Calibration & Homing Routine

Executes the hardware reference homing sequence for all axes (Joint 1, Joint 2, Z-axis, Tool yaw). Synchronizes stepper motor step counters with optical physical limit switches.


Category 6: Execution Flow & Safety


WAIT / WAIT_MS

Trajectory Dwell Delay

Pauses program execution for a specified duration in milliseconds. Used to allow pneumatic pressures to equalize, mechanical vibrations to dampen, or peripheral automation to index.


SYNC

Trajectory Buffer Barrier Flush

Inserts an execution barrier that blocks further command execution until the robot controller’s motion buffer completely drains and all axes come to a complete physical standstill.


HOLD

Trajectory Feed Hold (Pause)

Commands a controlled deceleration and immediate suspension of the running trajectory. Motors remain energized and position coordinates are preserved.


RESUME

Resume Paused Trajectory

Resumes motion along a previously paused (HOLD) trajectory from the exact suspended coordinates.


ESTOP

Immediate Emergency Stop

Executes an instantaneous hard stop aborting all motion, clearing command queues, and locking execution until an explicit reset.


ENABLE

Energize Motor Driver Stages

Powers up and energizes the stepper motor driver stages, applying holding torque to all axes.


DISABLE

De-energize Motor Driver Stages

Cuts power to stepper driver motor windings, releasing holding torque. Allows manual positioning by hand.


4. Static Analysis & Linter Rules

The scaralang toolchain includes an industrial-grade static analyzer and linter (scarac lint). It inspects AST instructions before compilation and flags semantic issues into three severity categories: ERROR, WARNING, and INFO.

4.1 Motion Rules

Rule Identifier Checker Service Description Severity
MOTION_UNCALIBRATED MotionCalibrationValidator Motion instruction (MOVE_J, MOVE_L, etc.) is commanded before HOME homing routine. WARNING
MOTION_DUPLICATE MotionDuplicateValidator Adjacent move instructions specify identical target coordinates, wasting trajectory planning cycles. INFO
MOTION_WORKSPACE_LIMIT TrajectoryValidator Target coordinate falls outside the physical reach envelope ($R_{min} \le r \le R_{max}$, $Z_{min} \le z \le Z_{max}$). ERROR

4.2 Pneumatic & Vacuum Rules

Rule Identifier Checker Service Description Severity
PNEUMATIC_CONFLICT PneumaticConflictValidator PUMP ON and VALVE ON are commanded simultaneously, causing hardware pneumatic contention. ERROR
PNEUMATIC_FLYBY PneumaticFlybyValidator PUMP ON is triggered without a subsequent dwell (WAIT) before initiating rapid motion, risking part drop. WARNING
PNEUMATIC_REDUNDANT PneumaticRedundancyValidator Consecutive redundant state changes (e.g. PUMP ON followed immediately by PUMP ON). INFO

4.3 State & Kinematic Rules

Rule Identifier Checker Service Description Severity
STATE_HOMING_REDUNDANT StateHomingValidator Multiple HOME commands placed without physical reason. INFO
STATE_MOTOR_MODE MotorModeValidator Incompatible motor drive mode or configuration timing. WARNING
STATE_ZONE_CONFLICT StateZoneValidator Zone rounding enabled during precision pick/place or probing sequences. WARNING

4.4 Timing & Blending Rules

Rule Identifier Checker Service Description Severity
TIMING_DWELL_EXCESSIVE TimingDwellValidator Single WAIT command exceeds 60,000 ms (1 minute), likely an error. WARNING
TIMING_BLEND_COLLISION TimingBlendZoneValidator Corner blend zone radius is larger than the motion segment distance. ERROR

5. Complete Industrial Example Scripts

5.1 High-Speed Pick and Place with Matrix Pallet

# ------------------------------------------------------------------
# Industrial Palletizing Routine: Pick from Feeder, Place into Tray
# ------------------------------------------------------------------
CONFIG ELBOW LEFT
CONFIG MOTOR CLOSED_LOOP

SPEED RAPID 220.0
SPEED WORK 80.0
ACCEL 600.0
OVERRIDE 100

# 1. Calibrate reference home
HOME

# 2. Define a 3x4 Component Tray Matrix
PALLET_DEF TRAY_OUT ROWS 3 COLS 4 DX 30.0 DY 30.0 Z 10.0

# 3. Position above component feeder station
MOVE_J X 120.0 Y -60.0 Z 40.0
APPROACH DIST 35.0

# 4. Grip first component
PUMP ON
WAIT 150
RETRACT DIST 35.0

# 5. High-speed parabolic arch transfer to Pallet Slot #1
JUMP X 180.0 Y 50.0 Z 10.0 ARCH 30.0

# 6. Release component
PUMP OFF
VALVE ON
WAIT 60
VALVE OFF

# 7. Move directly to Pallet Slot #2 for second cycle
MOVE_PALLET TRAY_OUT INDEX 2
APPROACH DIST 10.0

5.2 Circular Profiling with Tool Tangency

# ------------------------------------------------------------------
# Continuous Circular Gasket Dispensing with Tangential Tool Yaw
# ------------------------------------------------------------------
SPEED RAPID 180.0
SPEED WORK 50.0
ACCEL 400.0

HOME
ZONE Z5
TOOL_ORIENT TANGENT

# Approach starting contour point
MOVE_J X 150.0 Y 0.0 Z 25.0
MOVE_L X 150.0 Y 0.0 Z 5.0

# Dispenser ON
TOOL DOWN
WAIT 50

# Continuous circular toolpath (R=40mm)
ARC_CW X 190.0 Y 40.0 I 0.0 J 40.0
ARC_CW X 230.0 Y 0.0 I 0.0 J -40.0
ARC_CW X 190.0 Y -40.0 I -40.0 J 0.0
ARC_CW X 150.0 Y 0.0 I 0.0 J 40.0

# Dispenser OFF
ZONE EXACT
TOOL UP
RETRACT DIST 30.0

5.3 Surface Probing and Adhesive Dispensing

# ------------------------------------------------------------------
# PCB Height Surface Probing and Touch-Off
# ------------------------------------------------------------------
CONFIG ELBOW RIGHT
SPEED RAPID 150.0
SPEED WORK 30.0

HOME

# Move above PCB test pad
MOVE_J X 140.0 Y 20.0 Z 35.0

# Search for PCB top plane at controlled velocity
PROBE SPEED 5.0 DIST 30.0

# Set Work Coordinate System relative to probed surface
FRAME X 140.0 Y 20.0 Z 0.0

# Dispense micro-dot exactly 0.5 mm above probed surface
MOVE_L X 0.0 Y 0.0 Z 0.5
TOOL DOWN
WAIT 100
TOOL UP
RETRACT DIST 20.0
FRAME_RESET