Giter Site home page Giter Site logo

pymap2d's Introduction

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

pymap2d's People

Contributors

danieldugas avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.