Skip to main content

pymap2d

pymap2d is a Cython-based fast toolbox for 2d grid maps.

The CMap2D class provides:

  • simple xy <-> ij coordinate conversions
  • implementation of the dijkstra / fastmarch algorithm
  • fast 2D distance transform (ESDF)
  • conversions:
    • to/from polygon vertices
    • from ROS occupancy map or lidar scan message
    • serialization to/from dict

pymap2d

Note: rather than carefully designed, this codebase was chaotically grown. It is in dire need of refactoring / documentation. I hope it still proves useful.

Dependency: Cython

$ pip install numpy Cython

Installation:

Inside this project root folder:

$ pip install pymap2d

How to

Creating a map

from CMap2D import CMap2D

# empty map
mymap = CMap2D()

# from an array
mymap.from_array(array, origin, resolution)

# from a pgm file
mymap = CMap2D("folder", "filename")

# from a ROS message
mymap.from_msg(msg)

Accessing occupancy data, origin, resolution (read-only)

# occupancy as 2d array
mymap.occupancy()

# origin: (x, y) coordinates of point (i, j) = (0, 0)
mymap.origin_xy()

# resolution: size of grid cell [meters]
mymap.resolution()

Converting between grid and spatial coordinates

list_of_xy_points = np.array([[1.3, 2.3], [-1.1, -4.0], [6.4, 2.3]])

in_ij_coordinates = mymap.xy_to_floatij(list_of_xy_points)
as_indices = mymap.xy_to_ij(list_of_xy_points, clip_if_outside=True)

gridshow is a convenience function, which wraps plt.imshow to intuitively visualize 2d array contents. It makes the first array dimension x axis and uses grayscale by default.

from CMap2D import gridshow
gridshow(mymap.occupancy())

gridshow_vs_imshow

For more examples, see test/example_*.py

Release files for pymap2d 0.1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymap2d 0.1.15
File Size Uploaded
pymap2d-0.1.15.tar.gz 350.9 kB Details

Release files / pymap2d-0.1.15.tar.gz

Download URL pymap2d-0.1.15.tar.gz
Size 350.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a159167c0e8544c15d90d3c2667fabd85cc6a476daf3af436c8b9f507039227d
BLAKE2b-256 checksum
How to use checksums
f9e6642cd3513b61537010feb51b78aa8578454097e3b75ce5b3527762a8d916
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.5.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.1.15 This release

1 release file

0.1.14

1 release file

0.1.12

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page