加载中…
个人资料
wangluoxi
wangluoxi
  • 博客等级:
  • 博客积分:0
  • 博客访问:4,198
  • 关注人气:12
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

[转载]中鸣机器人E2RCU搭建与编程实例

(2021-03-22 21:20:46)
标签:

转载

分类: 网络资料

(第6周)

工作里偷闲,总要对机器人作一番研究,这段时间主要研究中鸣公司的综合技能机器人及E2RCU传感器的研究,通过反复的程序测试,E2RCU实质上在程序判断上很难符合需求,也就是说,它虽然有很P1-P8个可接的端口,但却不能很好的支持罗辑判断,编写的程序只能是顺序执行,否则便会运行错误。

现列举几个实例

实例一:排除障碍机器人

原料:超声波传感器、E2RCU、2个编组马达及组木块

搭建:

[转载]中鸣机器人E2RCU搭建与编程实例

 

程序编写:1图形代码

[转载]中鸣机器人E2RCU搭建与编程实例

 

2.程序代码: #include "HardwareInfo.c"

#include "JMLib.c"

#include

#include

#include

#include

 

int main(void)

{

    E2RCU_Init();

    unsigned int var0 = 0;

    while (1)

    {

        var0 = GetUltrasound(_P3_, 0);

        if ( var0<30 )

        {

            SetMotor(_M1_, -50);

            SetMotor(_M2_, -50);

            SetWaitForTime(1);

            SetMotor(_M1_, 0);

            SetMotor(_M2_, 50);

            SetWaitForTime(1);

            Set3CLed(_P7_, RED);

            Set3CLed(_P6_, RED);

        }

        else

        {

            SetMotor(_M1_, 50);

            SetMotor(_M2_, 50);

            Set3CLed(_P7_, PURPLE);

            Set3CLed(_P6_, PURPLE);

        }

    }

    while(1);

}

 

实例二:模拟宠物

原料:超声波传感器、声音模块、E2RCU、2个编组马达及组木块

搭建:

[转载]中鸣机器人E2RCU搭建与编程实例

 

1.图形化程序:利用超声测距进行物体追踪,并在检测到物体是发出定义的声响:

[转载]中鸣机器人E2RCU搭建与编程实例

 

2.C语言程序代码:

#include "HardwareInfo.c"

#include "JMLib.c"

#include

#include

#include

#include

#include

#include

 

int main(void)

{

    E2RCU_Init();

    int unsg = 0;

    int un1 = 0;

    int sound = 80;

    SetLCDBack(ON);

    SetDisplayString(1, "P1", YELLOW, BLACK);

    SetDisplayString(2, "Music Player", YELLOW, BLACK);

    SetWaitForTime(0.3);

    un1=2;

    while (1)

    {

        sound = GetUltrasound(_P3_, 0);

        if ( unsg<30 )

        {

            SetMusicPlayer(_P1_, 1);

            SetWaitForTime(0.5);

            SetMotor(_M1_, -30);

            SetMotor(_M2_, -30);

        }

        else

        {

            if ( unsg<40 )

            {

                SetMotor(_M1_, 30);

                SetMotor(_M2_, 30);

            }

            else

            {

                if ( unsg<60 )

                {

                    SetMotor(_M1_, 60);

                    SetMotor(_M2_, 60);

                }

                else

                {

                    SetMotor(_M1_, 0);

                    SetMotor(_M2_, 0);

                }

            }

        }

    }

    while(1);

}

 

在简单的程序定义中,E2RCU运行没有太大的问题,不过传感器的测试不是完全正确,有很大的偏差,新写入的程序运行没有太大的问题,不过连续开关主机或多执行几遍后,机器人会出现错误。

综合来看,E2RCU很不稳定,功能有缺陷,只合适简单的应用。

0

  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有