当前位置:文档之家› 智能机器人课程设计报告[资料]

智能机器人课程设计报告[资料]

智能机器人课程设计报告[资料] 天津师范大学计算机与信息工程学院课程设计报告课程名称: 机器人设计设计题目:专业: 信息工程班级: 08(1)班组别:学生姓名: 吴雪萍学号: 08509205起止日期: 2011年3月1日 ~ 2011年 7月1日指导教师: 刘岩恺梁景莲同组人员:课程设计题目机器人设计实验姓名吴雪萍学号 08509205 班级 08信息(1)班班级专业信息工程组别组长组员指导教师刘岩恺梁景莲课程设计设计家庭组机器人和机器人行走目的课程设计Vc++环境课程设计任务用C++语言设计一个颜色识别的程序和一个机器人行走程序和要求课程设计内容描述:1(绪论通过学习机器人设计2课程~学会了家庭组机器人和足球机器人的一些理论知识。

了解了机器人方向识别~动手调试了全景摄像头和前置摄像头~设置了场地、球门、白线、足球等的颜色数值。

2. 颜色识别的产生结合梁老师给的人脸识别程序~通过改变人脸模型建立颜色识别程序。

3. 平台的选择及搭建根据刘老师给的参考资料~首先安装了DirectX9.0 SDK和Visual C++软件~然后一步步的按照老师所给的步骤~先建立基本界面~接着编制串口通讯控制机器人的程序~读取距离传感器信息等~最后得出了机器人行走程序如下。

课程设计源程序:机器人行走// VoyTestDlg.cpp : implementation file //#include "stdafx.h"#include "VoyTest.h"#include "VoyTestDlg.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__; #endif//////////////////////////////////////////////////////////////////// /////////// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog {public:CAboutDlg();// Dialog Data//{{AFX_DATA(CAboutDlg)enum { IDD = IDD_ABOUTBOX };//}}AFX_DATA// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(CAboutDlg)protected:virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL// Implementationprotected://{{AFX_MSG(CAboutDlg)//}}AFX_MSGDECLARE_MESSAGE_MAP()};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD){//{{AFX_DATA_INIT(CAboutDlg)//}}AFX_DATA_INIT}void CAboutDlg::DoDataExchange(CDataExchange* pDX){CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(CAboutDlg)//}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)//{{AFX_MSG_MAP(CAboutDlg)// No message handlers//}}AFX_MSG_MAPEND_MESSAGE_MAP()//////////////////////////////////////////////////////////////////// /////////// CVoyTestDlg dialogCVoyTestDlg::CVoyTestDlg(CWnd* pParent /*=NULL*/): CDialog(CVoyTestDlg::IDD, pParent) {//{{AFX_DATA_INIT(CVoyTestDlg)m_nPort = 0;//}}AFX_DATA_INIT// Note that LoadIcon does not require a subsequent DestroyIcon in Win32m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);}void CVoyTestDlg::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()//////////////////////////////////////////////////////////////////// /////////// CVoyTestDlg message handlersBOOL CVoyTestDlg::OnInitDialog(){CDialog::OnInitDialog();// Add "About..." menu item to system menu.// IDM_ABOUTBOX must be in the system command range.ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX < 0xF000);CMenu* pSysMenu = GetSystemMenu(FALSE);if (pSysMenu != NULL){CString strAboutMenu;strAboutMenu.LoadString(IDS_ABOUTBOX);if (!strAboutMenu.IsEmpty()){pSysMenu->AppendMenu(MF_SEPARATOR);pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);}}// Set the icon for this dialog. The framework does this automatically// when the application's main window is not a dialogSetIcon(m_hIcon, TRUE); // Set big iconSetIcon(m_hIcon, FALSE); // Set small icon// TODO: Add extra initialization herereturn TRUE; // return TRUE unless you set the focus to a control }void CVoyTestDlg::OnSysCommand(UINT nID, LPARAM lParam) {if ((nID & 0xFFF0) == IDM_ABOUTBOX){CAboutDlg dlgAbout;dlgAbout.DoModal();}else{CDialog::OnSysCommand(nID, lParam);}}// If you add a minimize button to your dialog, you will need the code below// to draw the icon. For MFC applications using the document/view model,// this is automatically done for you by the framework.void CVoyTestDlg::OnPaint(){if (IsIconic()){CPaintDC dc(this); // device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);// Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);int cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(&rect);int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;// Draw the icondc.DrawIcon(x, y, m_hIcon);}else{CDialog::OnPaint();}}// The system calls this to obtain the cursor to display while the user drags// the minimized window.HCURSOR CVoyTestDlg::OnQueryDragIcon(){return (HCURSOR) m_hIcon;}void CVoyTestDlg::OnOpen(){// TODO: Add your control notification handler code here UpdateData();//CString str;//str.Format("您打开的串口号为%d",m_nPort);//AfxMessageBox(str);m_Com.SetCmd(&m_Cmd); //协议层与通讯层对接m_Com.Create(m_nPort); //打开通讯串口}void CVoyTestDlg::OnForward(){// TODO: Add your control notification handler code here m_Cmd.SetBothMotorsSpeed(100,100); //前行 }void CVoyTestDlg::OnBackward(){// TODO: Add your control notification handler code here m_Cmd.SetBothMotorsSpeed(-100,-100);//后退 }void CVoyTestDlg::OnTureleft(){// TODO: Add your control notification handler code here m_Cmd.SetBothMotorsSpeed(-100,100); //左转 }void CVoyTestDlg::OnTureright(){// TODO: Add your control notification handler code herem_Cmd.SetBothMotorsSpeed(100,-100); //右转 }void CVoyTestDlg::OnBrake(){// TODO: Add your control notification handler code herem_Cmd.Brake(1); //刹车}总结:1、程序调试及运行结果通过程序运行~我们可以看到足球机器人前进~后退~左转~右转及刹车等动作的分解。

相关主题