Esempio n. 1
0
 def on_elevation_map(self, msg: ElevationMap):
     with self.op_lock:
         rospy.loginfo("Elevation map received")
         decoded = serialization.geodata_from_raster_msg(msg.raster, layer="elevation")
         rospy.logwarn("Ignoring data from ElevationMap message. Using flat terrain")
         decoded.data["elevation"][...] = 0.
         self.op.logger.info("%s", str(decoded))
         self.op.set_elevation(decoded)
    def _on_wildfire_map_observed(self, msg: WildfireMap, uav: str):
        with self.sa_lock:
            local_firemap = serialization.geodata_from_raster_msg(msg.raster, "ignition")
            g = GeoDataDisplay.pyplot_figure(local_firemap)
            g.draw_ignition_shade(with_colorbar=True)
            g.figure.savefig("local_firemap_" + str(uav) + ".png")
            g.close()
            del g
            rospy.loginfo("Local wildfire map received from %s", str(uav))

            for cell in zip(*np.where(local_firemap.data["ignition"] < np.inf)):
                self.sa.observed_wildfire.set_cell_ignition(
                    (*cell, local_firemap["ignition"][cell]))
Esempio n. 3
0
    def on_wildifre_prediction(self, msg: PredictedWildfireMap):
        def create_drawable_contour(f_map: geo_data.GeoData,
                                    time_sec: float,
                                    color: ty.Tuple[int, int, int],
                                    one_out_of: int = 1):
            cur_perimeter = _compute_perimeter(firemap, time_sec)
            count = 0
            if cur_perimeter[1]:  # cells
                coor_tran = geo_data.CoordinateTransformation(
                    firemap.projection_epsg, geo_data.EPSG_WGS84)
                polygon = []
                for cell in cur_perimeter[2][0]:
                    if count % one_out_of:
                        continue
                    if not np.isnan(cell[0]) and not np.isnan(cell[1]):
                        pcs_point = firemap.coordinates(cell)
                        gcs_point = coor_tran.transform(*pcs_point)
                        polygon.append({
                            "lat": gcs_point[1],
                            "lon": gcs_point[0]
                        })
            if polygon:
                return {"time": time_sec, "color": color, "polygon": polygon}

        firemap = serialization.geodata_from_raster_msg(msg.raster, "ignition")
        oof = 2
        rospy.loginfo("Sending to Neptus %s out of %s point in contours",
                      str(1), str(oof))
        # Colors from bright red to white, varying saturation: (255, x, x)
        desired_contours = [(rospy.Time.now().to_sec(), (255, 0, 0)),
                            (rospy.Time.now().to_sec() + 1800, (255, 85, 85)),
                            (rospy.Time.now().to_sec() + 3600, (255, 170, 170))
                            ]
        drawable_conts = []
        for d in desired_contours:
            d_cont = create_drawable_contour(firemap, d[0], d[1], oof)
            if d_cont:
                drawable_conts.append(d_cont)

        self.ccu.send_wildfire_contours(*drawable_conts)
Esempio n. 4
0
 def on_wildfire_map_observed(self, uav: str,
                              wildfire_map_observed_msg: WildfireMap):
     gd = serialization.geodata_from_raster_msg(
         wildfire_map_observed_msg.raster, "ignition", invert=True)
     self.wildfire_map_observed.data = gd
Esempio n. 5
0
 def on_wildfire_map(self, wildfire_map_msg: WildfireMap):
     self.wildfire_map.data = serialization.geodata_from_raster_msg(
         wildfire_map_msg.raster, "ignition")
Esempio n. 6
0
 def on_wildfire_map_predicted(self,
                               wildfire_map_msg: PredictedWildfireMap):
     self.wildfire_map_predicted.data = serialization.geodata_from_raster_msg(
         wildfire_map_msg.raster, "ignition")
Esempio n. 7
0
 def on_elevation_map(self, elevation_map_msg: ElevationMap):
     self.elevation_map.data = serialization.geodata_from_raster_msg(
         elevation_map_msg.raster, "elevation")
Esempio n. 8
0
 def on_wildfire_prediction(self, msg: PredictedWildfireMap):
     with self.op_lock:
         rospy.loginfo("Predicted wildfire map received")
         self.op.set_wildfire_map(serialization.geodata_from_raster_msg(
             msg.raster, layer="ignition"))
Esempio n. 9
0
 def _on_real_wildfire_map(self, wildfire: WildfireMap):
     self.real_wildfire_map = serialization.geodata_from_raster_msg(wildfire.raster, "ignition")
     rospy.loginfo("Real wildfire received")
     rospy.loginfo(wildfire.raster.metadata)
     self._reset_firemapper()
Esempio n. 10
0
 def _on_elevation_map(self, elevation: ElevationMap):
     self.elevation_map = serialization.geodata_from_raster_msg(elevation.raster, "elevation")
     rospy.loginfo("Elevation received")
     rospy.loginfo(elevation.raster.metadata)
     self._reset_firemapper()