dronefleet / mavlink

A Java API for MAVLink communication
MIT License
110 stars 67 forks source link

Mission Upload #45

Closed tunahanbulut closed 4 years ago

tunahanbulut commented 4 years ago

Hi, I am trying to upload a mission to a simulated drone with your great library. While doing this, I followed the instructions under mavlink.io/services/mission. But I continuously getting time out error from the drone side. I think the reason for this initially I send drone mission_count message with value 4 and waiting for mission_request_messages with seq number in a range of 1...4/0...3. But I get a seq number like 123, 196, etc. Thus I do not send responses and get time out error. My work environment build-up from the following components;

...
if(message.getPayload() instanceof MissionAck){
        MavlinkMessage<MissionAck> missionAck = (MavlinkMessage<MissionAck>)message;
        System.out.println("This is a missionAck message with following values: \n" + missionAck.toString());
        if(missionAck.getPayload().type().entry().equals(MavMissionResult.MAV_MISSION_ACCEPTED)){
                missionUploadFinished = true;
         }
}
...
while(!missionUploadFinished){
            if(requestedMissionItem != transmittedMissionItem){
                 MissionItem missionItem = MissionItem.builder()
                        .targetSystem(1)
                        .targetComponent(1)
                        .seq(requestedMissionItem)
                        .frame(MavFrame.MAV_FRAME_GLOBAL)
                        .command(MavCmd.MAV_CMD_NAV_WAYPOINT)
                        .current(0)
                        .autocontinue(1)
                        .param1(0)
                        .param2(0)
                        .param3(0)
                        .param4(10)
                        .x(waypointList[requestedMissionItem][0])
                        .y(waypointList[requestedMissionItem][1])
                        .z(waypointList[requestedMissionItem][2])
                        .missionType(MavMissionType.MAV_MISSION_TYPE_MISSION)
                        .build();
                transmittedMissionItem = requestedMissionItem;
                // Write an message to drone
                connection.send2(systemId, componentId, missionItem);
                System.out.println("Seq: " + requestedMissionItem + ", Message Send: " + MavCmd.MAV_CMD_NAV_WAYPOINT.name());
            }
}
...