OccupancyGrid.fromJson constructor

OccupancyGrid.fromJson(
  1. Map<String, dynamic> response
)

Implementation

factory OccupancyGrid.fromJson(Map<String, dynamic> response) {
  List<dynamic> dataDynamicList = response["data"];
  List<int> dataIntList = dataDynamicList.map<int>((item) => item as int).toList();

  return OccupancyGrid(
    header: Header(
      frameId: response["header"]["frame_id"],
      stamp: Stamp(
        nanosec: response["header"]["stamp"]["nanosec"],
        sec: response["header"]["stamp"]["sec"],
      ),
    ),
    mapMetaData: MapMetaData(
      resolution: response["info"]["resolution"],
      width: response["info"]["width"],
      height: response["info"]["height"],
      origin: Pose(
        position: Position(
          x: response["info"]["origin"]["position"]["x"],
          y: response["info"]["origin"]["position"]["y"],
          z: response["info"]["origin"]["position"]["z"],
        ),
        orientation: Orientation(
          x: response["info"]["origin"]["orientation"]["x"],
          y: response["info"]["origin"]["orientation"]["y"],
          z: response["info"]["origin"]["orientation"]["z"],
          w: response["info"]["origin"]["orientation"]["w"],
        ),
      ),
    ),
    data: dataIntList,
  );
}