1. Trang chủ
  2. » Luận Văn - Báo Cáo

Điều khiển mô hình hệ thống theo vết đối tượng chuyển động trong thời gian thực

146 30 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

BỘ GIÁO DỤC VÀ ĐÀO TẠO ĐẠI HỌC QUỐC GIA THÀNH PHỐ HỒ CHÍ MINH TRƯỜNG ĐẠI HỌC BÁCH KHOA KHOA CƠ KHÍ " # Luận văn thạc sĩ ĐIỀU KHIỂN MƠ HÌNH HỆ THỐNG THEO VẾT ĐỐI TƯỢNG CHUYỂN ĐỘNG TRONG THỜI GIAN THỰC Hướng dẫn: TS Nguyễn Văn Giáp Học viên: Lê Ngọc Tuyền Lớp: Chế Tạo Máy, K15 Mã số: 00404096 THÀNH PHỐ HỒ CHÍ MINH 2006 Lý lịch trích ngang Họ tên: Lê Ngoc Tuyền Ngày tháng năm sinh: 01/01/1964 Nơi sinh: Quảng Ngãi Địa liên lạc: Phòng 416 c/c 657 Nguyễn Kiệm, P 9, Q Phú Nhuận Tp HCM QUÁ TRÌNH ĐÀO TẠO Đại học Chế độ học: quy Thời gian học: 1981 – 1986 Nơi học: Đại Học Bách Khoa HCM Ngành học: Cơ Khí Chế Tạo Máy Tên luận văn: Thiết Kế Máy Ép Than Tự Động Cao học Chế độ học: quy Thời gian học: 2004 – 2006 Nơi học: Đại Học Bách Khoa HCM Ngành học: Cơ Khí Chế Tạo Máy Tên luận văn: Điều Khiển Mơ Hình Hệ Thống Theo Vết Đối Tượng Chuyển Động Trong Thời Gian Thực Q TRÌNH CƠNG TÁC Từ 1986 Ỉ nay: cán giảng dạy mơn Hình Hoạ & Vẽ Kỹ Thuật, khoa Kỹ Thuật Xây Dựng, trường Đại Học Bách Khoa HCM TRƯỜNG ĐH BÁCH KHOA CỘNG HOÀ XÃ HỘI CHỦ NGHĨA VIỆT NAM PHÒNG ĐÀO TẠO SĐH ĐỘC LẬP - TỰ DO – HẠNH PHÚC -TpHCM, Ngày….tháng… năm 20… NHIỆM VỤ LUẬN VĂN THẠC SĨ I Họ tên học viên: LÊ NGỌC TUYỀN Phái: nam Ngày tháng năm sinh: 01 / 01 / 1964 Nơi sinh: Quảng Ngãi Chuyên ngành: Cơ Khí Chế Tạo Máy MSHV: 00404096 TÊN ĐỀ TÀI Điều Khiển Mơ Hình Hệ Thống Theo Vết Đối Tượng Chuyển Động Trong Thời Gian Thực II NHIỆM VỤ VÀ NỘI DUNG - Lắp đặt mơ hình thực hệ thống theo vết đối tượng - Viết chương trình phát mơ đối tượng chuyển động - Viết chương trình nhận dạng đối tượng chuyển động thu từ camera điều khiển hệ thống theo vết đối tượng - Điều độ hệ thống - Đánh giá kết III NGÀY GIAO NHIỆM VỤ: IV NGÀY HOÀN THÀNH NHIỆM VỤ: V CÁN BỘ HƯỚNG DẪN: TS Nguyễn Văn Giáp CÁN BỘ HƯỚNG DẪN CN BỘ MÔN QL CHUYÊN NGÀNH TS Nguyễn Văn Giáp Nội dung yêu cầu LVTN hội đồng chuyên ngành thông qua Ngày TRƯỞNG PHÒNG ĐTSĐH tháng năm TRƯỞNG KHOA QUẢN LÝ NGÀNH Tóm tắt Đề tài luận văn thạc sĩ “Điều khiển mơ hình hệ thống theo vết đối tượng chuyển động” nhằm thử nghiệm việc thêm chiều thời gian vào không gian điều khiển Phương pháp thử nghiệm chế tạo mơ hình vật lý hệ thống quay theo vết đối tượng chuyển động xây dựng phần mềm điều khiển mơ hình hoạt động thời gian thực Mơ hình thu nhận hình ảnh mơi trường qua cảm biến camera, máy tính phân tích nhận dạng đối tượng chuyển động điều khiển mơ hình quay hướng đối tượng chuyển động lựa chọn Ngoài ra, để thử nghiệm số giải thuật điều độ thời gian thực, đề tài có đề thêm nhiệm vụ cho mơ hình tiêu diệt đối tượng chuyển động đối tượng đến vị trí giới hạn trước chúng biến khỏi tầm quan sát camera Lời cảm ơn Chân thành cảm ơn thầy Nguyễn Văn Giáp, chủ nhiệm môn Cơ Điện Tử, trường đại học Bách Khoa thành phố Hồ Chí Minh hướng dẫn để có luận văn Khơng có thầy, luận văn chắn khơng thể hồn thành Cám ơn thầy hội đồng bảo vệ đề cương luận văn thạc sĩ dẫn cho nhận xét quý báu Cám ơn thầy môn Cơ Điện Tử cung cấp thông tin, tài liệu nhiều dẫn bổ ích cho việc hồn thành luận văn Cám ơn gia đình, đồng nghiệp bạn bè động viên, góp ý giúp đỡ cho việc hoàn thành luận văn Mục lục Chương Tổng quan 1.1 Cơ sở nghiên cứu 1.2 Vấn đề nghiên cứu .2 1.3 Tình hình nghiên cứu hệ thống thời gian thực .2 1.4 Phương pháp nghiên cứu .5 1.5 Mục tiêu đề tài .6 1.6 Các nội dung cần giải luận văn 1.7 Giới hạn phạm vi thực luận văn Chương 2.1 Giới thiệu mơ hình Phần cứng 2.1.1 Cơ sở thiết kế xây dựng phần cứng mơ hình 2.1.2 Bộ phận quan sát 10 2.1.3 Bộ phận chuyển động 10 2.1.4 Bộ phận điều khiển 11 2.1.5 Cân chỉnh hệ thống 11 2.2 Phần mềm 12 2.2.1 Yêu cầu phần mềm điều khiển 12 2.2.2 Công cụ thiết lập phần mềm 12 2.2.3 Yêu cầu để chạy phần mềm 13 2.2.4 Giao diện phần mềm 13 2.2.5 Bắt hình từ camera 14 2.2.6 Theo vết đối tượng chuyển động 15 2.2.7 Điều độ hệ thống 16 2.2.8 Điều chỉnh vận hành động 17 2.2.9 Tiêu diệt đối tượng 19 2.2.10 Phát chương trình mơ 20 2.3 Chương trình mô đối tượng chuyển động .22 2.3.1 Giới thiệu 22 2.3.2 Các tác vụ chương trình mơ 24 Chương 3.1 Thiết kế tổng quát chương trình ứng dụng 26 Xác định yêu cầu hệ thống 26 3.1.1 Các yêu cầu chức 26 3.1.2 Các yêu cầu thời gian an toàn 26 3.2 Xác định đặc tính kỹ thuật chương trình .27 3.2.1 Quá trình nhận dạng điều khiển 27 3.2.2 Quá trình nhận dạng điều khiển song song 28 3.3 Hiện thực chương trình 29 Chương 4.1 Xác định đối tượng chuyển động camera 30 Một số phương pháp theo vết đối tượng chuyển động .30 4.1.1 Thuật toán mean-shift giải thuật theo vết sở thuật toán mean-shift – theo vết chuyển động chiều (2D motion tracking) 30 4.1.2 Phương pháp phân chia chuyển động (motion segmentation) 31 4.1.3 Sử dụng hai camera (stereo vision) – theo vết chuyển động chiều (3D motion 31 tracking) 4.2 Xác định đối tượng chuyển động chương trình ứng dụng 32 4.2.1 Bỏ hình 32 4.2.2 Biểu diễn lại chuyển động 32 4.2.3 Phân chia chuyển động (motion segmentation) 33 4.2.4 Xác định đối tuợng chuyển động 34 4.2.5 Kết xuất liệu 35 Chương Điều khiển theo vết đối tượng 36 5.1 Đổi toạ độ 36 5.2 Điều khiển động 39 5.3 Dự đoán thời gian vận hành động 40 Chương 6.1 Điều độ hệ thống 42 Giới thiệu 42 6.1.1 Kiểm tra tính khả thi 42 6.1.2 Xây dựng kế hoạch điều độ 43 6.1.3 Thực tác vụ 45 6.2 Hiện thực chương trình điều độ 45 6.2.1 Kiểm tra tính khả thi 45 6.2.2 Xây dựng kế hoạch điều độ thực điều khiển 46 Chương Đánh giá kết 48 7.1 Phương pháp đánh giá 48 7.2 Đánh giá hoạt động động theo vết đối tượng .48 7.2.1 Đánh giá điều kiện vận hành tốt 48 7.2.2 Thay đổi tốc độ động cơ: 50 7.2.3 Đánh giá khả dự đoán 50 7.3 Đánh giá hoạt động điều độ .52 7.3.1 Khi tài nguyên tối đa 52 7.3.2 Khi tài nguyên hệ thống có giới hạn 53 Chương Kết luận 55 8.1 Mức độ hoàn thành đề tài 55 8.2 Huớng phát triển đề tài 56 Tài liệu tham khảo 57 Chương 1.1 Tổng quan Cơ sở nghiên cứu Các hệ thống thời gian thực (real-time systems) phát triển mạnh thời gian gần Các hệ thống xuất khắp nơi sống hàng ngày Động lực phát triển hệ thống thời gian thực phát triển mạnh mẽ kỹ thuật thông tin Trong nhiều lãnh vực công nghiệp, việc sử dụng hệ thống thời gian thực thay chẳng hạn hệ thống điều khiển bay, hệ thống điều khiển tàu không gian thoi, hệ thống điều khiển điện tử hàng không, hệ thống điều khiển kế hoạch lượng hạt nhân…[H Kopetz-97] Sự phát triển hệ thống thời gian thực cho phép thay hệ thống cũ (thủy lực, khí) an tồn hệ thống thời gian thực hoạt động theo thời gian tới hạn (time-critical) có độ an tồn cao Thuận lợi yếu thay gia tăng độ an toàn thiết bị giảm chi phí cho việc phát triển, bảo trì thiết bị Sự thay giảm chi phí toàn hệ thống, giảm trọng lượng, cải thiện độ tin cậy tăng chất lượng phục vụ [G Bauer-00] Các ứng dụng hệ thống thời gian thực trải rộng từ vi điều khiển đơn giản đến hệ phân bố phức tạp cao cấp chẳng hạn hệ thống điều khiển bay, ứng dụng chế tạo linh hoạt, hệ thống thông minh, hệ thống truyền thông đa phương tiện tốc độ cao Nghiên cứu để hiểu rõ hệ thống thời gian thực, nghiên cứu việc lập trình điều khiển thời gian thực tạo thuận lợi cho việc ứng dụng hệ thống thời gian thực ngành công nghiệp điều khiển Để có cơng cụ thử nghiệm, đánh giá, cần thiết phải xây mơ hình vật lý mô hệ thống điều khiển theo thời gian thực Việc điều khiển mơ hình hay gợi ý cho ứng dụng thời gian thực phức tạp sau Trang 1.2 Vấn đề nghiên cứu Theo Oxford Dictionary of Computing: Hệ thống thời gian thực hệ thống mà thời gian lúc đầu thiết lập có ý nghĩa, có ý nghĩa thơng thường đầu vào tương ứng với số vận động giới vật lý đầu phải có quan hệ với vận động Khoảng cách thời gian đầu vào thời gian đầu phải đủ nhỏ để tính hợp thời chấp nhận Theo Kopetz-97: Sự đắn hệ thống thời gian thực không phụ thuộc vào đắn kết chúng chuyển giao mà phụ thuộc vào thời gian lúc kết chuyển giao Như hệ thống thời gian thực xác định hệ thống mà đắn hệ thống phụ thuộc khơng kết logic tính tốn mà cịn phụ thuộc vào thời gian kết thiết lập Nếu ràng buộc thời gian hệ thống không thoả mãn sai hỏng xảy ra, vấn đề ràng buộc thời gian hệ thống phải bảo đảm thoả mãn Việc đảm bảo thời gian đòi hỏi hệ thống phải dự đốn được, nghĩa tác vụ kích hoạt phải có khả xác định thời gian hoàn thành cách chắn Có thể có số kiện xảy khoảng thời gian gần với tầm quan trọng kiện khác (ví dụ kiện có liên quan đến an tồn quan trọng yêu cầu ghi lại liệu) Khi tài nguyên hệ thống cần điều độ (schedule) để tất yêu cầu đáp ứng định mức thời gian chúng 1.3 Tình hình nghiên cứu hệ thống thời gian thực Về cấu trúc chương trình, kỹ thuật có từ nghiên cứu quản trị làm cho phân tích điều độ hệ thống thời gian thực báo Liu Layland (1973) kỹ thuật trì ảnh hưởng chúng thập kỷ Đây thời gian phát triển kỹ thuật cho ngơn ngữ lập trình báo Hoare (1969) Jensen (1976) đưa hàm thời gian tiện ích (time/utility functions) cho kế hoạch rada quân đội Hoa Kỳ để chống tên lửa đạn đạo – SAFEGUARD Jensen (1983) tiếp tục nghiên cứu hàm Trang this->Controls->Add(this->closeButton); this->Controls->Add(this->manualRunButton); this->Controls->Add(this->m2CheckBox); this->Controls->Add(this->m2UpDown); this->Controls->Add(this->groupBox2); this->Controls->Add(this->m1CheckBox); this->Controls->Add(this->m1UpDown); this->Controls->Add(this->groupBox1); this->Controls->Add(this->label6); this->MaximizeBox = false; this->Name = L"Calib"; this->Text = L"Calibrate and Adjust Motor"; this->groupBox1->ResumeLayout(false); this->groupBox1->PerformLayout(); (cli::safe_cast (this->m1UpDown))->EndInit(); this->groupBox2->ResumeLayout(false); this->groupBox2->PerformLayout(); (cli::safe_cast (this->m2UpDown))->EndInit(); (cli::safe_cast (this->xCamLocationUpDown))->EndInit(); (cli::safe_cast (this->yCamLocationUpDown))->EndInit(); cli::safe_cast (this->numOfPulseUpDown))->EndInit(); this->groupBox3->ResumeLayout(false); this->groupBox3->PerformLayout(); (cli::safe_cast (this->viewDistUpDown))->EndInit(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void closeButton_Click(System::Object^ sender, System::EventArgs^ e) { this->Close(); } private: System::Void manualRunButton_Click(System::Object^ sender, System::EventArgs^ e) { int counter1 = (int)this->m1UpDown->Value; int counter2 = (int)this->m2UpDown->Value; short pData1 = 0; short pData2 = 0; if (this->m1CheckBox->Checked) if (this->rLeft->Checked) pData1 = LEFT; else pData1 = RIGHT; else counter1 = 0; if (this->m2CheckBox->Checked) if (this->rDown->Checked) pData2 = DOWN; else pData2 = UP; else counter2 = 0; if ((abs(myCon->cMotor->x) > LIMIT_LOCATION)|| (abs(myCon->cMotor->x) > LIMIT_LOCATION)) { Trang 65 } else System::Windows::Forms::DialogResult result; result = MessageBox::Show(this,L"Motor chạy giơi hạn! Tiếp tục?","Alert",MessageBoxButtons::YesNo); if (result == ::DialogResult::Yes){ myCon->Run(pData1,counter1,pData2,counter2); } myCon->Run(pData1,counter1,pData2,counter2); } private: System::Void gotoButton_Click(System::Object^ sender, System::EventArgs^ e) if (!myCon->setHomeFlag){ MessageBox::Show("Please Set Home first"); else yCon->GotoXY((int)xCamLocationUpDown->Value, (int)yCamLocationUpDown->Value); } private: System::Void setHomeButton_Click(System::Object^ sender, System::EventArgs^ e) { if (!myCon->setHomeFlag){ myCon->cMotor->x = myCon->CtoM(-myCon->xOffset); myCon->cMotor->y = 0; myCon->setHomeFlag = true; } else{ System::Windows::Forms::DialogResult result; result = MessageBox::Show(this,L"Đặt lại vị trí gốc?", "Reset Home", MessageBoxButtons::YesNo); if (result == ::DialogResult::Yes){ myCon->cMotor->x = myCon->CtoM(-myCon->xOffset); myCon->cMotor->y = 0; } } } private: System::Void goHomeButton_Click(System::Object^ sender, System::EventArgs^ e) { int counter1, counter2; short pData1, pData2; counter1 = myCon->cMotor->x - myCon->CtoM(-myCon->xOffset); counter2 = myCon->cMotor->y; if (counter1 < 0){ pData1 = RIGHT; counter1 = -counter1; } else pData1 = LEFT; if (counter2 < 0){ pData2 = DOWN; counter2 = -counter2; } else pData2 = UP; myCon->Run(pData1,counter1,pData2,counter2); } private: System::Void rateRadioButton_CheckedChanged(System::Object^ sender, System::EventArgs^ e) { myCon->allPulse = this->allPulseRadio->Checked; } private: System::Void numOfPulseUpDown_ValueChanged(System::Object^ Trang 66 sender, System::EventArgs^ e) { myCon->numOfPulse = (int)this->numOfPulseUpDown->Value; } private: System::Void viewDistUpDown_ValueChanged(System::Object^ System::EventArgs^ e) { myCon->viewDist = (float)this->viewDistUpDown->Value; } }; } sender, B.6 Đối tượng phát mô phỏng: DemoObj.h DemoObj.cpp Khai báo: DemoObj.h #pragma once #include "cv.h" #include "cxcore.h" #include "highgui.h" #include "DemoPara.h" using namespace System; using namespace System::Drawing; ref class DemoObj : public Object{ public: float cx; float cy; int radius; float vx; float vy; CvScalar* color; InitDemoObjValue* demoVal; DemoObj(InitDemoObjValue* _demoVal); ~DemoObj(void); void InitValue(void); void GetRandomColor(unsigned char minc, CvScalar* color); void Draw(IplImage* g); bool DeleteObj(int w, int h); bool ToBound(int w, int h); void SetReflexVelo(bool xminus); }; Hiện thực: DemoObj.cpp #include "StdAfx.h" #include "DemoObj.h" #include "CamImg.h" DemoObj::DemoObj(InitDemoObjValue* _demoVal){ demoVal = _demoVal; Random^ rand = gcnew Random(); radius = rand->Next(demoVal->rMin, demoVal->rMax); color = new CvScalar(); InitValue(); delete rand; } DemoObj::~DemoObj(void){ if (color) delete color; } void DemoObj::InitValue(void){ Random^ rand = gcnew Random(); cx = (float)radius; cy = (float)(rand->NextDouble()) * (IH - 2*radius) + radius; Trang 67 vx = (float)(rand->NextDouble()) * (demoVal->vxMax - demoVal->vxMin) + demoVal->vxMin; if (rand->Next(0,1)) vx = -vx; vy = (float)(rand->NextDouble()) * 2*demoVal->vyMax - demoVal->vyMax; GetRandomColor(demoVal->cMin, color); delete rand; } void DemoObj::GetRandomColor(unsigned char minc, CvScalar* color){ Random^ rand = gcnew Random(); unsigned int r = rand->Next(255); unsigned int g = rand->Next(255); unsigned int b = rand->Next(255); while ( (r < minc) && (g < minc)) { r = rand->Next(minc, 255); g = rand->Next(minc, 255); } delete rand; *color = CV_RGB(r,g,b); } void DemoObj::Draw(IplImage* g){cvRectangle(g,cvPoint(Math::Round( cx - radius),Math::Round(cy - radius)), cvPoint(Math::Round(cx + radius),Math::Round(cy + radius)),*color, -1); } bool DemoObj::DeleteObj(int w, int h){ if (((cx + radius)< 0) || ((cx - radius)> w) || ((cy + radius)< 0) || ((cy - radius)> h) ) return true; return false; } bool DemoObj::ToBound(int w, int h){ if ((cx - (float)radius)>0 && (cx + (float)radius)0 && (cy + (float)radius)NextDouble()) * (demoVal->vxMax - demoVal->vxMin) + demoVal->vxMin; vyNew = (float)(rand->NextDouble()) * (demoVal->vxMax - demoVal->vxMin) + demoVal->vxMin; if (xminus) Trang 68 else } if (vx * vxNew > 0) vx = -vxNew; else vx = vxNew; if (vy * vyNew > 0) vy = -vyNew; else vy = vyNew; delete rand; Cài đặt giá trị: DemoPara.h #pragma once typedef struct InitDemoObjValue{ int rMin; int rMax; float vxMin; float vxMax; float vyMin; float vyMax; int cMin; int objMax; int maxTimeCreateObject; int timeWriteFile; InitDemoObjValue() { rMin = 7; rMax = 10; vxMin = 2; vxMax = 5; vyMin = 0; vyMax = 3; cMin = 220; objMax = 4; maxTimeCreateObject = 2000; timeWriteFile = 30; } }InitDemoObjValue; using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; namespace MT { public ref class DemoPara : public System::Windows::Forms::Form{ InitDemoObjValue* demoVal; public: DemoPara(InitDemoObjValue* _demoVal){ InitializeComponent(); demoVal = _demoVal; rMinUpDown->Value = demoVal->rMin; rMaxUpDown->Value = demoVal->rMax; vxMinUpDown->Value = (Decimal)demoVal->vxMin; vxMaxUpDown->Value = (Decimal)demoVal->vxMax; vyMinUpDown->Value = (Decimal)demoVal->vyMin; vyMaxUpDown->Value = (Decimal)demoVal->vyMax; colorMinUpDown->Value = demoVal->cMin; timeWriteFileUpDown->Value = (Decimal)demoVal->timeWriteFile; objMaxUpDown->Value = demoVal->objMax; timeCreateObjUpDown->Value = demoVal->maxTimeCreateObject; } Trang 69 protected: ~DemoPara(){ if (components){ delete components; } } private: System::Windows::Forms::NumericUpDown^ rMinUpDown; private: System::Windows::Forms::NumericUpDown^ rMaxUpDown; private: System::Windows::Forms::NumericUpDown^ vxMinUpDown; private: System::Windows::Forms::NumericUpDown^ vxMaxUpDown; private: System::Windows::Forms::NumericUpDown^ vyMinUpDown; private: System::Windows::Forms::NumericUpDown^ vyMaxUpDown; private: System::Windows::Forms::NumericUpDown^ colorMinUpDown; private: System::Windows::Forms::Label^ label1; private: System::Windows::Forms::Label^ label2; private: System::Windows::Forms::Label^ label3; private: System::Windows::Forms::Label^ label4; private: System::Windows::Forms::Label^ label5; private: System::Windows::Forms::Label^ label6; private: System::Windows::Forms::Label^ label7; private: System::Windows::Forms::Button^ cancelButton; private: System::Windows::Forms::Button^ okButton; private: System::Windows::Forms::Label^ label8; private: System::Windows::Forms::NumericUpDown^ objMaxUpDown; private: System::Windows::Forms::NumericUpDown^ timeWriteFileUpDown; private: System::Windows::Forms::Label^ label9; private: System::Windows::Forms::NumericUpDown^ timeCreateObjUpDown; private: System::Windows::Forms::Label^ label10; private: System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code void InitializeComponent(void){ this->rMinUpDown = (gcnew System::Windows::Forms::NumericUpDown()); this->rMaxUpDown = (gcnew System::Windows::Forms::NumericUpDown()); this->vxMinUpDown = (gcnew System::Windows::Forms::NumericUpDown()); this->vxMaxUpDown = (gcnew System::Windows::Forms::NumericUpDown()); this->vyMinUpDown = (gcnew System::Windows::Forms::NumericUpDown()); this->vyMaxUpDown = (gcnew System::Windows::Forms::NumericUpDown()); this->colorMinUpDown = (gcnew System::Windows::Forms::NumericUpDown()); this->label1 = (gcnew System::Windows::Forms::Label()); this->label2 = (gcnew System::Windows::Forms::Label()); this->label3 = (gcnew System::Windows::Forms::Label()); this->label4 = (gcnew System::Windows::Forms::Label()); this->label5 = (gcnew System::Windows::Forms::Label()); this->label6 = (gcnew System::Windows::Forms::Label()); this->label7 = (gcnew System::Windows::Forms::Label()); this->cancelButton = (gcnew System::Windows::Forms::Button()); this->okButton = (gcnew System::Windows::Forms::Button()); this->label8 = (gcnew System::Windows::Forms::Label()); this->objMaxUpDown = (gcnew System::Windows::Forms::NumericUpDown()); this->timeWriteFileUpDown = (gcnew System::Windows::Forms::NumericUpDown()); this->label9 = (gcnew System::Windows::Forms::Label()); this->timeCreateObjUpDown = (gcnew System::Windows::Forms::NumericUpDown()); this->label10 = (gcnew System::Windows::Forms::Label()); (cli::safe_cast (this->rMinUpDown))->BeginInit(); (cli::safe_cast (this->rMaxUpDown))->BeginInit(); Trang 70 (cli::safe_cast (this->vxMinUpDown))->BeginInit(); (cli::safe_cast (this->vxMaxUpDown))->BeginInit(); (cli::safe_cast (this->vyMinUpDown))->BeginInit(); (cli::safe_cast (this->vyMaxUpDown))->BeginInit(); (cli::safe_cast (this->colorMinUpDown))->BeginInit(); (cli::safe_cast (this->objMaxUpDown))->BeginInit(); (cli::safe_cast (this->timeWriteFileUpDown))->BeginInit(); (cli::safe_cast (this->timeCreateObjUpDown))->BeginInit(); this->SuspendLayout(); // rMinUpDown this->rMinUpDown->Location = System::Drawing::Point(13, 13); this->rMinUpDown->Maximum = System:: Decimal(gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0}); this->rMinUpDown->Minimum = System::Decimal( gcnew cli::array< System::Int32 >(4) {2, 0, 0, 0}); this->rMinUpDown->Name = L"rMinUpDown"; this->rMinUpDown->Size = System::Drawing::Size(50, 20); this->rMinUpDown->TabIndex = 0; this->rMinUpDown->Value = System::Decimal( gcnew cli::array< System::Int32 >(4) {7, 0, 0, 0}); this->rMinUpDown->ValueChanged += gcnew System::EventHandler( this, &DemoPara::rMinUpDown_ValueChanged); // rMaxUpDown this->rMaxUpDown->Location = System::Drawing::Point(136, 12); this->rMaxUpDown->Maximum = System::Decimal( gcnew cli::array< System::Int32 >(4) {20, 0, 0, 0}); this->rMaxUpDown->Minimum = System::Decimal( gcnew cli::array< System::Int32 >(4) {3, 0, 0, 0}); this->rMaxUpDown->Name = L"rMaxUpDown"; this->rMaxUpDown->Size = System::Drawing::Size(50, 20); this->rMaxUpDown->TabIndex = 1; this->rMaxUpDown->Value = System::Decimal( gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0}); this->rMaxUpDown->ValueChanged += gcnew System::EventHandler( this, &DemoPara::rMaxUpDown_ValueChanged); // vxMinUpDown this->vxMinUpDown->DecimalPlaces = 1; this->vxMinUpDown->Increment = System::Decimal( gcnew cli::array< System::Int32 >(4) {1, 0, 0, 65536}); this->vxMinUpDown->Location = System::Drawing::Point(13, 39); this->vxMinUpDown->Maximum = System::Decimal( gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0}); this->vxMinUpDown->Minimum = System::Decimal( gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0}); this->vxMinUpDown->Name = L"vxMinUpDown"; this->vxMinUpDown->Size = System::Drawing::Size(50, 20); this->vxMinUpDown->TabIndex = 2; this->vxMinUpDown->Value = System::Decimal( gcnew cli::array< System::Int32 >(4) {2, 0, 0, 0}); this->vxMinUpDown->ValueChanged += gcnew System::EventHandler( this, &DemoPara::vxMinUpDown_ValueChanged); // vxMaxUpDown this->vxMaxUpDown->DecimalPlaces = 1; Trang 71 this->vxMaxUpDown->Increment = System::Decimal( gcnew cli::array< System::Int32 >(4) {1, 0, 0, 65536}); this->vxMaxUpDown->Location = System::Drawing::Point(136, 39); this->vxMaxUpDown->Maximum = System::Decimal( gcnew cli::array< System::Int32 >(4) {20, 0, 0, 0}); this->vxMaxUpDown->Minimum = System::Decimal( gcnew cli::array< System::Int32 >(4) {2, 0, 0, 0}); this->vxMaxUpDown->Name = L"vxMaxUpDown"; this->vxMaxUpDown->Size = System::Drawing::Size(50, 20); this->vxMaxUpDown->TabIndex = 3; this->vxMaxUpDown->Value = System::Decimal( gcnew cli::array< System::Int32 >(4) {5, 0, 0, 0}); this->vxMaxUpDown->ValueChanged += gcnew System::EventHandler( this, &DemoPara::vxMaxUpDown_ValueChanged); // vyMinUpDown this->vyMinUpDown->DecimalPlaces = 1; this->vyMinUpDown->Location = System::Drawing::Point(13, 65); this->vyMinUpDown->Maximum = System::Decimal( gcnew cli::array< System::Int32 >(4) {10, 0, 0, 0}); this->vyMinUpDown->Name = L"vyMinUpDown"; this->vyMinUpDown->Size = System::Drawing::Size(50, 20); this->vyMinUpDown->TabIndex = 4; this->vyMinUpDown->ValueChanged += gcnew System::EventHandler( this, &DemoPara::vyMinUpDown_ValueChanged); // vyMaxUpDown this->vyMaxUpDown->DecimalPlaces = 1; this->vyMaxUpDown->Increment = System::Decimal( gcnew cli::array< System::Int32 >(4) {1, 0, 0, 65536}); this->vyMaxUpDown->Location = System::Drawing::Point(136, 65); this->vyMaxUpDown->Maximum = System::Decimal( gcnew cli::array< System::Int32 >(4) {20, 0, 0, 0}); this->vyMaxUpDown->Minimum = System::Decimal( gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0}); this->vyMaxUpDown->Name = L"vyMaxUpDown"; this->vyMaxUpDown->Size = System::Drawing::Size(50, 20); this->vyMaxUpDown->TabIndex = 5; this->vyMaxUpDown->Value = System::Decimal( gcnew cli::array< System::Int32 >(4) {3, 0, 0, 0}); this->vyMaxUpDown->ValueChanged += gcnew System::EventHandler( this, &DemoPara::vyMaxUpDown_ValueChanged); // colorMinUpDown this->colorMinUpDown->Location = System::Drawing::Point(13, 91); this->colorMinUpDown->Maximum = System::Decimal( gcnew cli::array< System::Int32 >(4) {254, 0, 0, 0}); this->colorMinUpDown->Minimum = System::Decimal( gcnew cli::array< System::Int32 >(4) {128, 0, 0, 0}); this->colorMinUpDown->Name = L"colorMinUpDown"; this->colorMinUpDown->Size = System::Drawing::Size(50, 20); this->colorMinUpDown->TabIndex = 6; this->colorMinUpDown->Value = System::Decimal( gcnew cli::array< System::Int32 >(4) {220, 0, 0, 0}); // label1 this->label1->AutoSize = true; this->label1->Location = System::Drawing::Point(69, 20); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(35, 13); this->label1->TabIndex = 7; this->label1->Text = L"R Min"; // label2 this->label2->AutoSize = true; this->label2->Location = System::Drawing::Point(192, 19); Trang 72 this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(38, 13); this->label2->TabIndex = 8; this->label2->Text = L"R Max"; // label3 this->label3->AutoSize = true; this->label3->Location = System::Drawing::Point(69, 46); this->label3->Name = L"label3"; this->label3->Size = System::Drawing::Size(41, 13); this->label3->TabIndex = 9; this->label3->Text = L"VX Min"; // label4 this->label4->AutoSize = true; this->label4->Location = System::Drawing::Point(192, 46); this->label4->Name = L"label4"; this->label4->Size = System::Drawing::Size(44, 13); this->label4->TabIndex = 10; this->label4->Text = L"VX Max"; // label5 this->label5->AutoSize = true; this->label5->Location = System::Drawing::Point(69, 72); this->label5->Name = L"label5"; this->label5->Size = System::Drawing::Size(41, 13); this->label5->TabIndex = 11; this->label5->Text = L"VY Min"; // label6 this->label6->AutoSize = true; this->label6->Location = System::Drawing::Point(192, 72); this->label6->Name = L"label6"; this->label6->Size = System::Drawing::Size(44, 13); this->label6->TabIndex = 12; this->label6->Text = L"VY Max"; // label7 this->label7->AutoSize = true; this->label7->Location = System::Drawing::Point(70, 97); this->label7->Name = L"label7"; this->label7->Size = System::Drawing::Size(48, 13); this->label7->TabIndex = 13; this->label7->Text = L"Màu Min"; // cancelButton this->cancelButton->Location = System::Drawing::Point(13, 178); this->cancelButton->Name = L"cancelButton"; this->cancelButton->Size = System::Drawing::Size(75, 23); this->cancelButton->TabIndex = 14; this->cancelButton->Text = L"Cancel"; this->cancelButton->UseVisualStyleBackColor = true; this->cancelButton->Click += gcnew System::EventHandler( this, &DemoPara::cancelButton_Click); // okButton this->okButton->Location = System::Drawing::Point(155, 178); this->okButton->Name = L"okButton"; this->okButton->Size = System::Drawing::Size(75, 23); this->okButton->TabIndex = 15; this->okButton->Text = L"OK"; this->okButton->UseVisualStyleBackColor = true; this->okButton->Click += gcnew System::EventHandler( this, &DemoPara::okButton_Click); // label8 this->label8->AutoSize = true; this->label8->Location = System::Drawing::Point(192, 93); this->label8->Name = L"label8"; Trang 73 this->label8->Size = System::Drawing::Size(46, 13); this->label8->TabIndex = 16; this->label8->Text = L"Max Obj"; // objMaxUpDown this->objMaxUpDown->Location = System::Drawing::Point(136, 91); this->objMaxUpDown->Maximum = System::Decimal( gcnew cli::array< System::Int32 >(4) {20, 0, 0, 0}); this->objMaxUpDown->Minimum = System::Decimal( gcnew cli::array< System::Int32 >(4) {1, 0, 0, 0}); this->objMaxUpDown->Name = L"objMaxUpDown"; this->objMaxUpDown->Size = System::Drawing::Size(50, 20); this->objMaxUpDown->TabIndex = 17; this->objMaxUpDown->Value = System::Decimal( gcnew cli::array< System::Int32 >(4) {4, 0, 0, 0}); // timeWriteFileUpDown this->timeWriteFileUpDown->Location = System::Drawing::Point(12,152); this->timeWriteFileUpDown->Maximum = System::Decimal( gcnew cli::array< System::Int32 >(4) {120, 0, 0, 0}); this->timeWriteFileUpDown->Minimum = System::Decimal( gcnew cli::array< System::Int32 >(4) {30, 0, 0, 0}); this->timeWriteFileUpDown->Name = L"timeWriteFileUpDown"; this->timeWriteFileUpDown->Size = System::Drawing::Size(51, 20); this->timeWriteFileUpDown->TabIndex = 33; this->timeWriteFileUpDown->Value = System::Decimal( gcnew cli::array< System::Int32 >(4) {30, 0, 0, 0}); // label9 this->label9->AutoSize = true; this->label9->Location = System::Drawing::Point(69, 154); this->label9->Name = L"label9"; this->label9->Size = System::Drawing::Size(98, 13); this->label9->TabIndex = 34; this->label9->Text = L"Thời gian ghi file (s)"; // timeCreateObjUpDown this->timeCreateObjUpDown->Increment = System::Decimal( gcnew cli::array< System::Int32 >(4) {100, 0, 0, 0}); this->timeCreateObjUpDown->Location = System::Drawing::Point(13,118); this->timeCreateObjUpDown->Maximum = System::Decimal( gcnew cli::array< System::Int32 >(4) {5000, 0, 0, 0}); this->timeCreateObjUpDown->Minimum = System::Decimal( gcnew cli::array< System::Int32 >(4) {100, 0, 0, 0}); this->timeCreateObjUpDown->Name = L"timeCreateObjUpDown"; this->timeCreateObjUpDown->Size = System::Drawing::Size(50, 20); this->timeCreateObjUpDown->TabIndex = 35; this->timeCreateObjUpDown->Value = System::Decimal( gcnew cli::array< System::Int32 >(4) {2000, 0, 0, 0}); // label10 this->label10->AutoSize = true; this->label10->Location = System::Drawing::Point(70, 120); this->label10->Name = L"label10"; this->label10->Size = System::Drawing::Size(161, 13); this->label10->TabIndex = 36; this->label10->Text = L"Thời gian tạo đối tượng max (ms)"; // DemoPara this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(242, 218); this->ControlBox = false; this->Controls->Add(this->label10); this->Controls->Add(this->timeCreateObjUpDown); this->Controls->Add(this->label9); this->Controls->Add(this->timeWriteFileUpDown); Trang 74 this->Controls->Add(this->objMaxUpDown); this->Controls->Add(this->label8); this->Controls->Add(this->okButton); this->Controls->Add(this->cancelButton); this->Controls->Add(this->label7); this->Controls->Add(this->label6); this->Controls->Add(this->label5); this->Controls->Add(this->label4); this->Controls->Add(this->label3); this->Controls->Add(this->label2); this->Controls->Add(this->label1); this->Controls->Add(this->colorMinUpDown); this->Controls->Add(this->vyMaxUpDown); this->Controls->Add(this->vyMinUpDown); this->Controls->Add(this->vxMaxUpDown); this->Controls->Add(this->vxMinUpDown); this->Controls->Add(this->rMaxUpDown); this->Controls->Add(this->rMinUpDown); this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle; this->MaximizeBox = false; this->MinimizeBox = false; this->Name = L"DemoPara"; this->Text = L"Demo Object Parameter"; (cli::safe_castrMinUpDown))->EndInit(); (cli::safe_castrMaxUpDown))->EndInit(); (cli::safe_castvxMinUpDown))->EndInit(); (cli::safe_castvxMaxUpDown))->EndInit(); (cli::safe_castvyMinUpDown))->EndInit(); (cli::safe_castvyMaxUpDown))->EndInit(); (cli::safe_castcolorMinUpDown))->EndInit(); (cli::safe_castobjMaxUpDown))->EndInit(); (cli::safe_casttimeWriteFileUpDown))->EndInit(); (cli::safe_casttimeCreateObjUpDown))->EndInit(); this->ResumeLayout(false); this->PerformLayout(); > > > > > > > > > > } #pragma endregion private: System::Void rMinUpDown_ValueChanged(System::Object^ sender, System::EventArgs^ e) { if (rMinUpDown->Value > (rMaxUpDown->Value-1)) rMinUpDown->Value = rMaxUpDown->Value-1; } private: System::Void rMaxUpDown_ValueChanged(System::Object^ sender, System::EventArgs^ e) { if (rMinUpDown->Value > (rMaxUpDown->Value-1)) rMaxUpDown->Value = rMinUpDown->Value+1; } private: System::Void vxMinUpDown_ValueChanged(System::Object^ sender, System::EventArgs^ e) { if (this->vxMinUpDown->Value > (vxMaxUpDown->Value-1)) Trang 75 vxMinUpDown->Value = vxMaxUpDown->Value-1; } private: System::Void vxMaxUpDown_ValueChanged(System::Object^ sender, System::EventArgs^ e) { if (this->vxMinUpDown->Value > (vxMaxUpDown->Value-1)) vxMaxUpDown->Value = vxMinUpDown->Value+1; } private: System::Void vyMinUpDown_ValueChanged(System::Object^ sender, System::EventArgs^ e) { if (this->vyMinUpDown->Value > (vyMaxUpDown->Value-1)) vyMinUpDown->Value = vyMaxUpDown->Value-1; } private: System::Void vyMaxUpDown_ValueChanged(System::Object^ sender, System::EventArgs^ e) { if (this->vyMinUpDown->Value > (vyMaxUpDown->Value-1)) vyMaxUpDown->Value = vyMinUpDown->Value+1; } private: System::Void okButton_Click(System::Object^ sender, System::EventArgs^ e) { demoVal->rMin = (int)rMinUpDown->Value; demoVal->rMax = (int)rMaxUpDown->Value; demoVal->vxMin = (float)vxMinUpDown->Value; demoVal->vxMax = (float)vxMaxUpDown->Value; demoVal->vyMin = (float)vyMinUpDown->Value; demoVal->vyMax = (float)vyMaxUpDown->Value; demoVal->cMin = (int)colorMinUpDown->Value; demoVal->objMax = (int)this->objMaxUpDown->Value; demoVal->maxTimeCreateObject = (int)this->timeCreateObjUpDown->Value; demoVal->timeWriteFile = (int)this->timeWriteFileUpDown->Value; this->Close(); } private: System::Void cancelButton_Click(System::Object^ sender, System::EventArgs^ e) { this->Close(); } }; } B.7 Liên kết mạng: NetWork.h #pragma once using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::Net; using namespace System::Net::Sockets; using namespace System::Text; namespace MT { public ref class Network : public System::Windows::Forms::Form{ public: System::Windows::Forms::Label^ label1; public: System::Windows::Forms::TextBox^ serverIPTextBox; public: System::Windows::Forms::Label^ label2; public: System::Windows::Forms::TextBox^ portTextBox; public: System::Windows::Forms::Button^ closeButton; IPEndPoint^ serverEP; Socket^ sSocket; Network(void){ Trang 76 InitializeComponent(); this->serverEP = gcnew IPEndPoint(IPAddress::Parse("172.28.36.129"), 9000); this->sSocket = gcnew Socket(serverEP->AddressFamily, SocketType::Stream, ProtocolType::Tcp); } protected: ~Network(){ if (components){ delete components; } if (serverEP) delete serverEP; if (sSocket) delete sSocket; } private: System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code void InitializeComponent(void){ this->label1 = (gcnew System::Windows::Forms::Label()); this->serverIPTextBox = (gcnew System::Windows::Forms::TextBox()); this->label2 = (gcnew System::Windows::Forms::Label()); this->portTextBox = (gcnew System::Windows::Forms::TextBox()); this->closeButton = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // label1 this->label1->AutoSize = true; this->label1->Location = System::Drawing::Point(9, 9); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(53, 13); this->label1->TabIndex = 0; this->label1->Text = L"Địa IP"; // serverIPTextBox this->serverIPTextBox->Location = System::Drawing::Point(70, 6); this->serverIPTextBox->Name = L"serverIPTextBox"; this->serverIPTextBox->Size = System::Drawing::Size(100, 20); this->serverIPTextBox->TabIndex = 1; this->serverIPTextBox->Text = L"172.28.36.129"; // label2 this->label2->AutoSize = true; this->label2->Location = System::Drawing::Point(9, 36); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(26, 13); this->label2->TabIndex = 2; this->label2->Text = L"Port"; // portTextBox this->portTextBox->Location = System::Drawing::Point(70, 33); this->portTextBox->Name = L"portTextBox"; this->portTextBox->Size = System::Drawing::Size(43, 20); this->portTextBox->TabIndex = 3; this->portTextBox->Text = L"9000"; // closeButton this->closeButton->Location = System::Drawing::Point(176, 31); this->closeButton->Name = L"closeButton"; this->closeButton->Size = System::Drawing::Size(75, 23); this->closeButton->TabIndex = 4; this->closeButton->Text = L"Close"; this->closeButton->UseVisualStyleBackColor = true; this->closeButton->Click += gcnew System::EventHandler(this, &Network::closeButton_Click); // Network this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); Trang 77 this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(263, 61); this->ControlBox = false; this->Controls->Add(this->closeButton); this->Controls->Add(this->portTextBox); this->Controls->Add(this->label2); this->Controls->Add(this->serverIPTextBox); this->Controls->Add(this->label1); this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedDialog; this->MaximizeBox = false; this->MinimizeBox = false; this->Name = L"Network"; this->Text = L"Network"; this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion public: void Network::ConnectServer(void){ if(sSocket->Connected){ System::Windows::Forms::DialogResult result; result = MessageBox::Show(L"Đang kết nối! Kết nối lại?", "Connect",MessageBoxButtons::YesNo ); if (result==::DialogResult::No) return; } try { this->sSocket->Connect(serverEP); } catch (SocketException^ e) { MessageBox::Show(e->ToString(),"Can't connect"); } if(sSocket->Connected) MessageBox::Show(L"Đã kết nối với server","Connect"); } private: System::Void closeButton_Click(System::Object^ sender, System::EventArgs^ e) { serverEP->Address = IPAddress::Parse(serverIPTextBox->Text); serverEP->Port = int::Parse(portTextBox->Text); this->Hide(); } public: void KillServerObject(Point cLocation){ array^ data; data = BitConverter::GetBytes(cLocation.X); data->Resize(data,8); data->Copy(BitConverter::GetBytes(cLocation.X),0,data,4,4); sSocket->Send(data,data->Length,SocketFlags::None); } }; } B.8 Khai báo cho báo cáo: Report.h typedef struct EvaluatePara{ int numOfCycle; int numOfObject; int numOfTimeMotorMove; int numOfTimeOut; Trang 78 int numOfKilledObject; int numOfObjectReachedLimitLine; int numOfObjectNotKilled; double totalMODist; double averateOfMODist; void Init(){ numOfCycle = 0; numOfObject = 0; numOfTimeMotorMove = 0; numOfTimeOut = 0; totalMODist = 0; averateOfMODist = 0; numOfKilledObject = 0; numOfObjectReachedLimitLine = 0; numOfObjectNotKilled = 0; } }EvaluatePara; Trang 79 ... TÀI Điều Khiển Mơ Hình Hệ Thống Theo Vết Đối Tượng Chuyển Động Trong Thời Gian Thực II NHIỆM VỤ VÀ NỘI DUNG - Lắp đặt mơ hình thực hệ thống theo vết đối tượng - Viết chương trình phát mơ đối tượng. .. tên là: ? ?Điều khiển mơ hình hệ thống theo vết đối tượng chuyển động thời gian thực? ?? 1.6 Các nội dung cần giải luận văn Xây dựng mô hình thực hệ thống quay hướng theo đối tượng chuyển động thu... đối tượng phát lệnh cho phận quay chuyển động theo vết đối tượng Trang Hình 1: Mơ hình hệ thống tự động quay theo đối tượng chuyển động Khi đối tượng vượt qua đường bao vị trí báo động, đối tượng

Ngày đăng: 10/02/2021, 23:01

Xem thêm:

TỪ KHÓA LIÊN QUAN

Mục lục

    Lý lịch trích ngang

    Cơ sở nghiên cứu

    Vấn đề nghiên cứu

    Phương pháp nghiên cứu

    Mục tiêu của đề tài

    Các nội dung cần giải quyết của luận văn

    Giới hạn phạm vi thực hiện của luận văn

    Giới thiệu mô hình

    Cơ sở thiết kế và xây dựng phần cứng của mô hình

    Bộ phận quan sát

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w