Giter VIP home page Giter VIP logo

Comments (10)

stonier avatar stonier commented on May 14, 2024

We have a function in the cost_map library (based on this one, but has char based grids instead of double) which does this...here. There's an active PR on that too looking to improve it a bit.

At any rate, it could very easily be templatised to handle grid_map and cost_map objects together I think.

from grid_map.

skohlbr avatar skohlbr commented on May 14, 2024

Thanks for the link @stonier! I made my own small converter by pulling out some code from navigation, converting from CostMap2D to nav_msgs/OccupancyGrid and then just using the conversion to GridMap. Not terribly efficient, but gets the job done: https://github.com/tu-darmstadt-ros-pkg/grid_map_navigation_planner/blob/master/grid_map_planner_nav_plugin/include/grid_map_planner_nav_plugin/grid_map_cost_map_2d_conversion.h#L71

from grid_map.

stonier avatar stonier commented on May 14, 2024

Oh, two step. Bit expensive, but it should work.

Good to have this issue here. I've been a bit delayed getting my cost map revamped (has to wait until I get back from interview travels), but this would be a good function to get into the core for both cost_map and grid_map.

from grid_map.

pfankhauser avatar pfankhauser commented on May 14, 2024

Thanks @skohlbr and @stonier for your input! I added a quick implementation of a Costmap2D to Grid Map in the feature/costmap_conversion branch.

  • The class Costmap2DConverter provides two methods
    1. First one has to initialize a new grid map with initializeFromCostmap2d to adapt to the geometry of the costmap.
    2. Then, data from the costmap can be copied to a layer of the grid map with addLayerFromCostmap2d.
  • Direct conversion from Costmap2d to Grid Map, no intermediate steps.
  • Templated on MapType, so can be used by Grid Map derivatives as well.
  • Unit tests here.

Please let me know if this works for you or if you have any suggestions. Thanks!

from grid_map.

pfankhauser avatar pfankhauser commented on May 14, 2024

Update: I used the cost translation table as suggested by @skohlbr and added him as an author, please let me know if this is not ok.

from grid_map.

skohlbr avatar skohlbr commented on May 14, 2024

Fine with me, but full disclosure: I extracted and modified that code from costmap_2d_publisher (the cost translation table is a static char* cost_translation_table_ there).

from grid_map.

pfankhauser avatar pfankhauser commented on May 14, 2024

@skohlbr Ok great, were you able to check if the new conversion feature in branch feature/costmap_conversion works for your use case?

from grid_map.

skohlbr avatar skohlbr commented on May 14, 2024

Not yet, but will do next week.

from grid_map.

stonier avatar stonier commented on May 14, 2024

We've been refining what we do with Costmap2DROS conversions into cost maps - details here. Basically the use case we were interested in supporting is the ability to catch a subwindow of the cost map around the ros pose. @skohlbr is this a use case you were looking for as well?

This required us to be a little more careful (i.e. catch a few bugs) to make sure we don't introduce errors by having the resulting cost map not exactly aligning with the underlying ros costmap - it is not as straight forward as just setting the cost map centre to the robot pose position.

Anyway, seems to be working now and we have a battery of tests catching the different permutations. @pfankhauser it looks like something I could easily template in the style you made in the PR so we could use it for both cost map and grid map converters, just with different policies applied (e.g. direct value cast, or normalising from 0 to 100.0 or similar).

from grid_map.

pfankhauser avatar pfankhauser commented on May 14, 2024

Solved by #78.

from grid_map.

Related Issues (20)

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.