PolygonMapLayer - use it to define some area, but not for restriction purpose

Hello, we want to define some polygon area, so robot would walk inside it. Using map editor polygon layer was added, but it’s not being show on the map view. New layer is present as component in configs and displayed in Websight as a part of the map, but only polygons that are shown on the map is for restricted area.
How can i correctly define it for my purpose?
I need to:

  1. Define polygon which further will be shown in Websight
  2. Make robot walk around in that area ( Already developed codelet which creates goals inside polygon area )

Another related question - is there any API to get polygon defined in json config from C++ Codelet? I mean from map part in which it’s usually defined, as currently i added param which accepts vector of points.

P.S. i tried to use flatsim demo_1 to check it on map provided with SDK.

    "test": {
  "color": [
    255,
    0,
    0
  ],
  "execution_queue_limit": 1,
  "frame": "world",
  "obstacle_max_distance": 1.5,
  "obstacle_pixel_size": 0.1,
  "polygons": {
    "poly8348693694232041": {
      "points": [
        [
          23.400000000000002,
          10.100000000000001
        ],
        [
          22.700000000000003,
          11.4
        ],
        [
          23.200000000000003,
          12.8
        ],
        [
          24.1,
          13.700000000000001
        ],
        [
          25.1,
          13.5
        ],
        [
          25.400000000000002,
          12.3
        ],
        [
          25.3,
          10.9
        ],
        [
          24.200000000000003,
          9.9
        ],
        [
          22.5,
          11.100000000000001
        ]
      ]
    }
  }
}


    {
      "name": "test",
      "type": "isaac::map::PolygonMapLayer"
    }

this 2 blocks were added in config and graph accordingly.

Hi,

From your post above it seems you are using correctly the map_editor as it generates a valid config.
But for completeness let me list all the steps that need to be done:

  • Run the map_editor:
  bazel run apps/map_editor -- --config apps/assets/maps/some_map.config.json 
                               --graph apps/assets/maps/some_map.graph.json 
                               --config_backup /tmp/new_config.json
  • Copy your new layer config in the original config file (if you did not override the original one). Feel free to renmane the polygon’s name.
"map": {
    ...
    "restricted_area": {
      ...,
      "polygons": { ... }
    },
    "test": {
      ...,
      "polygons": { ... }
    }
}
  • Update the original graph.json file, if you open it, you will see that the restricted_area layer is defined:
{
  "name": "restricted_area",
  "type": "isaac::map::PolygonMapLayer"
},
{
  "name": "test",
  "type": "isaac::map::PolygonMapLayer"
}
  • Enable visualization:
    -Either from sigth directly: you can look for the layer name (“test” in your example) in the left panel Channels, and right click on “polygons” and add to the view you want)
    -You can modify the config directly (look at the example flatsim demo_5 if you want an example)

I think you were missing the last step (adding the new layer to the xxxx.graph.json file.

Concerning your second question:

  • You can first get the PolygonMapLayer:
  auto* polygon_layer =
      node()->app()->findComponentByName<PolygonMapLayer>(get_polygon_layer_name());

or using the Map codelet interface:

  auto* polygon_layer = map->getLayer<PolygonMapLayer>(get_polygon_layer_name());
  • Then you can use the PolygonMapLayer API to access the polygons:
  // Finds a named polygon
  std::optional<geometry::Polygon2D> findByName(const std::string& name) const;

  // Returns the list of all polygons
  std::vector<std::pair<std::string, geometry::Polygon2D>> polygons() const;

I hope this is helping, please let me know if you have any other issue.

Regards,
Ben