private void ChgFlight(object sender, EventArgs e) { if (!Serial.IsOpen) { return; } int i = FlightModes.SelectedIndex; Msg_set_mode m = new Msg_set_mode(); m.base_mode = (byte)MAV_MODE_FLAG.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED; m.custom_mode = (byte)i; m.target_system = (byte)MAV_AUTOPILOT.MAV_AUTOPILOT_RESERVED; SendPacket(m); }
// Use this for initialization void Start() { SystemId = (byte)MAV_MODE.MAV_MODE_MANUAL_ARMED; ComponentId = (byte)MAV_COMPONENT.MAV_COMP_ID_AUTOPILOT1; Application.runInBackground = true; mlpn = new Msg_local_position_ned(); mgpi = new Msg_global_position_int(); Mheratbeat = new Msg_heartbeat(); Msts = new Msg_sys_status(); Matt = new Msg_attitude(); Mdatastream = new Msg_request_data_stream(); Mgpsr = new Msg_gps_raw_int(); Mattq = new Msg_attitude_quaternion(); Mvhud = new Msg_vfr_hud(); MattTar = new Msg_attitude_target(); MHome = new Msg_home_position(); setMHome = new Msg_set_home_position(); setMode = new Msg_set_mode(); EstimatorStatus = new Msg_estimator_status(); Mvirbration = new Msg_vibration(); ExtendState = new Msg_extended_sys_state(); latlonalt = new LatLonAlt(); Malt = new Msg_altitude(); positionL = new Msg_position_target_local_ned(); setPositionL = new Msg_set_position_target_local_ned(); setPositionG = new Msg_set_position_target_global_int(); PositionG = new Msg_position_target_global_int(); MhiIMU = new Msg_highres_imu(); BatteryStatus = new Msg_battery_status(); player = GameObject.FindGameObjectWithTag("Player"); DM = player.GetComponent <DroneMove> (); InitSocket(); setHomePosition(); setPositionTargetLocal(); setPositionTargetGlobal(); }