Virtual Stick light painting for x-mas (Xcode 12, Swift 5, SDK 4.14)
510 0 2020-12-20
Uploading and Loding Picture ...(0/1)
o(^-^)o
hdrpano
lvl.4
Flight distance : 598458 ft
  • >>>
Switzerland
Offline

I added a GPS star mission for light painting and virtual stich in my DJI iOS advanced 4.14 sample.

We can add a GPS star with an individual radius and with x edges.



If the star has 5 edges we add 10 points.

  //MARK:- GPS Star Mission
  func star(radius: Double, points: Int, latitude: Double, longitude: Double, altitude: Double) -> [[Double]] {
        var grid: Array = [[Double]]()
        var coor: CLLocationCoordinate2D
        var angle: Float = 0
        let R: Double = 6371000
        for z in 0..<points {
            angle = 360 / Float(points) * Float(z)
            angle = yawControl(yaw: angle) // for +/- 180°
            if z % 2 == 0 {
                coor = self.newCoor(latitude: latitude, longitude: longitude, distance: radius, bearing: angle, radiusM: R)
            } else {
                coor = self.newCoor(latitude: latitude, longitude: longitude, distance: radius/2, bearing: angle, radiusM: R)
            }
            
            if z == 0 {
                grid = [[Double(coor.latitude), Double(coor.longitude), altitude]]
            } else {
                grid.append([Double(coor.latitude), Double(coor.longitude), altitude])
            }
        }
        
        coor = self.newCoor(latitude: latitude, longitude: longitude, distance: radius, bearing: 0, radiusM: R)
        grid.append([Double(coor.latitude), Double(coor.longitude), altitude])
        
        return grid
    }

   //MARK:- GPS Lat
   func latm(latitude: Double, distance: Double, bearing: Float, radiusM: Double = 6371000) -> Double {
       let dr: Double = .pi / 180.0
       let rd: Double = 180.0 / .pi
       return asin(sin(latitude*dr) * cos(distance/radiusM) + cos(latitude*dr) * sin(distance/radiusM) * cos(Double(bearing)*dr)) * rd
   }
   
   //MARK:- GPS Lon
   func lonm(latitude: Double, longitude: Double, latitudeM: Double, distance: Double, bearing: Float, radiusM: Double = 6371000) -> Double {
       let dr: Double = .pi / 180.0
       let rd: Double = 180.0 / .pi
       return longitude + atan2(sin(Double(bearing)*dr) * sin(distance/radiusM) * cos(latitude*dr), cos(distance/radiusM) - sin(latitude*dr) * sin(latitudeM*dr)) * rd
   }
   
   //MARK:- GPS New Coordinate
   func newCoor(latitude: Double, longitude: Double, distance: Double, bearing: Float, radiusM: Double = 6371000) -> CLLocationCoordinate2D {
       let latitudeM: Double = self.latm(latitude: latitude, distance: distance, bearing: bearing, radiusM: radiusM)
       let longitudeM: Double = self.lonm(latitude: latitude, longitude: longitude, latitudeM: latitudeM, distance: distance, bearing: bearing, radiusM: radiusM)
       return CLLocationCoordinate2DMake(latitudeM, longitudeM)
   }

Use the front LED to swith on and off your additional light for the painting

    //MARK:- Front LEDs On Off
    func frontLed(frontLEDs: Bool) {
        let FC = self.fetchFlightController()
        if FC != nil {
            let led: DJIMutableFlightControllerLEDsSettings = DJIMutableFlightControllerLEDsSettings.init()
            led.frontLEDsOn = frontLEDs
            FC?.setLEDsEnabledSettings(led, withCompletion: { (error: Error?) in
                if error != nil {
                    NSLog("Error set front Led \(frontLEDs)")
                } else {
                    NSLog("Set front Led \(frontLEDs)")
                }
            })
        }
    }

2020-12-20
Use props
Advanced
You need to log in before you can reply Login | Register now

Credit Rules