Android Question DJI Hotspot Mission

shb777

Active Member
Licensed User
Longtime User
In the example video, you execute a hotspot mission, but in your two example programs, I don't see the code for a hotspot mission. Steve
 

DonManfred

Expert
Licensed User
Longtime User
I don't see the code for a hotspot mission

DJI Drones

Check the examples again. It is in the download DroneMission.zip

Part of code

B4X:
Sub btnStartMission_Click
    Dim builder As DJIWaypointMissionBuilder
    builder.Initialize
    builder.AutoFlightSpeed = 10
    builder.MaxFlightSpeed = 15
    builder.AddWaypoint(CreateWaypoint(32.8373372, 35.26967794, 40))
    Dim wp As DJIWaypoint = CreateWaypoint(32.83850007, 35.26828855, 30)
    wp.AddAction("STAY", 3000)
    wp.AddAction("GIMBAL_PITCH", -90)
    wp.AddAction("START_TAKE_PHOTO", 0)
    builder.AddWaypoint(wp)
    wp = CreateWaypoint(32.83772032, 35.26845485, 30)
    wp.AddAction("GIMBAL_PITCH", 0)
    wp.AddAction("START_RECORD", 0)
    builder.AddWaypoint(wp)
    wp = CreateWaypoint(32.83707127, 35.26887327, 30)
    wp.AddAction("STOP_RECORD", 0)
    builder.AddWaypoint(wp)
    builder.SetFinishAction("GO_FIRST_WAYPOINT")
    WaypointOperator.LoadMission(builder)
    Wait For (WaypointOperator.UploadMission) WaypointOperator_Result (Success As Boolean, ErrorMessage As String)
    If Success Then
        Sleep(1000) '<--- required. Otherwise it will fail
        Wait For (WaypointOperator.StartMission) WaypointOperator_Result (Success As Boolean, ErrorMessage As String)
        Log("Start: " & Success & ", " & ErrorMessage)
        MissionState(True)
    Else
        Log("Error uploading: " & ErrorMessage)
        ToastMessageShow("Error uploading: " & ErrorMessage, True)
    End If
End Sub

Sub CreateWaypoint(Lat As Double, Lon As Double, Altitude As Float) As DJIWaypoint
    Dim wp As DJIWaypoint
    wp.Initialize(Lat, Lon, Altitude)
    Return wp
End Sub

Sub WaypointOperator_MissionStart
    MissionStatus = "MissionStart"
End Sub

Sub WaypointOperator_MissionFinish (Error As String)
    MissionStatus = "MissionFinish: " & Error
    MissionState(False)
End Sub

Sub MissionState(Running As Boolean)
    btnStartMission.Enabled = Not(Running)
    btnStopMission.Enabled = Running
End Sub

Sub WaypointOperator_MissionProgress (ExecutionEvent As Object, TargetWaypointIndex As Int)
    MissionStatus = "Flying to: " & TargetWaypointIndex
End Sub


Sub btnStopMission_Click
    Wait For (WaypointOperator.StopMission) WaypointOperator_Result (Success As Boolean, ErrorMessage As String)
    If Success = False Then
        ToastMessageShow("Failed to stop", True)
    Else
        MissionStatus = "Mission stopped"
        MissionState(False)
    End If
End Sub
 
Last edited:
Upvote 0

shb777

Active Member
Licensed User
Longtime User
OK so you never implemented a hotspot mission, even though it's in the youtube video. So it would have to be done with a Javaobject. Steve
 
Upvote 0
Top