Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Juan-Carlos-Cruz/robotaxi-zoox/llms.txt
Use this file to discover all available pages before exploring further.
leer_mapa reads a space-separated integer text file and returns a list-of-lists matrix ready to pass to Grid. It is the standard entry point for loading any of the project’s map files and handles all I/O concerns — path resolution, encoding, empty-line skipping, and error reporting — so calling code never has to open files directly. When no path is given, leer_mapa defaults to mapas/test/Prueba1.txt relative to the project root.
Function signature
leer_mapa(ruta=None)
Reads the file at ruta, parses every non-empty line as a row of whitespace-separated integers, and returns the resulting matrix. All errors are caught internally and reported to stdout; the function never raises.
Path to the
.txt map file to load. Accepts a plain string, a
pathlib.Path object, or None. When None, the function resolves the
default map path automatically — see Behavior details
below.A 2D list of integers where each inner list corresponds to one row of the
map. Returns
None if the file is not found, contains no parseable rows,
or any other error occurs during reading.Behavior details
Default path resolution. Whenruta is None, the function calls the private helper _ruta_mapa_predeterminada(), which constructs an absolute path by resolving the project root (RUTA_PROYECTO) at import time and appending mapas/test/Prueba1.txt. This means the default path is always correct regardless of the working directory from which the script is run.
Empty-line handling. Each line is stripped of leading and trailing whitespace before processing. Lines that are empty after stripping are silently skipped, so map files may contain blank separator lines without causing errors.
Integer conversion. Each non-empty line is split on whitespace and every token is converted with int(). The cell-type integers correspond directly to the constants on Grid (0–5).
Error handling. Two error conditions are caught:
FileNotFoundError— printsError: No se encontró el archivo <path>to stdout and returnsNone.- Any other exception during parsing — prints
Error al leer archivo: <error>to stdout and returnsNone.
None rather than an empty list.
Examples
Private helper
_ruta_mapa_predeterminada()
Builds the absolute Path object for the default map file. It is called automatically by leer_mapa when ruta=None and is not part of the public API — do not call it directly from application code.
Absolute path to
<project_root>/mapas/test/Prueba1.txt, where
project_root is resolved relative to the map_loader.py source file at
import time using Path(__file__).resolve().parents[2].RUTA_PROYECTO (the project root constant used by _ruta_mapa_predeterminada)
is resolved once when the mundo.io module is first imported. If you move
the source tree after import, the cached path will not update. In tests or
scripts that manipulate the file system, always pass an explicit ruta
argument to leer_mapa rather than relying on the default.