• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MAVLink类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MAVLink的典型用法代码示例。如果您正苦于以下问题:C# MAVLink类的具体用法?C# MAVLink怎么用?C# MAVLink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MAVLink类属于命名空间,在下文中一共展示了MAVLink类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: BUT_connect_Click

        private void BUT_connect_Click(object sender, EventArgs e)
        {
            Comms.CommsSerialScan.Scan(false);

            DateTime deadline = DateTime.Now.AddSeconds(50);

            while (Comms.CommsSerialScan.foundport == false)
            {
                System.Threading.Thread.Sleep(100);

                if (DateTime.Now > deadline)
                {
                    CustomMessageBox.Show("Timeout waiting for autoscan/no mavlink device connected");
                    return;
                }
            }

            MAVLink com2 = new MAVLink();

            com2.BaseStream.PortName = Comms.CommsSerialScan.portinterface.PortName;
            com2.BaseStream.BaudRate = Comms.CommsSerialScan.portinterface.BaudRate;

            com2.Open(true);

            MainV2.Comports.Add(com2);

            bindingSource1.ResetBindings(false);
        }
开发者ID:neolu,项目名称:MissionPlanner,代码行数:28,代码来源:FollowPathControl.cs


示例2: UpdateIcon

        public void UpdateIcon(MAVLink mav,float x, float y, float z, bool movable)
        {
            foreach (var icon in icons)
            {
                if (icon.interf == mav)
                {
                    icon.Movable = movable;
                    if (!movable)
                    {
                        icon.x = 0;
                        icon.y = 0;
                        icon.z = 0;
                        icon.Color = Color.Blue;
                    }
                    else
                    {
                        icon.x = x;
                        icon.y = y;
                        icon.z = z;
                        icon.Color = Color.Red;
                    }
                    this.Invalidate();
                    return;
                }
            }

            icons.Add(new icon() { interf = mav, y=y, z = z,x = x, Movable = movable, Name = mav.ToString() });
        }
开发者ID:shocky,项目名称:MissionPlanner,代码行数:28,代码来源:Grid.cs


示例3: ReceviedPacket

        bool ReceviedPacket(MAVLink.MAVLinkMessage rawpacket)
        {
            if (rawpacket.msgid == (byte) MAVLink.MAVLINK_MSG_ID.TERRAIN_REQUEST)
            {
                MAVLink.mavlink_terrain_request_t packet =
                    rawpacket.ToStructure<MAVLink.mavlink_terrain_request_t>();

                if (issending)
                    return false;

                lastmessage = rawpacket;
                lastrequest = packet;

                log.Info("received TERRAIN_REQUEST " + packet.lat/1e7 + " " + packet.lon/1e7 + " space " +
                         packet.grid_spacing + " " + Convert.ToString((long) packet.mask, 2));

                System.Threading.ThreadPool.QueueUserWorkItem(QueueSendGrid);
            }
            else if (rawpacket.msgid == (byte) MAVLink.MAVLINK_MSG_ID.TERRAIN_REPORT)
            {
                MAVLink.mavlink_terrain_report_t packet =
                    rawpacket.ToStructure<MAVLink.mavlink_terrain_report_t>();
                log.Info("received TERRAIN_REPORT " + packet.lat/1e7 + " " + packet.lon/1e7 + " " + packet.loaded + " " +
                         packet.pending);
            }
            return false;
        }
开发者ID:AndersonRayner,项目名称:MissionPlanner,代码行数:27,代码来源:TerrainFollow.cs


示例4: receivedPacket

        private bool receivedPacket(MAVLink.MAVLinkMessage arg)
        {
            if (arg.msgid == (uint)MAVLink.MAVLINK_MSG_ID.STATUSTEXT)
            {
                var message = ASCIIEncoding.ASCII.GetString(arg.ToStructure<MAVLink.mavlink_statustext_t>().text);

                UpdateUserMessage(message);

                if (message.ToLower().Contains("calibration successful") ||
                 message.ToLower().Contains("calibration failed"))
                {
                    try
                    {
                        Invoke((MethodInvoker)delegate
                        {
                            BUT_calib_accell.Text = Strings.Done;
                            BUT_calib_accell.Enabled = false;
                        });

                        _incalibrate = false;
                        MainV2.comPort.UnSubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.STATUSTEXT, receivedPacket);
                    }
                    catch
                    {
                    }
                }
            }

            return true;
        }
开发者ID:ArduPilot,项目名称:MissionPlanner,代码行数:30,代码来源:ConfigAccelerometerCalibration.cs


示例5: MAVLinkSerialPort

        public MAVLinkSerialPort(MAVLinkInterface mavint, MAVLink.SERIAL_CONTROL_DEV port)
        {
            this.mavint = mavint;
            this.port = port;

            if (!mavint.BaseStream.IsOpen)
            {
                mavint.BaseStream.Open();
            }

            if (mavint.getHeartBeat().Length == 0)
            {
                throw new Exception("No valid heartbeats read from port");
            }

            if (subscription.Value != null)
                mavint.UnSubscribeToPacketType(subscription);

            subscription = mavint.SubscribeToPacketType(MAVLink.MAVLINK_MSG_ID.SERIAL_CONTROL, ReceviedPacket, true);

            bgdata = new Thread(mainloop);
            bgdata.Name = "MAVLinkSerialPort";
            bgdata.IsBackground = true;
            bgdata.Start();
        }
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:25,代码来源:MAVLinkSerialPort.cs


示例6: getOffsetFromLeader

        public HIL.Vector3 getOffsetFromLeader(MAVLink leader, MAVLink mav)
        {
            //convert Wgs84ConversionInfo to utm
            CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();

            GeographicCoordinateSystem wgs84 = GeographicCoordinateSystem.WGS84;

            int utmzone = (int)((leader.MAV.cs.lng - -183.0) / 6.0);

            IProjectedCoordinateSystem utm = ProjectedCoordinateSystem.WGS84_UTM(utmzone, leader.MAV.cs.lat < 0 ? false : true);

            ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84, utm);

            double[] masterpll = { leader.MAV.cs.lng, leader.MAV.cs.lat };

            // get leader utm coords
            double[] masterutm = trans.MathTransform.Transform(masterpll);

            double[] mavpll = { mav.MAV.cs.lng, mav.MAV.cs.lat };

            //getLeader follower utm coords
            double[] mavutm = trans.MathTransform.Transform(mavpll);

            return new HIL.Vector3(masterutm[1] - mavutm[1], masterutm[0] - mavutm[0], 0);
        }
开发者ID:rezatoops,项目名称:MissionPlanner,代码行数:25,代码来源:FormationControl.cs


示例7: setup

        public void setup(List<KeyValuePair<int, string>> source, string paramname, MAVLink.MAVLinkParamList paramlist)
            //, string paramname2 = "", Control enabledisable = null)
        {
            base.SelectedIndexChanged -= MavlinkComboBox_SelectedIndexChanged;

            _source2 = source;

            this.DisplayMember = "Value";
            this.ValueMember = "Key";
            this.DataSource = source;

            this.ParamName = paramname;


            if (paramlist.ContainsKey(paramname))
            {
                this.Enabled = true;
                this.Visible = true;

                enableControl(true);

                var item = paramlist[paramname];

                this.SelectedValue = (int) paramlist[paramname].Value;
            }

            base.SelectedIndexChanged += new EventHandler(MavlinkComboBox_SelectedIndexChanged);
        }
开发者ID:ans10528,项目名称:MissionPlanner-MissionPlanner1.3.34,代码行数:28,代码来源:MavlinkComboBox.cs


示例8: GMapMarkerPhoto

        public GMapMarkerPhoto(MAVLink.mavlink_camera_feedback_t mark, bool shotBellowMinInterval = false)
            : base(new PointLatLng(mark.lat/1e7, mark.lng/1e7))
        {
            local = mark;
            this.shotBellowMinInterval = shotBellowMinInterval;
            Offset = new Point(-localcache1.Width/2, -localcache1.Height/2);
            Size = localcache1.Size;
            Alt = mark.alt_msl;
            ToolTipMode = MarkerTooltipMode.OnMouseOver;

            Roll = local.roll - rolltrim;
            Pitch = local.pitch - pitchtrim;
            Yaw = local.yaw - yawtrim;

            ToolTipText = "Photo" + "\nAlt: " + mark.alt_msl + "\nNo: "+ mark.img_idx + "\nRoll: "+Roll.ToString("0.00");

            Tag = mark.time_usec;

            var footprint = ImageProjection.calc(new PointLatLngAlt(Position.Lat, Position.Lng, Alt), Roll,
                Pitch, Yaw, hfov, vfov);

            footprintpoly = new GMapPolygon(footprint.ConvertAll(x => x.Point()), "FP"+mark.time_usec);

            footprintpoly.Fill = Brushes.Transparent;
            footprintpoly.Stroke = Pens.Crimson;
        }
开发者ID:AndersonRayner,项目名称:MissionPlanner,代码行数:26,代码来源:GMapMarkerPhoto.cs


示例9: getOffsets

 public HIL.Vector3 getOffsets(MAVLink mav)
 {
     if (offsets.ContainsKey(mav))
     {
         return offsets[mav];
     }
     return new HIL.Vector3(offsets.Count, 0, 0);
 }
开发者ID:jjlin,项目名称:MissionPlanner,代码行数:8,代码来源:FollowLeader.cs


示例10: setup

        public void setup(string paramname, MAVLink.MAVLinkParamList paramlist)
        {
            this.ParamName = paramname;

            if (paramlist.ContainsKey(paramname))
            {
                this.Enabled = true;

                list = ParameterMetaDataRepository.GetParameterBitMaskInt(ParamName,
                    MainV2.comPort.MAV.cs.firmware.ToString());
                chkcount = list.Count;

                int leftside = 9;
                int top = 9;

                uint value = (uint) paramlist[paramname].Value;

                for (int a = 0; a < chkcount; a++)
                {
                    CheckBox chk = new CheckBox();
                    chk.AutoSize = true;
                    chk.Text = list[a].Value.ToString();
                    chk.Location = new System.Drawing.Point(leftside, top);

                    chk.CheckedChanged -= MavlinkCheckBoxBitMask_CheckedChanged;

                    if ((value & (1 << list[a].Key)) > 0)
                    {
                        chk.Checked = true;
                    }

                    chklist.Add(new KeyValuePair<int, CheckBox>(list[a].Key, chk));
                    panel1.Controls.Add(chk);

                    chk.CheckedChanged += MavlinkCheckBoxBitMask_CheckedChanged;

                    //this.Controls.Add(new Label() { Location = chk.Location, Text = "test" });

                    leftside += chk.Width + 5;
                    if (leftside > 500)
                    {
                        top += chk.Height + 5;
                        leftside = 9;
                    }
                }


                this.panel1.Height = top + 25;

                //this.Height = top + 25;
            }
            else
            {
                this.Enabled = false;
            }
        }
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:56,代码来源:MavlinkCheckBoxBitMask.cs


示例11: GMapMarkerRallyPt

 public GMapMarkerRallyPt(MAVLink.mavlink_rally_point_t mark)
     : base(new PointLatLng(mark.lat / 1e7, mark.lng / 1e7))
 {
     Size = SizeSt;
     Offset = new Point(-10, -40);
     Alt = mark.alt;
     Alt = (int)mark.alt; 
     ToolTipMode = MarkerTooltipMode.OnMouseOver;
     ToolTipText = "Rally Point" + "\nAlt: " + mark.alt;
 }
开发者ID:ECain,项目名称:MissionPlanner,代码行数:10,代码来源:GMapMarkerRallyPt.cs


示例12: setup

 public void setup(double OnValue, double OffValue, string[] paramname, MAVLink.MAVLinkParamList paramlist,
     Control enabledisable = null)
 {
     foreach (var s in paramname)
     {
         if (paramlist.ContainsKey(s))
         {
             setup(OnValue, OffValue, s, paramlist, enabledisable);
             return;
         }
     }
 }
开发者ID:ArduPilot,项目名称:MissionPlanner,代码行数:12,代码来源:MavlinkCheckBox.cs


示例13: ReceviedPacket

        private bool ReceviedPacket(MAVLink.MAVLinkMessage arg)
        {
            if (arg.msgid == (byte) MAVLink.MAVLINK_MSG_ID.DATA_TRANSMISSION_HANDSHAKE)
            {
                var packet = arg.ToStructure<MAVLink.mavlink_data_transmission_handshake_t>();
                msgDataTransmissionHandshake = packet;
                imageBuffer.Close();
                imageBuffer = new MemoryStream((int)packet.size);
            }
            else if (arg.msgid == (byte)MAVLink.MAVLINK_MSG_ID.ENCAPSULATED_DATA)
            {
                var packet = arg.ToStructure<MAVLink.mavlink_encapsulated_data_t>();
                msgEncapsulatedData = packet;
                int start = msgDataTransmissionHandshake.payload * msgEncapsulatedData.seqnr;
                int left = (int)msgDataTransmissionHandshake.size - start;
                var writeamount = Math.Min(msgEncapsulatedData.data.Length, left);

                imageBuffer.Seek(start, SeekOrigin.Begin);
                imageBuffer.Write(msgEncapsulatedData.data, 0, writeamount);

                // we have a complete image
                if ((msgEncapsulatedData.seqnr+1) == msgDataTransmissionHandshake.packets)
                {
                    using (
                        Bitmap bmp = new Bitmap(msgDataTransmissionHandshake.width, msgDataTransmissionHandshake.height,
                            PixelFormat.Format8bppIndexed))
                    {
                        SetGrayscalePalette(bmp);

                        var bitmapData = bmp.LockBits(new Rectangle(Point.Empty, bmp.Size), ImageLockMode.ReadWrite,
                            bmp.PixelFormat);

                        if (imageBuffer.Length > msgDataTransmissionHandshake.size)
                            return true;

                        var buffer = imageBuffer.ToArray();

                        Marshal.Copy(buffer, 0, bitmapData.Scan0, buffer.Length);
                        bmp.UnlockBits(bitmapData);

                        if (newImage != null)
                            newImage(this, new ImageEventHandle(bmp));

                        //bmp.Save("test.bmp", ImageFormat.Bmp);
                    }
                }
            }

            return true;
        }
开发者ID:ArduPilot,项目名称:MissionPlanner,代码行数:50,代码来源:OpticalFlow.cs


示例14: setup

        public void setup(Type source, string paramname, MAVLink.MAVLinkParamList paramlist)//, string paramname2 = "", Control enabledisable = null)
        {
            base.SelectedIndexChanged -= MavlinkComboBox_SelectedIndexChanged;

            _source = source;

            this.DataSource = Enum.GetNames(source);

            this.ParamName = paramname;

            if (paramlist.ContainsKey(paramname))
            {
                this.Enabled = true;
                this.Visible = true;

                enableControl(true);

                this.Text = Enum.GetName(source, (Int32)paramlist[paramname].Value);
            }

            base.SelectedIndexChanged += new EventHandler(MavlinkComboBox_SelectedIndexChanged);
        }
开发者ID:jackmaynard,项目名称:MissionPlanner,代码行数:22,代码来源:MavlinkComboBox.cs


示例15: setup

        public void setup(double OnValue, double OffValue, string paramname, MAVLink.MAVLinkParamList paramlist,
            Control enabledisable = null)
        {
            base.CheckedChanged -= MavlinkCheckBox_CheckedChanged;

            this.OnValue = OnValue;
            this.OffValue = OffValue;
            this.ParamName = paramname;
            this._control = enabledisable;

            if (paramlist.ContainsKey(paramname))
            {
                this.Enabled = true;
                this.Visible = true;

                if (paramlist[paramname].Value == OnValue)
                {
                    this.Checked = true;
                    enableControl(true);
                }
                else if (paramlist[paramname].Value == OffValue)
                {
                    this.Checked = false;
                    enableControl(false);
                }
                else
                {
                    this.CheckState = System.Windows.Forms.CheckState.Indeterminate;
                    enableControl(false);
                }
            }
            else
            {
                this.Enabled = false;
            }

            base.CheckedChanged += new EventHandler(MavlinkCheckBox_CheckedChanged);
        }
开发者ID:ans10528,项目名称:MissionPlanner-MissionPlanner1.3.34,代码行数:38,代码来源:MavlinkCheckBox.cs


示例16: doMotorTest

 public bool doMotorTest(int motor, MAVLink.MOTOR_TEST_THROTTLE_TYPE thr_type, int throttle, int timeout)
 {
     return MainV2.comPort.doCommand(MAVLink.MAV_CMD.DO_MOTOR_TEST, (float) motor, (float) (byte) thr_type,
         (float) throttle, (float) timeout, 0, 0, 0);
 }
开发者ID:ChukRhodes,项目名称:MissionPlanner,代码行数:5,代码来源:MAVLinkInterface.cs


示例17: setup

 public void setup(float Min, float Max, float Scale, float Increment, string paramname,
     MAVLink.MAVLinkParamList paramlist, Control enabledisable = null)
 {
     setup(Min, Max, Scale, Increment, new string[] {paramname}, paramlist, enabledisable);
 }
开发者ID:hmchen1,项目名称:MissionPlanner,代码行数:5,代码来源:MavlinkNumericUpDown.cs


示例18: InsertWP

 public void InsertWP(int idx, MAVLink.MAV_CMD cmd, double p1, double p2, double p3, double p4, double x, double y,
     double z)
 {
     MainV2.instance.FlightPlanner.InsertCommand(idx, cmd, p1, p2, p3, p4, x, y, z);
 }
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:5,代码来源:Plugin.cs


示例19: AddWPtoList

 /// <summary>
 /// add wp to command queue - dont upload to mav
 /// </summary>
 /// <param name="cmd"></param>
 /// <param name="p1"></param>
 /// <param name="p2"></param>
 /// <param name="p3"></param>
 /// <param name="p4"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="z"></param>
 public void AddWPtoList(MAVLink.MAV_CMD cmd, double p1, double p2, double p3, double p4, double x, double y,
     double z)
 {
     MainV2.instance.FlightPlanner.AddCommand(cmd, p1, p2, p3, p4, x, y, z);
 }
开发者ID:duyisu,项目名称:MissionPlanner,代码行数:16,代码来源:Plugin.cs


示例20: setOffsets

 public void setOffsets(MAVLink mav, double x, double y, double z)
 {
     offsets[mav] = new HIL.Vector3(x,y,z);
     //log.Info(mav.ToString() + " " + offsets[mav].ToString());
 }
开发者ID:palacita,项目名称:MissionPlanner,代码行数:5,代码来源:Formation.cs



注:本文中的MAVLink类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MCSControls类代码示例发布时间:2022-05-24
下一篇:
C# MATRIX_D类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap