Skip to content

MissionRaw's takeoff doesn't take off. #232

@fumiaki09

Description

@fumiaki09

System Requirements

  • WLS2 Ubuntu22.04 Ardupilot SITL
  • mavsdk = "3.12.0"

Launch with the following command

$ sim_vehicle.py --map --console

The mission itself is sending the following code.

fun uploadMission() {

        val missionRaw: MutableList<MissionRaw.MissionItem> = mutableListOf()
        var seq = 0

        // Takeoff (The very first command disappears.)
        missionRaw.add(
            MissionRaw.MissionItem(
                seq++,
                3, // MAV_FRAME_GLOBAL_RELATIVE_ALT
                22, // MAV_CMD_NAV_WAYPOINT
                0,  // current
                1,  // autocontinue
                0f, // param1
                0f, // param2
                0f, // param3
                0f, // param4
                0,
                0,
                10f, // alt
                0   // mission_type
            )
        )

        // Takeoff
        missionRaw.add(
            MissionRaw.MissionItem(
                seq++,
                3, // MAV_FRAME_GLOBAL_RELATIVE_ALT
                22, // MAV_CMD_TAKEOFF
                1,  // current
                1,  // autocontinue
                0f, // param1
                0f, // param2
                0f, // param3
                0f, // param4
                0,
                0,
                10f, // alt
                0   // mission_type
            )
        )

        // WP
        missionRaw.add(
            MissionRaw.MissionItem(
                seq++,
                3,
                16, //WP
                0,
                1,
                0f,
                0f,
                0f,
                0f,
                (-35.36285619 * 1E7).toInt(),
                (149.16553477* 1E7).toInt(),
                50f,
                0
            )
        )

        // RTL
        missionRaw.add(
            MissionRaw.MissionItem(
                seq++,
                3,
                20, //RTL
                0,
                1,
                0f,
                0f,
                0f,
                0f,
                0,
                0,
                0f,
                0
            )
        )

        viewModelScope.launch(Dispatchers.IO) {
            droneRepository.runWithDrone { drone ->
                try {
                    drone.missionRaw.uploadMission(missionRaw).await()
                    println("uploaded mission")
                } catch (e: Exception) {
                    println("upload failed")
                }
            }
        }
    }

You can start the mission with the following code.

fun missionStart() {
        viewModelScope.launch(Dispatchers.IO) {
            try {
                droneRepository.runWithDrone { drone ->
                    drone.action.arm().await()
                    delay(2000)
                    drone.action.setTakeoffAltitude(5f).await()
                    drone.action.takeoff().await()
                    drone.mission.startMission().await()
                }
            } catch (e: Exception) {
                e.printStackTrace()
            }
        }
    }
}

Why can't the mission takeoff command execute in the following code that removed takeoff?

fun missionStart() {
        viewModelScope.launch(Dispatchers.IO) {
            try {
                droneRepository.runWithDrone { drone ->
                    drone.action.arm().await()
                    delay(2000)
                    drone.mission.startMission().await()
                }
            } catch (e: Exception) {
                e.printStackTrace()
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions