模吧

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

1561查看 | 7回复

【参赛作品】四旋翼地面站

[复制链接]
发表于 2014-8-18 00:40:06 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
错过了最佳的作品提交日期了。
前段时间帮同学做电子设计大赛,做的就是四旋翼的竞赛题目。感觉收货颇丰的。

在DIY作品中,还是做自己的老本行吧,所以就写了一套四旋翼的地面站来参赛了。

这个地面站经历了好几个版本的。

也为大家提供了通信协议的。方便大家能够使用 。

只要是通过串口,就可以实现数据的发送和显示。


【参赛作品】四旋翼地面站 DIY,地面站 作者:china 8729
【参赛作品】四旋翼地面站 DIY,地面站 作者:china 8787
【参赛作品】四旋翼地面站 DIY,地面站 作者:china 55

【参赛作品】四旋翼地面站 DIY,地面站 作者:china 5077


附带了 通信协议的

消息格式:*高度,pitch,roll,yaw,经度,纬度,rc1,rc2,rc3,rc4;
除经纬度之外,其他必须为整型,有bug还在测试中。roll角度为0-360°
消息:*1522,15,12,12,2.33666555,3.22555554,1500,1500,1500,1500;


为了方便调试,这里也做了一些修改的。
看了到调试界面了吗?
【参赛作品】四旋翼地面站 DIY,地面站 作者:china 3164

【参赛作品】四旋翼地面站 DIY,地面站 作者:china 7924

这个是演示视频的。看看效果的



为了让更多的人了解一下这个东西,附上串口代码的:
        void Serial_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            int n =SP.BytesToRead;
            byte[] buf = new byte[n+1];
            (sender as SerialPort).Read(buf, 0, n);
            //Array.Resize(ref buf, n);
            // MessageBox.Show( String.Format("{0}{1}", BitConverter.ToString(buf), Environment.NewLine));

            //MessageBox.Show(Encoding.Default.GetString(buf));

            int m=0;
            while (m != n)
            {

                if (buf[m] == '*' )
                {

                    msg_num = 0;
                    is_exit1 = 1;

                }
                else if (buf[m] == '#')
                {
                    msg_num = 0;
                    is_exit1 = 2;

                }
                if(buf[m] == ';')
                {

                    //msg_num = 0;
                    if (is_exit1 == 1)
                    {
                        is_exit2 = 1;
                        pcmsg[msg_num] = buf[m];
                    }
                    else
                    {
                        msg_num = 0;
                        is_exit1 = 0;
                        is_exit2 = 0;
                        pcmsg = null;
                        pcmsg = new byte[400];
                        return;

                    }

                    break;
                }
                pcmsg[msg_num]=buf[m];
                m++;
                msg_num++;
                if (msg_num >= 399)
                {
                    msg_num = 0;
                    is_exit1 = 0;
                    is_exit2 = 0;
                    pcmsg = null;
                    pcmsg = new byte[400];
                    return;
                }

            }
            if (is_exit2 == 1 && is_exit1 == 2)
            {
                string recvstr = Encoding.Default.GetString(pcmsg);
                RECV.Text = recvstr;

                string mstr = recvstr.Substring(1, msg_num - 1);
                msg.Text = mstr;
                string str2 = mstr.Replace(",", "");

                int strlen = mstr.Length - str2.Length + 1;
                string[] s = mstr.Split(',');
                if (strlen != 9)
                {
                    is_exit2 = 0;
                    is_exit1 = 0;
                    pcmsg = null;
                    pcmsg = new byte[400];
                    return;
                }
                PP.Text =(( Convert.ToDouble(s[0]))/100).ToString();
                PI.Text = ((Convert.ToDouble(s[1])) / 100).ToString();
                PD.Text = ((Convert.ToDouble(s[2])) / 100).ToString();

                YP.Text = ((Convert.ToDouble(s[3])) / 100).ToString();
                YI.Text = ((Convert.ToDouble(s[4])) / 100).ToString();
                YD.Text = ((Convert.ToDouble(s[5])) / 100).ToString();

                AP.Text = ((Convert.ToDouble(s[6])) / 100).ToString();
                AI.Text = ((Convert.ToDouble(s[7])) / 100).ToString();
                AD.Text = ((Convert.ToDouble(s[8])) / 100).ToString();
                msg_num = 0;
                is_exit1 = 0;
                is_exit2 = 0;

            }
            if (is_exit2 == 1 && is_exit1==1)
            {
                string recvstr=Encoding.Default.GetString(pcmsg);
                RECV.Text = recvstr;

                string mstr =recvstr.Substring(1, msg_num-1);
                msg.Text = mstr;
                string str2= mstr.Replace(",","");

                int strlen =mstr.Length- str2.Length+1;
                string[] s = mstr.Split(',');

               // MessageBox.Show(strlen.ToString());
                if (strlen >= 10)
                {
                    val.Text = s[0] + Environment.NewLine + s[1] + Environment.NewLine + s[2] + Environment.NewLine + s[3] + Environment.NewLine + s[4]
                        + Environment.NewLine + s[5] + Environment.NewLine + s[6] + Environment.NewLine + s[7] + Environment.NewLine + s[8]
                        + Environment.NewLine + s[9];
                }
                if (strlen >= 21 || strlen < 19)
                {
                    is_exit2 = 0;
                    is_exit1 = 0;
                    pcmsg = null;
                    pcmsg = new byte[400];
                    return;
                }
                //娑堟伅鏍煎紡锛?楂樺害锛宲itch锛宺oll锛寉aw锛岀粡搴︼紝绾害锛宺c1锛宺c2锛宺c3锛宺c4锛?
                if(strlen >0)
                if (reg.IsMatch(s[0]) && s[0] != ""&& s[0].Length <6 )
                {

                    altimeterIndicator1.SetAlimeterParameters(Convert.ToInt16(s[0])%65535);
                }
                if (strlen > 2)
                if (reg.IsMatch(s[1]) && reg.IsMatch(s[2]) && s[1] != ""
                    && s[2] != "" &&  s[1].Length< 4 && s[2].Length<4)
                {
                    mpitch =-Convert.ToInt16(s[1]);
                    mroll =-Convert.ToInt16(s[2]);
                    attitudeIndicator1.SetAttitudeIndicatorParameters(-mpitch, mroll);
                }
                if (strlen > 3)
                if (reg.IsMatch(s[3]) && s[3] != "" && s[3].Length < 5)
                 {

                     int tyaw=0;
                     tyaw =Convert.ToInt16(s[3]);;
                     tyaw = 180 - tyaw;
                     myaw = tyaw;

                     headingIndicator1.SetHeadingIndicatorParameters(tyaw);
                 }
                if (strlen >2 )
                if (reg.IsMatch(s[0]) && reg.IsMatch(s[1]) && reg.IsMatch(s[2])
                    && s[0] != "" && s[1] != "" && s[2] != "" )
                {
                    bFI1.Altitude = Convert.ToInt16(s[0]);
                    bFI1.Pitch = -Convert.ToInt16(s[1]);
                    bFI1.Bank = mroll;//Convert.ToInt16(s[2]);

                    bFI2.Altitude = Convert.ToInt16(s[0]);
                    bFI2.Pitch =- Convert.ToInt16(s[1]);
                    bFI2.Bank = mroll;//Convert.ToInt16(s[2]);
                }
                if (strlen > 4)
                {
                    wd.Text = s[4];
                    dwd.Text = s[4];
                }
                if (strlen > 5)
                {
                    jd.Text = s[5];
                    djd.Text = s[5];
                }
                if (strlen > 6)
                    if (reg.IsMatch(s[6]) && s[6] != "" && s[6].Length < 5)
                    {
                        rc1.Value = limit(Convert.ToInt16(s[6]));
                        rc1l.Text = s[6];
                    }
                if (strlen >7 )
                    if (reg.IsMatch(s[7]) && s[7] != "" && s[7].Length < 5)
                    {
                        rc2.Value = limit(Convert.ToInt16(s[7]));
                        rc2l.Text = s[7];
                    }
                if (strlen > 8)
                    if (reg.IsMatch(s[8]) && s[8] != "" && s[8].Length < 5)
                    {
                        rc3.Value = limit(Convert.ToInt16(s[8]));
                        rc3l.Text = s[8];
                    }
                if (strlen >9 )
                    if (reg.IsMatch(s[9]) && s[9] != "" && s[9].Length < 5)
                    {
                        rc4.Value = limit(Convert.ToInt16(s[9]));
                        rc4l.Text = s[9];
                    }

                if (strlen > 10)
                    if (reg.IsMatch(s[10]) && s[10] != "" && s[10].Length < 5)
                    {
                        rc5.Value = limit(Convert.ToInt16(s[10]));
                        rc5l.Text = s[10];
                    }

                if (strlen > 11)
                    if (reg.IsMatch(s[11]) && s[11] != "" && s[11].Length < 5)
                    {
                        rc6.Value = limit(Convert.ToInt16(s[11]));
                        rc6l.Text = s[11];
                    }

                if (strlen > 12)
                    if (reg.IsMatch(s[12]) && s[12] != "" && s[12].Length < 5)
                    {
                        rc7.Value = limit(Convert.ToInt16(s[12]));
                        rc7l.Text = s[12];
                    }

                if (strlen > 13)
                    if (reg.IsMatch(s[13]) && s[13] != "" && s[13].Length < 5)
                    {
                        rc8.Value = limit(Convert.ToInt16(s[13]));
                        rc8l.Text = s[13];
                    }

                if (strlen > 14)
                    pitchtext.Text = s[14];
                if (strlen > 15)
                    rolltext.Text = s[15];
                if (strlen > 16)
                    yawtext.Text = s[16];
                if (strlen > 17)
                    alttext.Text = s[17];


                if (strlen > 18)
                    mjd.Text = s[18];
                if (strlen > 19)
                    mwd.Text = s[19];



                is_exit2 = 0;
                is_exit1 = 0;
                pcmsg = null;
                pcmsg = new byte[400];
            }

        }

发表于 2014-8-18 14:17:59 | 显示全部楼层
【参赛作品】四旋翼地面站 DIY,地面站 作者:cyb2688 1100 【参赛作品】四旋翼地面站 DIY,地面站 作者:cyb2688 5975 厉害理工男【参赛作品】四旋翼地面站 DIY,地面站 作者:cyb2688 5097 【参赛作品】四旋翼地面站 DIY,地面站 作者:cyb2688 9150
发表于 2014-8-18 14:19:34 | 显示全部楼层
厉害!!!
发表于 2014-8-18 23:36:19 | 显示全部楼层
厉害 支持什么飞控
 楼主| 发表于 2014-8-26 19:51:43 | 显示全部楼层
cyb2688 发表于 2014-8-18 14:17 【参赛作品】四旋翼地面站 DIY,地面站 作者:china 4198
厉害理工男

多谢支持
 楼主| 发表于 2014-8-26 19:51:56 | 显示全部楼层
炸香机 发表于 2014-8-18 23:36 【参赛作品】四旋翼地面站 DIY,地面站 作者:china 4345
厉害 支持什么飞控

支持四轴
发表于 2014-8-26 21:26:08 | 显示全部楼层
china 发表于 2014-8-26 19:51 【参赛作品】四旋翼地面站 DIY,地面站 作者:炸香机 1718
支持四轴

支持所有四轴飞控?
发表于 2016-4-17 17:49:22 | 显示全部楼层
能交流交流吗,最近我也再做这个。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|关于模吧|APP下载|广告报价|小黑屋|手机版|企业会员|商城入驻|联系我们|模吧 ( 冀公网安备13080502000084号 )

© 2013-2020 Moz8.com 模吧,玩出精彩!