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

thiết kế và chế tạo mô hình robot scara phân loại sản phẩm theo màu sắc và hình dạng

129 107 2

Đ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

Nội dung

LỜI CẢM ƠN LỜI CẢM ƠN Để hoàn thành đề tài luận văn kết thúc khóa học, em xin bày tỏ lòng biết ơn sâu sắc đến trường Đại học kỹ thuật – công nghệ Cần Thơ tạo điều kiện cho em có mơi trường học tập tốt suốt thời gian học tập nghiên cứu trường Đặc biệt, em xin chân thành cảm ơn thầy Đường Khánh Sơn tận tình hướng dẫn giúp đỡ em q trình hồn thành luận văn Đồng thời, em gửi lời cảm ơn chân thành đến thầy khoa Kỹ thuật khí, gia đình bạn bè giúp đỡ tạo điều kiện tốt cho em trình học tập q trình hồn thành luận văn tốt nghiệp Em xin chân thành cảm ơn! SVTH: Phan Phúc Hậu Trang I LỜI CẢM ƠN LỜI CAM ĐOAN Em xin cam đoan đề tài: “Thiết kế chế tạo mơ hình Robot SCARA phân loại sản phẩm theo màu sắc hình dạng” cơng trình nghiên cứu thực cá nhân em hướng dẫn thầy Đường Khánh Sơn Trong báo cáo, tất số liệu, hình ảnh thơng tin đề tài em thu thập với thái độ khách quan trung thực Ngoài ra, số nguồn tài liệu tham khảo trích dẫn nguồn thích rõ ràng, khơng chép tài liệu mà khơng có trích dẫn Em xin hồn tồn chịu trách nhiệm trước mơn, khoa nhà trường cam đoan Sinh viên thực SVTH: Phan Phúc Hậu Trang II TÓM TẮT LUẬN VĂN TÓM TẮT LUẬN VĂN Đề tài luận văn “Thiết kế chế tạo mơ hình Robot Scara phân loại sản phẩm theo màu sắc hình dạng” bao gồm nội dung cốt lõi như: tìm hiểu khái niệm kiến thức Robot, thiết kế chế tạo mơ hình Robot Scara bậc tự hoạt động linh hoạt xác, thiết kế mạch điều khiển giao diện điều khiển cho Robot, xây dựng giải thuật PID điều khiển vị trí động DC, ứng dụng xử lý ảnh vào mơ hình để phân loại sản phẩm SVTH: Phan Phúc Hậu Trang III MỤC LỤC MỤC LỤC LỜI CẢM ƠN I LỜI CAM ĐOAN II TÓM TẮT LUẬN VĂN III MỤC LỤC i DANH MỤC HÌNH ẢNH iv DANH MỤC BẢNG iv CHƯƠNG 1: TỔNG QUAN 1.1 Tổng quan đề tài 1.1.1 Đặt vấn đề 1.1.2 Mục tiêu đề tài 1.1.3 Giới hạn đề tài 1.2 Giới thiệu sơ lượt Robot công nghiệp 1.2.1 Lịch sử hình thành phát triển 1.2.2 Cấu trúc Robot công nghiệp .5 1.2.3 Ứng dụng 10 1.3 Giới thiệu sơ lượt Robot Scara 11 CHƯƠNG 2: ĐỐI TƯỢNG VÀ PHƯƠNG PHÁP NGHIÊN CỨU 14 2.1 Đối tượng nghiên cứu .14 2.2 Phương pháp nghiêm cứu .14 2.2.1 Phần mềmMatlab 14 2.2.2 Matlab GUI .17 2.2.3 Xử lý ảnh Matlab .21 2.2.4 Phần mềm Invertor 27 SVTH: Phan Phúc Hậu Trang i MỤC LỤC 2.2.5 Arduino .29 2.2.6 Phần mềm Arduino IDE 32 2.2.7 PID 34 2.2.8 Chuẩn giao tiếp I2C 37 CHƯƠNG 3: THIẾT KẾ VÀ CHẾ TẠO MƠ HÌNH 41 3.1 Bài toán động học 41 3.1.1 Động học thuận 41 3.1.2 Động học ngược .42 3.2 Thiết kế mơ hình khí cho Robot .43 3.2.1 Cơ sở thiết kế 43 3.2.2 Bản vẽ thiết kế Robot Inventor 44 3.2.3 Chế tạo mơ hình khí .50 3.2.4 Lắp ráp mơ hình Robot Scara hoàn chỉnh 55 3.3 Thiết kế mạch điều khiển 57 3.3.1 Lưu đồ giải thuật điều khiển Robot 57 3.3.2 Sơ đồ mạch điều khiển Robot 58 CHƯƠNG 4: XỬ LÝ ẢNH VÀ THIẾT KẾ GIAO DIỆN NGƯỜI DÙNG 66 4.1 Xử lý ảnh 66 4.1.1 Giới thiệu hệ thống xử lý ảnh 66 4.1.2 Sơ lượt trình xử lý ảnh đề tài .68 4.1.3 Thu nhận ảnh đầu vào .69 4.1.4 Xác định vùng hoạt động Robot 70 4.1.5 Phân vùng ảnh tách sản phẩm 72 4.1.6 Nhận dạng đối tượng 74 SVTH: Phan Phúc Hậu Trang ii MỤC LỤC 4.1.7 Kết trình xử lý ảnh 77 4.2 Thiết kế giao diện người dùng 77 CHƯƠNG 5: KẾT QUẢ VÀ HƯỚNG PHÁT TRIỂN 79 5.1 Kết 79 5.1.1 Kết mô Matlab Simulink 79 5.1.2 Kết thực tế mơ hình Robot Scara 80 5.1.3 Kết chạy thực tế mơ hình Robot Scara 83 5.2 Đánh giá 90 5.3 Kết luận 90 5.3.1 Kết đạt .91 5.3.2 Những hạn chế đề tài 91 5.4 Hướng phát triển .91 TÀI LIỆU THAM KHẢO 93 PHỤ LỤC 94 SVTH: Phan Phúc Hậu Trang iii DANH MỤC HÌNH ẢNH DANH MỤC HÌNH ẢNH Hình 1.1: Dây chuyền sản xuất tơ tự động Robot Hình 1.2: Robot Scara phân loại sản phẩm Hình 1.3: Cánh tay Robot bậc tự hãng YASKAWA MOTOMAN Hình 1.4: Sơ đồ khối Robot cơng nghiệp .5 Hình 1.5: Các thành phần hệ thống Robot Hình 1.6: Phân loại Robot theo hình dạng hình học khơng gian hoạt động Hình 1.7: Sơ đồ điều khiển hở Hình 1.8: Sơ đồ điều khiển kín Hình 1.9: Robot xếp hàng thùng hàng lên pallet 10 Hình 1.10: Robot phun sơn tự động sản xuất ô tô 10 Hình 1.11: Robot hàn Panasonic .11 Hình 1.12: Ứng dụng Robot số lĩnh vực 11 Hình 1.13: Robot Scara .12 Hình 1.14: Robot SCARA hãng MITSUBISHI 12 Hình 1.15: Robot SCARA dây chuyền sản xuất linh hoạt 13 Hình 2.1: Phần mềm Matlab .15 Hình 2.2; Giao diện làm việc Matlab 16 Hình 2.3: Cửa sổ GUIDE Quick Start .18 Hình 2.4: Giao diện Blank GUI mặc định 18 Hình 2.5: Hộp thoại Inspector 20 Hình 2.6: Ảnh Index 22 Hình 2.7: Ảnh xám 23 Hình 2.8: Ảnh nhị phân .23 Hình 2.9: Ảnh RGB 24 Hình 2.10: Arduino Mega 2560 Arduino Uno R3 .29 Hình 2.11: Phần cứng Arduino Uno R3 .30 Hình 2.12: Ba loại Arduino phổ biến 31 Hình 2.13: Một số loại Arduino nâng cao 31 Hình 2.14: Phần mềm Arduino IDE 32 SVTH: Phan Phúc Hậu Trang iv DANH MỤC HÌNH ẢNH Hình 2.15: Một chương trình Arduino 33 Hình 2.16: Giao diện phần mềm Arduino IDE 33 Hình 2.17: Ba thành phần điều khiển PID 35 Hình 2.18: Mơ hình hệ thống điều khiển với PID 35 Hình 2.19: Sơ đồ truyền liệu I2C 38 Hình 2.20: Điều kiện START STOP 38 Hình 2.21: Điều kiện REPEATED START 39 Hình 2.22: Giao thức truyền nhận liệu I2C 39 Hình 3.1: Gắn hệ tọa độ cho Robot 41 Hình 3.2: Sắt .50 Hình 3.3: Sắt hộp .50 Hình 3.4: Nhơm 50 Hình 3.5: Động M555 51 Hình 3.6: Động Planet 52 Hình 3.7: Bộ truyền Pully dây đai 52 Hình 3.8: Bộ trục vít-me đai ốc .53 Hình 3.9: Bộ trượt, ray trượt gối đỡ 54 Hình 3.10: Bạc đạn đỡ trục KFL08 54 Hình 3.11: Vịng bi trục 54 Hình 3.12: Khớp nối mặt bích cố định 54 Hình 3.13: Bulong đai ốc 54 Hình 3.14: Phần đế thực tế mơ hình Robot Scara 55 Hình 3.15: Khâu tịnh tiến thực tế mơ hình Robot Scara 55 Hình 3.16: Hai khâu quay thực tế mơ hình Robot Scara 56 Hình 3.17: Mơ hình khí hồn thiện Robot Scara 56 Hình 3.18: Lưu đồ giải thuật điều khiển 57 Hình 3.19: Mạch điều khiển Robot 58 Hình 3.20: Sơ đồ chân Arduino Uno 59 Hình 3.21: Sơ đồ chân Arduino Nano 61 Hình 3.22: Sơ đồ chân Module L298N 63 SVTH: Phan Phúc Hậu Trang v DANH MỤC HÌNH ẢNH Hình 3.23: Nguồn tổ ong 12V-10A 64 Hình 3.24: Động Servo MG995 65 Hình 4.1: Quá trình xử lý ảnh 66 Hình 4.2: Các bước xử lý ảnh 67 Hình 4.3: Sơ đồ trình xử lý ảnh đề tài .69 Hình 4.4: Webcam logitech HD C270 69 Hình 4.5: Kích thước vùng hoạt động .70 Hình 4.6: Ảnh trình xác định vùng hoạt động Robot 70 Hình 4.7: Sơ đồ trình tìm vùng hoạt động Robot 71 Hình 4.8: Vùng hoạt động Robot .71 Hình 4.9: Sơ đồ trình nhị phân ảnh 72 Hình 4.10: Ảnh trình nhị phân ảnh .72 Hình 4.11: Sơ đồ giải thuật phân vùng tách đối tượng 73 Hình 4.12: Ảnh kết trình phân vùng .73 Hình 4.13: Giải thuật trình nhận dạng màu sắc 74 Hình 4.14: Ảnh nhị phân màu vật 75 Hình 4.15: Ảnh kết trình nhận dạng màu sắc 75 Hình 4.16: Giải thuật trình nhận dạng hình dạng .76 Hình 4.17: Ảnh kết trình nhận dạng hình dạng 76 Hình 4.18: Ảnh kết trình nhận dạng màu sắc hình dạng 77 Hình 4.19: Giao diện người dùng điều khiển Robot Scara .78 Hình 5.1: Mơ hình hóa Robot Scara Matlab Simulink 79 Hình 5.2: Mơ hình 3D mơ Matlab Simulink 79 Hình 5.3: Kết chạy thực nghiệm PID khớp 80 Hình 5.4: Kết chạy thực nghiệm PID khớp 80 Hình 5.5: Kết chạy thực nghiệm PID khâu 81 Hình 5.6: Tay gắp thực gắp vật 81 Hình 5.7: Tay gắp thực thả vật 81 Hình 5.8: Kết chạy thực tế động học thuận Robot Scara 82 Hình 5.9: Kết chạy thực tế động học ngược Robot Scara 82 SVTH: Phan Phúc Hậu Trang vi DANH MỤC HÌNH ẢNH Hình 5.10: Kết nhận dạng màu sắc vật hình trịn 83 Hình 5.11: Quá trình phân loại màu sắc vật hình trịn Robot Scara 84 Hình 5.12: Kết nhận dạng màu sắc vật hình vng .84 Hình 5.13: Q trình phân loại màu sắc vật hình vng Robot Scara 85 Hình 5.14: Kết nhận dạng hình dạng vật màu đỏ 85 Hình 5.15: Quá trình phân loại hình dạng vật màu đỏ Robot Scara 86 Hình 5.16: Kết nhận dạng hình dạng vật màu xanh 86 Hình 5.17: Quá trình phân loại hình dạng vật màu xanh Robot Scara 87 Hình 5.18: Kết nhận dạng hình dạng vật màu xanh dương 87 Hình 5.19: Quá trình phân loại hình dạng vật màu xanh dương Robot .88 Hình 5.20: Kết nhận dạng màu sắc hình dạng tất vật 88 Hình 5.21: Quá trình phân loại màu sắc hình dạng Robot Scara 90 SVTH: Phan Phúc Hậu Trang vii PHỤ LỤC % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function theta2_Callback(hObject, eventdata, handles) % hObject handle to theta2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of theta2 as text % str2double(get(hObject,'String')) returns contents of theta2 as a double % - Executes during object creation, after setting all properties function theta2_CreateFcn(hObject, eventdata, handles) % hObject handle to theta2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function theta3_Callback(hObject, eventdata, handles) % hObject handle to theta3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of theta3 as text SVTH: Phan Phúc Hậu Trang 104 PHỤ LỤC % str2double(get(hObject,'String')) returns contents of theta3 as a double % - Executes during object creation, after setting all properties function theta3_CreateFcn(hObject, eventdata, handles) % hObject handle to theta3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function px_Callback(hObject, eventdata, handles) % hObject handle to px (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of px as text % str2double(get(hObject,'String')) returns contents of px as a double % - Executes during object creation, after setting all properties function px_CreateFcn(hObject, eventdata, handles) % hObject handle to px (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) SVTH: Phan Phúc Hậu Trang 105 PHỤ LỤC set(hObject,'BackgroundColor','white'); end function py_Callback(hObject, eventdata, handles) % hObject handle to py (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of py as text % str2double(get(hObject,'String')) returns contents of py as a double % - Executes during object creation, after setting all properties function py_CreateFcn(hObject, eventdata, handles) % hObject handle to py (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function pz_Callback(hObject, eventdata, handles) % hObject handle to pz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of pz as text % str2double(get(hObject,'String')) returns contents of pz as a double % - Executes during object creation, after setting all properties SVTH: Phan Phúc Hậu Trang 106 PHỤ LỤC function pz_CreateFcn(hObject, eventdata, handles) % hObject handle to pz (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows % See ISPC and COMPUTER if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end % - Executes on button press in dht function dht_Callback(hObject, eventdata, handles) % hObject handle to dht (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s; global l1 l2 l3; d1 = get(handles.d1,'String'); theta2 = get(handles.theta2,'String'); theta3 = get(handles.theta3,'String'); fprintf(s , 'ff'); fprintf(s , 'a'); fprintf(s , d1); pause(2) fprintf(s , 'b'); fprintf(s , theta2); fprintf(s , 'c'); fprintf(s , theta3); d1 = str2num(d1); theta2 = str2num(theta2); theta3 = str2num(theta3); T1 = [1 0 l3 ; 0 ; 0 d1 ; 0 1]; SVTH: Phan Phúc Hậu Trang 107 PHỤ LỤC T2 = [cosd(theta2) -sind(theta2) l1*cosd(theta2) ; sind(theta2) cosd(theta2) l1*sind(theta2) ; 0 ; 0 1]; T3 = [cosd(theta3) -sind(theta3) l2*cosd(theta3) ; sind(theta3) cosd(theta3) l2*sind(theta3) ; 0 ; 0 1]; T = T1*T2*T3; px = T(1,4); py = T(2,4); pz = T(3,4); set(handles.px,'String',num2str(round(px,2))); set(handles.py,'String',num2str(round(py,2))); set(handles.pz,'String',num2str(round(pz,2))); % - Executes on button press in dhn function dhn_Callback(hObject, eventdata, handles) % hObject handle to dhn (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s; global l1 l2 l3; px = get(handles.px,'String'); py = get(handles.py,'String'); pz = get(handles.pz,'String'); px = str2num(px)-l3; py = str2num(py); d1 = str2num(pz); c3 = (px^2+py^2-l1^2-l2^2)/(2*l1*l2); s3 = sqrt(1-(c3)^2); theta3 = atan2d(s3,c3); denta = px^2+py^2; denta1 = l1*px+l2*(px*c3+py*s3); denta2 = l1*py+l2*(py*c3-px*s3); c2 = denta1/denta; s2 = denta2/denta; theta2 = atan2d(s2,c2); SVTH: Phan Phúc Hậu Trang 108 PHỤ LỤC fprintf(s , 'ff'); fprintf(s , 'a'); fprintf(s , num2str(d1)); pause(2) fprintf(s , 'b'); fprintf(s , num2str(theta2)); fprintf(s , 'c'); fprintf(s , num2str(theta3)); set(handles.d1,'String',num2str(round(d1,2))); set(handles.theta2,'String',num2str(round(theta2,2))); set(handles.theta3,'String',num2str(round(theta3,2))); % - Executes on button press in reset function reset_Callback(hObject, eventdata, handles) % hObject handle to reset (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global s; global l1 l2 l3; fprintf(s , 'b'); fprintf(s , '0'); fprintf(s , 'a'); fprintf(s , '0'); fprintf(s , 'c'); fprintf(s , '0'); pause(1) fprintf(s , 'oo'); set(handles.d1,'String',0); set(handles.theta2,'String',0); set(handles.theta3,'String',0); set(handles.px,'String',l1+l2+l3); set(handles.py,'String',0); set(handles.pz,'String',0); function axes1_CreateFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: place code in OpeningFcn to populate axes1 SVTH: Phan Phúc Hậu Trang 109 PHỤ LỤC % - Executes on button press in oncam function oncam_Callback(hObject, eventdata, handles) % hObject handle to oncam (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global myCam; axes(handles.axes1); myCam = videoinput('winvideo',1); set(myCam,'ReturnedColorSpace','rgb'); triggerconfig(myCam,'manual'); set(myCam,'FramesPerTrigger',1 ); set(myCam,'TriggerRepeat', Inf); myCam.FrameGrabInterval = 3; hImage = image(zeros(576, 1024,3),'parent',handles.axes1); preview(myCam,hImage); % - Executes on button press in offcam function offcam_Callback(hObject, eventdata, handles) % hObject handle to offcam(see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global myCam; if (strcmp(get(myCam,'Running'),'on')) flushdata(myCam); stop(myCam); else imaqreset; end cla(handles.axes1,'reset'); SVTH: Phan Phúc Hậu Trang 110 PHỤ LỤC % - Executes on button press in setcam function setcam_Callback(hObject, eventdata, handles) % hObject handle to setcam (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global myCam; global X Y; axes(handles.axes1); X = []; Y = []; i = 0; rgb = getsnapshot(myCam); im = imsubtract(rgb(:,:,1), rgb2gray(rgb)); im = medfilt2(im, [3 3]); im = im2bw(im,0.15); % Remove all those pixels less than 250px im = bwareaopen(im,250); % Label all the connected components in the image bw = bwlabel(im, 8); % Here we the image blob analysis % We get a set of properties for each labeled region L = regionprops(bw, 'all'); for n = 1:length(L) W = L(n).BoundingBox(3); H = L(n).BoundingBox(4); S = L(n).Area; if H/W > 0.5 && H/W < if S >500 && S< 650 if S/(W*H)>0.5 && S/(W*H) 0.5 && H/W < if S > 500 && S < 1500 if S/(W*H) > 0.5 && S/(W*H) BRed plot(cX(i),cY(i),'r+'); text(cX(i)+25, cY(i)-12, strcat('X: ', num2str(round(cY(i)))),'Color','r'); text(cX(i)+25, cY(i)+12, strcat('Y: ', num2str(round(cX(i)-290))),'Color','r'); if (length(c) > 0) || (T > 0.9 && T < 1.1) Color(i) = 'R'; Shape(i) = 'O'; viscircles([cX(i) cY(i)],r,'EdgeColor','r'); end if ((T > 0.65 && T < 0.85) || (vat(n).Extent > 0.7)) && (length(c) == 0) Color(i) = 'R'; Shape(i) = 'X'; rectangle('Position',vat(n).BoundingBox,'EdgeColor','r','LineWidth',2); end end if WGreen > BGreen plot(cX(i),cY(i),'g+'); text(cX(i)+25, cY(i)-12, strcat('X: ', SVTH: Phan Phúc Hậu Trang 114 PHỤ LỤC num2str(round(cY(i)))),'Color','g'); text(cX(i)+25, cY(i)+12, strcat('Y: ', num2str(round(cX(i)-290))),'Color','g'); if (length(c) > 0) || (T > 0.9 && T < 1.1) Color(i) = 'G'; Shape(i) = 'O'; viscircles([cX(i) cY(i)],r,'EdgeColor','g'); end if ((T > 0.65 && T < 0.85) || (vat(n).Extent > 0.7)) && (length(c) == 0) Color(i) = 'G'; Shape(i) = 'X'; rectangle('Position',vat(n).BoundingBox,'EdgeColor','g','LineWidth',2); end end if WBlue > BBlue plot(cX(i),cY(i),'b+'); text(cX(i)+25, cY(i)-12, strcat('X: ', num2str(round(cY(i)))),'Color','b'); text(cX(i)+25, cY(i)+12, strcat('Y: ', num2str(round(cX(i)-290))),'Color','b'); if (length(c) > 0) || (T > 0.9 && T < 1.1) Color(i) = 'B'; Shape(i) = 'O'; viscircles([cX(i) cY(i)],r,'EdgeColor','b'); end if ((T > 0.65 && T < 0.85) || (vat(n).Extent > 0.7)) && (length(c) == 0) Color(i) = 'B'; Shape(i) = 'X'; rectangle('Position',vat(n).BoundingBox,'EdgeColor','b','LineWidth',2); end end end end end end hold off SVTH: Phan Phúc Hậu Trang 115 PHỤ LỤC fprintf(s , 'ff'); fprintf(s , 'a'); fprintf(s , '70'); pause(2) for j = 1:i px = cY(j)-l3; py = cX(j)-290; pz = 0; d1 = pz; c3 = (px^2+py^2-l1^2-l2^2)/(2*l1*l2); s3 = sqrt(1-(c3)^2); theta3 = atan2d(s3,c3); denta = px^2+py^2; denta1 = l1*px+l2*(px*c3+py*s3); denta2 = l1*py+l2*(py*c3-px*s3); c2 = denta1/denta; s2 = denta2/denta; theta2 = atan2d(s2,c2); set(handles.d1,'String',num2str(round(d1,2))); set(handles.theta2,'String',num2str(round(theta2,2))); set(handles.theta3,'String',num2str(round(theta3,2))); set(handles.px,'String',num2str(round(cY(j),2))); set(handles.py,'String',num2str(round(py,2))); set(handles.pz,'String',num2str(round(pz,2))); if Color(j) == 'R' && Shape(j) == 'O' fprintf(s , 'b'); fprintf(s , num2str(theta2)); fprintf(s , 'c'); fprintf(s , num2str(theta3)); pause(3) fprintf(s , 'a'); fprintf(s , '0'); pause(2) fprintf(s , 'oo'); pause(1) fprintf(s , 'a'); fprintf(s , '70'); pause(2) fprintf(s , 'b'); fprintf(s , '40'); fprintf(s , 'c'); fprintf(s , '30'); pause(3) fprintf(s , 'ff'); pause(1) end if Color(j) == 'G' && Shape(j) == 'O' fprintf(s , 'b'); fprintf(s , num2str(theta2)); fprintf(s , 'c'); fprintf(s , num2str(theta3)); pause(3) SVTH: Phan Phúc Hậu Trang 116 PHỤ LỤC fprintf(s , 'a'); fprintf(s , '0'); pause(2) fprintf(s , 'oo'); pause(1) fprintf(s , 'a'); fprintf(s , '70'); pause(2) fprintf(s , 'b'); fprintf(s , '37'); fprintf(s , 'c'); fprintf(s , '66'); pause(3) fprintf(s , 'ff'); pause(1) end if Color(j) == 'B' && Shape(j) == 'O' fprintf(s , 'b'); fprintf(s , num2str(theta2)); fprintf(s , 'c'); fprintf(s , num2str(theta3)); pause(3) fprintf(s , 'a'); fprintf(s , '0'); pause(2) fprintf(s , 'oo'); pause(1) fprintf(s , 'a'); fprintf(s , '70'); pause(2) fprintf(s , 'b'); fprintf(s , '49'); fprintf(s , 'c'); fprintf(s , '77'); pause(3) fprintf(s , 'ff'); pause(1) end if Color(j) == 'R' && Shape(j) == 'X' fprintf(s , 'b'); fprintf(s , num2str(theta2)); fprintf(s , 'c'); fprintf(s , num2str(theta3)); pause(3) fprintf(s , 'a'); fprintf(s , '0'); pause(2) fprintf(s , 'oo'); pause(1) fprintf(s , 'a'); fprintf(s , '70'); pause(2) fprintf(s , 'b'); fprintf(s , '-40'); fprintf(s , 'c'); fprintf(s , '-30'); pause(3) fprintf(s , 'ff'); pause(1) end if Color(j) == 'G' && Shape(j) == 'X' fprintf(s , 'b'); fprintf(s , num2str(theta2)); fprintf(s , 'c'); fprintf(s , num2str(theta3)); pause(3) SVTH: Phan Phúc Hậu Trang 117 PHỤ LỤC fprintf(s , 'a'); fprintf(s , '0'); pause(2) fprintf(s , 'oo'); pause(1) fprintf(s , 'a'); fprintf(s , '70'); pause(2) fprintf(s , 'b'); fprintf(s , '-37'); fprintf(s , 'c'); fprintf(s , '-66'); pause(3) fprintf(s , 'ff'); pause(1) end if Color(j) == 'B' && Shape(j) == 'X' fprintf(s , 'b'); fprintf(s , num2str(theta2)); fprintf(s , 'c'); fprintf(s , num2str(theta3)); pause(3) fprintf(s , 'a'); fprintf(s , '0'); pause(2) fprintf(s , 'oo'); pause(1) fprintf(s , 'a'); fprintf(s , '70'); pause(2) fprintf(s , 'b'); fprintf(s , '-49'); fprintf(s , 'c'); fprintf(s , '-77'); pause(3) fprintf(s , 'ff'); pause(1) end end fprintf(s , 'b'); fprintf(s , '0'); fprintf(s , 'c'); fprintf(s , '0'); pause(3) fprintf(s , 'a'); fprintf(s , '0'); fprintf(s , 'oo'); set(handles.d1,'String',0); set(handles.theta2,'String',0); set(handles.theta3,'String',0); set(handles.px,'String',l1+l2+l3); set(handles.py,'String',0); set(handles.pz,'String',0); SVTH: Phan Phúc Hậu Trang 118 ... luận văn ? ?Thiết kế chế tạo mơ hình Robot Scara phân loại sản phẩm theo màu sắc hình dạng? ?? bao gồm nội dung cốt lõi như: tìm hiểu khái niệm kiến thức Robot, thiết kế chế tạo mơ hình Robot Scara bậc... màu sắc vật hình trịn Robot Scara 84 Hình 5.12: Kết nhận dạng màu sắc vật hình vng .84 Hình 5.13: Quá trình phân loại màu sắc vật hình vng Robot Scara 85 Hình 5.14: Kết nhận dạng hình dạng. .. xanh Robot Scara 87 Hình 5.18: Kết nhận dạng hình dạng vật màu xanh dương 87 Hình 5.19: Quá trình phân loại hình dạng vật màu xanh dương Robot .88 Hình 5.20: Kết nhận dạng màu sắc hình dạng

Ngày đăng: 17/11/2020, 23:20

TỪ KHÓA LIÊN QUAN

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

TÀI LIỆU LIÊN QUAN

w