5151import com .comino .mavcom .control .IMAVController ;
5252import com .comino .mavcom .mavlink .MAV_CUST_MODE ;
5353import com .comino .mavcom .model .DataModel ;
54+ import com .comino .mavcom .model .segment .LogMessage ;
5455import com .comino .mavcom .model .segment .Status ;
5556import com .comino .mavcom .model .segment .Vision ;
5657import com .comino .mavcom .status .StatusManager ;
@@ -135,6 +136,18 @@ private void initialize() {
135136 arm_command .setOnAction ((ActionEvent event )-> {
136137
137138 if (!model .sys .isStatus (Status .MSP_ARMED )) {
139+
140+ if (control .isSimulation ()) {
141+ // SITL: Reset mode in order to be able to arm
142+ // TODO: Might be required for real vehicle also
143+ control .writeLogMessage (new LogMessage ("[mgc] Arming prep.: Switch to Loiter" ,MAV_SEVERITY .MAV_SEVERITY_DEBUG ));
144+ control .sendMAVLinkCmd (MAV_CMD .MAV_CMD_DO_SET_MODE , (cmd ,result ) -> {
145+ if (result != MAV_RESULT .MAV_RESULT_ACCEPTED )
146+ control .writeLogMessage (new LogMessage ("Arming preparation failed" ,MAV_SEVERITY .MAV_SEVERITY_DEBUG ));
147+ }, MAV_MODE_FLAG .MAV_MODE_FLAG_CUSTOM_MODE_ENABLED ,
148+ MAV_CUST_MODE .PX4_CUSTOM_MAIN_MODE_AUTO , MAV_CUST_MODE .PX4_CUSTOM_SUB_MODE_AUTO_LOITER );
149+ }
150+
138151 control .sendMAVLinkCmd (MAV_CMD .MAV_CMD_COMPONENT_ARM_DISARM ,( cmd ,result ) -> {
139152 if (result != MAV_RESULT .MAV_RESULT_ACCEPTED )
140153 logger .writeLocalMsg ("[mgc] Arming denied." ,MAV_SEVERITY .MAV_SEVERITY_WARNING );
@@ -152,7 +165,7 @@ private void initialize() {
152165
153166
154167 land_command .setOnAction ((ActionEvent event )-> {
155-
168+
156169 if (!model .vision .isStatus (Vision .FIDUCIAL_LOCKED )) {
157170 control .sendMAVLinkCmd (MAV_CMD .MAV_CMD_NAV_LAND , ( cmd ,result ) -> {
158171 if (result != MAV_RESULT .MAV_RESULT_ACCEPTED )
0 commit comments