@@ -102,7 +102,8 @@ local function MAVLinkProcessor()
102102 COMMAND_INT = 75 ,
103103 HIGH_LATENCY2 = 235 ,
104104 MISSION_ITEM_INT = 73 ,
105- SET_MODE = 11
105+ SET_MODE = 11 ,
106+ MISSION_SET_CURRENT = 41
106107 }
107108
108109 -- private fields
@@ -121,6 +122,7 @@ local function MAVLinkProcessor()
121122 _crc_extra [235 ] = 0xb3
122123 _crc_extra [73 ] = 0x26
123124 _crc_extra [11 ] = 0x59
125+ _crc_extra [41 ] = 0x1c
124126
125127 local _messages = {}
126128 _messages [75 ] = { -- COMMAND_INT
@@ -156,6 +158,9 @@ local function MAVLinkProcessor()
156158 _messages [11 ] = { -- SET_MODE
157159 { " custom_mode" , " <I4" }, { " target_system" , " <B" }, { " base_mode" , " <B" },
158160 }
161+ _messages [41 ] = { -- MISSION_SET_CURRENT
162+ { " seq" , " <I2" }, { " target_system" , " <B" }, { " target_component" , " <B" },
163+ }
159164 function self .getSeqID () return _txseqid end
160165
161166 function self .generateCRC (buffer )
@@ -269,53 +274,25 @@ local function MAVLinkProcessor()
269274 end
270275 elseif _mavresult .msgid == self .SET_MODE then
271276 vehicle :set_mode (_mavresult .custom_mode )
272- elseif _mavresult .msgid == self .COMMAND_LONG or _mavresult .msgid ==
273- self .COMMAND_INT then
274- if _mavresult .command == 400 then -- MAV_CMD_COMPONENT_ARM_DISARM
275- if _mavresult .param1 == 1 then
276- arming :arm ()
277- elseif _mavresult .param1 == 0 then
278- arming :disarm ()
279- end
280- elseif _mavresult .command == 176 then -- MAV_CMD_DO_SET_MODE
281- vehicle :set_mode (_mavresult .param2 )
282- elseif _mavresult .command == 20 then -- MAV_CMD_NAV_RETURN_TO_LAUNCH (Mode RTL) may vary depending on frame
283- if FWVersion :type () == 2 then -- copter
284- vehicle :set_mode (6 )
285- elseif FWVersion :type () == 3 then -- plane
286- vehicle :set_mode (11 )
287- elseif FWVersion :type () == 1 then -- rover
288- vehicle :set_mode (11 )
289- end
290- elseif _mavresult .command == 21 then -- MAV_CMD_NAV_LAND (Mode LAND) may vary depending on frame
291- if FWVersion :type () == 2 then -- copter
292- vehicle :set_mode (9 )
293- elseif FWVersion :type () == 12 then -- blimp
294- vehicle :set_mode (0 )
295- end
296- elseif _mavresult .command == 22 then -- MAV_CMD_NAV_TAKEOFF
297- vehicle :start_takeoff (_mavresult .param7 )
298- elseif _mavresult .command == 84 then -- MAV_CMD_NAV_VTOL_TAKEOFF
299- vehicle :start_takeoff (_mavresult .param7 )
300- elseif _mavresult .command == 85 then -- MAV_CMD_NAV_VTOL_LAND (Mode QLAND)
301- vehicle :set_mode (20 )
302- elseif _mavresult .command == 300 then -- MAV_CMD_MISSION_START --mode auto and then start mission
303- if FWVersion :type () == 2 then -- copter
304- vehicle :set_mode (3 )
305- elseif FWVersion :type () == 3 then -- plane
306- vehicle :set_mode (10 )
307- elseif FWVersion :type () == 1 then -- rover
308- vehicle :set_mode (10 )
309- elseif FWVersion :type () == 7 then -- sub
310- vehicle :set_mode (3 )
311- end
312- elseif _mavresult .command == 2600 then -- MAV_CMD_CONTROL_HIGH_LATENCY
313- if _mavresult .param1 == 1 then
314- gcs :enable_high_latency_connections (true )
315- else
316- gcs :enable_high_latency_connections (false )
317- end
318- end
277+ elseif _mavresult .msgid == self .COMMAND_LONG then
278+ gcs :run_command_long (_mavresult .command , { p1 = _mavresult .param1 ,
279+ p2 = _mavresult .param2 ,
280+ p3 = _mavresult .param3 ,
281+ p4 = _mavresult .param4 ,
282+ p5 = _mavresult .param5 ,
283+ p6 = _mavresult .param6 ,
284+ p7 = _mavresult .param7 })
285+ elseif _mavresult .msgid == self .COMMAND_INT then
286+ gcs :run_command_int (_mavresult .command , { p1 = _mavresult .param1 ,
287+ p2 = _mavresult .param2 ,
288+ p3 = _mavresult .param3 ,
289+ p4 = _mavresult .param4 ,
290+ x = _mavresult .x ,
291+ y = _mavresult .y ,
292+ z = _mavresult .z ,
293+ frame = _mavresult .frame })
294+ elseif _mavresult .msgid == self .MISSION_SET_CURRENT then
295+ mission :set_current_cmd (_mavresult .seq )
319296 end
320297 _mavbuffer = " "
321298 return true
0 commit comments