Skip to content

RoboticArm CSV import/export fails for arms with fewer than 4 servos #288

Description

@thisisanubhav

RoboticArm.export_timeline_to_csv always writes a four-servo header, but each row only has as many values as the arm has servos. import_timeline_from_csv always returns four angles per timestep, but run_schedule requires exactly one per servo. As a result, neither direction works for an arm with 1–3 servos.

pwm = MagicMock()
arm = RoboticArm([Servo("SQ1", pwm), Servo("SQ2", pwm)])
arm.export_timeline_to_csv([[10, 20], [30, None]], "out")

The exported file has short rows:

Timestep,Servo1,Servo2,Servo3,Servo4
0,10,20
1,30,null
  • Importing that file raises TypeError: int() argument must be ... not 'NoneType' because row["Servo3"] is None.
  • Importing a complete four-column file (0,10,20,null,null) returns [[10, 20, None, None]], and arm.run_schedule(...) then raises ValueError: Each timestep must specify an angle for every servo.

Expected: a timeline exported from an arm can be imported by that same arm and run. Suggested fix: the export pads rows with null up to four servos, keeping the four-column format; the import returns one angle per servo on the arm and rejects a file that sets an angle for a servo the arm doesn't have.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions