traj2csv.py

Trajectory to Speed Converter

Features

  • Converts high-level trajectory commands to speed sequences

  • Supports coordinated multi-servo movements

  • Three movement profiles:

    • Linear (l): Constant acceleration

    • Smooth (s): Sinusoidal acceleration

    • Pulse (p): Instant change

  • Maintains servo state between commands

  • Comment support in trajectory files

Usage

python traj2csv.py INPUT.traj -o OUTPUT.csv

Trajectory Command Syntax

[CMD] [SERVOS] [VALUES] [DURATION_MS] [PROFILE]
  • CMD: Movement type (mov or rot)

  • SERVOS: Comma-separated servo IDs (e.g., x0,x2,x5)

  • VALUES: Comma-separated target speeds (-100 to 100)

  • DURATION_MS: Movement duration (ms)

  • PROFILE: l (linear), s (smooth), or p (pulse)

Example Trajectory File

// Simultaneous movement with different profiles
mov x0,x1,x2 50,-30,80 2000 s
rot x5 100 500 p
mov all 0,0,0,0,0,0 1000 l

Output CSV Format

S1,S2,S3,S4,S5,S6
0.00,0.00,0.00,0.00,0.00,0.00
50.00,-30.00,80.00,0.00,0.00,0.00
...

Comparison Table

Feature

speed2csv.py

traj2csv.py

Command Type

Single movement

Multi-command sequence

Servo Coordination

Independent control

Coordinated movements

Profile Support

Per-servo profiles

Per-command profiles

Best For

Simple speed sequences

Complex trajectories

Input Format

Command-line args

Trajectory file

Output Resolution

20ms fixed

20ms fixed


Common Requirements

  • Python 3.6+

  • Required Libraries:

    pip install argparse csv-time
    
  • CSV Compatibility:

    • Both generators create files compatible with the robot arm controller

    • Each row = 20ms of movement

    • Columns 1-6 = Servo 0-5 speeds (-100.00 to 100.00)


Execution Flow

  1. Generate CSV using either tool:

    # Simple movement
    python speed2csv.py -s "100s 0 0 0 0 0" -t 1000 -o move.csv
    
    # Complex trajectory
    python traj2csv.py advanced.traj -o sequence.csv
    
  2. Run on robot arm:

    python arm_controller.py sequence.csv
    

Note: Use --dry-run flag with the controller to validate CSVs without hardware movement