您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > AI人工智能 > 智能机器人课程设计报告
天津师范大学计算机与信息工程学院课程设计报告课程名称:机器人设计设计题目:专业:信息工程班级:08(1)班组别:学生姓名:吴雪萍学号:08509205起止日期:2011年3月1日~2011年7月1日指导教师:刘岩恺梁景莲同组人员:课程设计题目机器人设计实验姓名吴雪萍学号08509205班级08信息(1)班班级专业信息工程组别组长组员指导教师刘岩恺梁景莲课程设计目的设计家庭组机器人和机器人行走课程设计环境Vc++课程设计任务和要求用C++语言设计一个颜色识别的程序和一个机器人行走程序课程设计内容描述:1.绪论通过学习机器人设计2课程,学会了家庭组机器人和足球机器人的一些理论知识。了解了机器人方向识别,动手调试了全景摄像头和前置摄像头,设置了场地、球门、白线、足球等的颜色数值。2.颜色识别的产生结合梁老师给的人脸识别程序,通过改变人脸模型建立颜色识别程序。3.平台的选择及搭建根据刘老师给的参考资料,首先安装了DirectX9.0SDK和VisualC++软件,然后一步步的按照老师所给的步骤,先建立基本界面,接着编制串口通讯控制机器人的程序,读取距离传感器信息等,最后得出了机器人行走程序如下。课程设计源程序:机器人行走//VoyTestDlg.cpp:implementationfile//#includestdafx.h#includeVoyTest.h#includeVoyTestDlg.h#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif///////////////////////////////////////////////////////////////////////////////CAboutDlgdialogusedforAppAboutclassCAboutDlg:publicCDialog{public:CAboutDlg();//DialogData//{{AFX_DATA(CAboutDlg)enum{IDD=IDD_ABOUTBOX};//}}AFX_DATA//ClassWizardgeneratedvirtualfunctionoverrides//{{AFX_VIRTUAL(CAboutDlg)protected:virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport//}}AFX_VIRTUAL//Implementationprotected://{{AFX_MSG(CAboutDlg)//}}AFX_MSGDECLARE_MESSAGE_MAP()};CAboutDlg::CAboutDlg():CDialog(CAboutDlg::IDD){//{{AFX_DATA_INIT(CAboutDlg)//}}AFX_DATA_INIT}voidCAboutDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CAboutDlg)//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)//{{AFX_MSG_MAP(CAboutDlg)//Nomessagehandlers//}}AFX_MSG_MAPEND_MESSAGE_MAP()///////////////////////////////////////////////////////////////////////////////CVoyTestDlgdialogCVoyTestDlg::CVoyTestDlg(CWnd*pParent/*=NULL*/):CDialog(CVoyTestDlg::IDD,pParent){//{{AFX_DATA_INIT(CVoyTestDlg)m_nPort=0;//}}AFX_DATA_INIT//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32m_hIcon=AfxGetApp()-LoadIcon(IDR_MAINFRAME);}voidCVoyTestDlg::DoDataExchange(CDataExchange*pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CVoyTestDlg)DDX_Text(pDX,IDC_PORT,m_nPort);//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CVoyTestDlg,CDialog)//{{AFX_MSG_MAP(CVoyTestDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_OPEN,OnOpen)ON_BN_CLICKED(IDC_FORWARD,OnForward)ON_BN_CLICKED(IDC_BACKWARD,OnBackward)ON_BN_CLICKED(IDC_TURELEFT,OnTureleft)ON_BN_CLICKED(IDC_TURERIGHT,OnTureright)ON_BN_CLICKED(IDC_BRAKE,OnBrake)//}}AFX_MSG_MAPEND_MESSAGE_MAP()///////////////////////////////////////////////////////////////////////////////CVoyTestDlgmessagehandlersBOOLCVoyTestDlg::OnInitDialog(){CDialog::OnInitDialog();//AddAbout...menuitemtosystemmenu.//IDM_ABOUTBOXmustbeinthesystemcommandrange.ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX0xF000);CMenu*pSysMenu=GetSystemMenu(FALSE);if(pSysMenu!=NULL){CStringstrAboutMenu;strAboutMenu.LoadString(IDS_ABOUTBOX);if(!strAboutMenu.IsEmpty()){pSysMenu-AppendMenu(MF_SEPARATOR);pSysMenu-AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);}}//Settheiconforthisdialog.Theframeworkdoesthisautomatically//whentheapplication'smainwindowisnotadialogSetIcon(m_hIcon,TRUE);//SetbigiconSetIcon(m_hIcon,FALSE);//Setsmallicon//TODO:AddextrainitializationherereturnTRUE;//returnTRUEunlessyousetthefocustoacontrol}voidCVoyTestDlg::OnSysCommand(UINTnID,LPARAMlParam){if((nID&0xFFF0)==IDM_ABOUTBOX){CAboutDlgdlgAbout;dlgAbout.DoModal();}else{CDialog::OnSysCommand(nID,lParam);}}//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,//thisisautomaticallydoneforyoubytheframework.voidCVoyTestDlg::OnPaint(){if(IsIconic()){CPaintDCdc(this);//devicecontextforpaintingSendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);//CentericoninclientrectangleintcxIcon=GetSystemMetrics(SM_CXICON);intcyIcon=GetSystemMetrics(SM_CYICON);CRectrect;GetClientRect(&rect);intx=(rect.Width()-cxIcon+1)/2;inty=(rect.Height()-cyIcon+1)/2;//Drawtheicondc.DrawIcon(x,y,m_hIcon);}else{CDialog::OnPaint();}}//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags//theminimizedwindow.HCURSORCVoyTestDlg::OnQueryDragIcon(){return(HCURSOR)m_hIcon;}voidCVoyTestDlg::OnOpen(){//TODO:AddyourcontrolnotificationhandlercodehereUpdateData();//CStringstr;//str.Format(您打开的串口号为%d,m_nPort);//AfxMessageBox(str);m_Com.SetCmd(&m_Cmd);//协议层与通讯层对接m_Com.Create(m_nPort);//打开通讯串口}voidCVoyTestDlg::OnForward(){//TODO:Addyourcontrolnotificationhandlercodeherem_Cmd.SetBothMotorsSpeed(100,100);//前行}voidCVoyTestDlg::OnBackward(){//TODO:Addyourcontrolnotificationhandlercodeherem_Cmd.SetBothMotorsSpeed(-100,-100);//后退}voidCVoyTestDlg::OnTureleft(){//TODO:Addyourcontrolnotificationhandlercodeherem_Cmd.SetBothMotorsSpeed(-100,100);//左转}voidCVoyTestDlg::OnTureright(){//TODO:Addyourcontrolnotificationhandlercodeherem_Cmd.SetBothMotorsSpeed(100,-100);//右转}voidCVoyTestDlg::OnBrake(){//TODO:Addyourcontrolnotificationhandlercodeherem_Cmd.Brake(1);//刹车}总结:1、程序调试及运行结果通过程序运行,我们可以看到足球机器人前进,后退,左转,右转及刹车等动作的分解。2、小结:通过完成本次实验,我认识到理论与实践的结合很重要。实践中遇到了许多问题,只有耐心的不断去修改、调试、运行,才能很好的把实验完成。理论是实际的基础,只有牢固的学好理论知识,才能成功的完成实验。在实践中我们可以学到许多新的知识,遇到问题困难的时候,才
本文标题:智能机器人课程设计报告
链接地址:https://www.777doc.com/doc-29527 .html