LEGO EV3 – Tank Bot and evil Python error :)

So, eventually, we have built Tank Bot according to the manual.

Once everything was set up inside VS Code

it turned out our Tank Bot doesn’t work as expected. All it was doing was producing an error:

Traceback (most recent call last):
  File "/home/robot/tank_bot/", line 28, in <module>
OSError: [Errno 19] ENODEV:

A sensor or motor is not connected to the specified port:
--> Check the cables to each motor and sensor.
--> Check the port settings in your script.
--> Check the line in your script that matches
    the line number given in the 'Traceback' above.

It turned out that there is a misalignment between ports being used inside building instructions and the Python code. After correcting the alignment

left_motor = Motor(Port.B, Direction.COUNTERCLOCKWISE)
right_motor = Motor(Port.D, Direction.COUNTERCLOCKWISE)

everything worked like a charm.