Điều khiển cánh tay robot 2 dof sử dụng mạng neural thích nghi với tín hiệu tham chiếu thông qua sóng não

117 1 0
Điều khiển cánh tay robot 2 dof sử dụng mạng neural thích nghi với tín hiệu tham chiếu thông qua sóng não

Đ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Ộ CÔNG THƢƠNG TRƢỜNG ĐẠI HỌC CÔNG NGHIỆP THÀNH PHỐ HỒ CHÍ MINH VŨ QUANG DŨNG ĐIỀU KHIỂN CÁNH TAY ROBOT DOF SỬ DỤNG MẠNG NEURAL THÍCH NGHI VỚI TÍN HIỆU THAM CHIẾU THƠNG QUA SĨNG NÃO Ngành: KỸ THUẬT ĐIỆN Mã ngành: 8520201 LUẬN VĂN THẠC SĨ THÀNH PHỐ HỒ CHÍ MINH, NĂM 2022 Cơng trình đƣợc hồn thành Trƣờng Đại học Cơng nghiệp TP Hồ Chí Minh Ngƣời hƣớng dẫn khoa học: TS Ngô Thanh Quyền NCS Lâm Bình Minh Luận v n thạc s đƣợc ảo vệ Hội đồng chấm ảo vệ Luận v n thạc s Trƣờng Đại học Công nghiệp thành phố Hồ Chí Minh ngày tháng n m Thành phần Hội đồng đánh giá luận v n thạc s gồm: PGS TS Châu Minh Thuyên - Chủ tịch Hội đồng TS Nguyễn Trọng Tài - Phản iện TS Vũ V n Phong - Phản iện TS Nguyễn Ngọc Sơn - Ủy viên TS Dƣơng Miên Ka - Thƣ ký CHỦ TỊCH HỘI ĐỒNG TRƢỞNG KHOA CÔNG NGHỆ ĐIỆN PGS.TS Châu Minh Thuyên TS Trần Thanh Ngọc BỘ CÔNG THƢƠNG TRƢỜNG ĐẠI HỌC CÔNG NGHIỆP THÀNH PHỐ HỒ CHÍ MINH CỘNG HÕA XÃ HỘI CHỦ NGHĨA VIỆT NAM Độc lập - Tự - Hạnh phúc NHIỆM VỤ LUẬN VĂN THẠC SĨ Họ tên học viên: Vũ Quang Dũng MSHV: 18105161 Ngày, tháng, n m sinh: 27/09/1995 Nơi sinh: Hải Phòng Ngành: Kỹ thuật điện Mã ngành: 8520201 I TÊN ĐỀ TÀI: Điều khiển cánh tay ro ot DOF sử dụng mạng neural thích nghi với tín hiệu tham chiếu thơng qua sóng não II NHIỆM VỤ VÀ NỘI DUNG: - Nghiên cứu lý thuyết sóng não ứng dụng để làm tham chiếu - Thiết kế cánh tay ro ot DOF mạch điều khiển - Lập trình thuật tốn huấn luyện phân tích sóng não để làm tham chiếu điều khiển cánh tay ro ot - Thực nghiệm thuật toán, đánh giá độ tin cậy III NGÀY GIAO NHIỆM VỤ: Ngày 08 tháng 04 n m 2021 IV NGÀY HOÀN THÀNH NHIỆM VỤ: Ngày 08 tháng 11 n m 2022 V NGƢỜI HƢỚNG DẪN KHOA HỌC: TS Ngô Thanh Quyền Tp Hồ Chí Minh, ngày … tháng … năm 20 … NGƢỜI HƢỚNG DẪN CHỦ NHIỆM BỘ MÔN ĐÀO TẠO TS Ngô Thanh Quyền TS Nguyễn Thanh Thuận TRƢỞNG KHOA CÔNG NGHỆ ĐIỆN TS Trần Thanh Ngọc LỜI CẢM ƠN Trong suốt thời gian học tập vừa qua với giúp đỡ tận tình Q thầy Khoa Cơng nghệ Điện, Trƣờng Đại học Công Nghiệp Thành phố Hồ Chí Minh giúp cho tơi tích lũy đƣợc vốn kiến thức vơ q giá, ổ ích cần thiết Sau khoảng thời gian tìm hiểu, nghiên cứu, lên phƣơng án tiến hành thực hoàn thành luận v n: “Điều khiển cánh tay ro ot DOF sử dụng mạng neural thích nghi với tín hiệu tham chiếu thơng qua sóng não”, kết mà tơi có đƣợc nhờ giúp đỡ, ảo tận tình Q Thầy Cơ khoa Cơng nghệ Điện Đặc iệt xin gửi lời cảm ơn chân thành đến giảng viên hƣớng dẫn: TS Ngô Thanh Quyền NCS Lâm Bình Minh giúp đỡ, hƣớng dẫn giúp đỡ tơi hồn thành luận v n Trong q trình thực luận v n cịn thiếu xót, tơi mong đƣợc Q Thầy Cơ góp ý để tơi hồn thiện ài nghiên cứu sau Xin kính chúc sức khỏe chân thành cảm ơn./ i TÓM TẮT LUẬN VĂN THẠC SĨ Trong n m gần đây, công nghệ tự động hóa phát triển mạnh mẽ Việc chạy theo công nghệ giải pháp giải ài toán cụ thể thực tế đƣợc nƣớc quan tâm nghiên cứu Việc đƣa sóng não vào nghiên cứu ứng dụng khơng ngoại lệ Sóng não đƣợc sản sinh từ lúc chào đời đến lúc chết đi, tất hoạt động thể tạo sóng não tƣơng ứng Vậy khơng ứng dụng sóng não để điều khiển cấu vật lý hay ất điều mà ta tƣởng tƣợng? Trong đề tài “Điều khiển cánh tay ro ot DOF sử dụng mạng neural thích nghi với tín hiệu tham chiếu thơng qua sóng não” đƣa lý thuyết ản sóng não nhƣ ứng dụng thực tiễn tham chiếu sóng não vào điều khiển cấu cánh tay ro ot Trong đề tài thực đƣợc công việc việc sử dụng sóng não để tham chiếu điều khiển cấu chấp hành + Phân tích đƣợc thay đổi sóng não xảy kiện thực + Huấn luyện mạng neural để phân tích thay đổi sóng não để đƣa lệnh tƣơng ứng + Đánh giá phƣơng pháp thống kê đƣa đƣợc tỉ lệ xác mơ hình huấn luyện ii ABSTRACT In recent years, automation technology has developed rapidly Countries are paying great attention to pursuing specific technologies and solutions to address practical problems Applying brain waves to research and practical applications is no exception Brain waves are generated from the moment we are born until we die, and all body activities create corresponding brain waves So why not apply brain waves to control physical structures or anything else we can imagine? The project "Controlling a 2-DOF robot arm using an adaptive neural network with reference signals via brain waves" will provide the most basic theories about brain waves as well as practical applications of brain wave reference signals in controlling a robot arm mechanism The project has accomplished the most basic tasks of using brain waves to control an executive mechanism: + Analyzing the changes in brain waves that occur during the execution of an event + Training a neural network to analyze the changes in brain waves to provide corresponding commands + Evaluating the model's accuracy through statistical methods iii LỜI CAM ĐOAN Tôi cam đoan cơng trình nghiên cứu tơi Các số liệu, kết nêu luận v n trung thực chƣa đƣợc công ố ất k cơng trình khác Việc tham khảo nguồn tài liệu đƣợc thực trích dẫn ghi nguồn tài liệu tham khảo theo yêu cầu Học viên Vũ Quang Dũng iv MỤC LỤC LỜI CẢM ƠN i TÓM TẮT LUẬN VĂN THẠC SĨ ii ABSTRACT iii LỜI CAM ĐOAN iv MỤC LỤC v DANH MỤC HÌNH ẢNH viii DANH MỤC BẢNG BIỂU x DANH MỤC TỪ VIẾT TẮT xi MỞ ĐẦU 1 Giới thiệu đề tài Lý chọn đề tài Mục tiêu Đối tƣợng phạm vi nghiên cứu Cách tiếp cận phƣơng pháp nghiên cứu Ý ngh a ứng dụng thực tiễn luận v n Thời gian thực CHƢƠNG TÍN HIỆU SÓNG NÃO 1.1 Tổng quan sóng não 1.1.1 Khái niệm ản sóng não 1.1.2 Phân loại sóng não 1.1.2.1 Sóng não Delta 1.1.2.2 Sóng não Theta 1.1.2.3 Sóng não Alpha 1.1.2.4 Sóng não Beta 1.1.2.5 Sóng não Gamma 1.1.3 Các thông số đặc trƣng sóng não 1.2 Tổng quan hệ giao diện Não – Máy tính (BCI) 10 v 1.2.1 Định ngh a BCI 10 1.2.2 Lịch sử phát triển BCI 10 1.3 Thiết bị cảm biến sóng não 11 1.3.1 Giới thiệu Emotiv Insight 2.0 11 1.3.2 Thông số kỹ thuật Emotiv Insight 2.0 12 1.4 Phần mềm phân tích sóng não 13 1.4.1 Giới thiệu phần mềm Emotiv PRO 13 1.4.2 Kết nối Insight với phần mềm EmotivPRO 15 1.5 Sự thay đổi sóng não 20 1.5.1 Cơ sở lý thuyết 20 1.5.2 Thực nghiệm kết phần mềm 22 CHƢƠNG THUẬT TỐN MẠNG NEURAL THÍCH NGHI ỨNG DỤNG VÀO ĐIỀU KHIỂN CÁNH TAY ROBOT 26 2.1 Thuật tốn mạng Neural thích nghi 26 2.1.1 Lý thuyết mạng neural 26 2.1.2 Lý thuyết điều khiển thích nghi 31 2.2 Thiết kế mơ hình cánh tay robot 35 2.2.1 Mơ hình cánh tay robot DOF 35 2.2.1.1 Thiết kế cánh tay ro ot SolidWorks 35 2.2.2 Mạch điều khiển cánh tay robot 39 2.2.2.1 Thiết kế mạch điều khiển 39 2.2.2.2 Sơ đồ kết nối 44 2.2.3 Mơ hình thực tế 45 CHƢƠNG CHƢƠNG TRÌNH KẾT NỐI GIỮA MƠ HÌNH VÀ MÁY TÍNH 46 3.1 Thuật toán điều khiển cánh tay robot thơng qua sóng não 46 3.2 Kết nối, mô chuyển động 50 CHƢƠNG KẾT QUẢ MÔ PHỎNG VÀ THỰC NGHIỆM 53 4.1 Mô chuyển động lên xuống 53 4.2 Mô chuyển động sang trái phải 55 4.3 Kết thực nghiệm 57 vi KẾT LUẬN VÀ HƢỚNG PHÁT TRIỂN 64 Kết luận 64 Hƣớng phát triển 64 TÀI LIỆU THAM KHẢO 65 PHỤ LỤC 67 LÝ LỊCH TRÍCH NGANG CỦA HỌC VIÊN 103 vii cur_dev->product_id == product_id) { if (serial_number) { if (cur_dev->serial_number && wcscmp(serial_number, cur_dev->serial_number) == 0) { path_to_open = cur_dev->path; break; } } else { path_to_open = cur_dev->path; break; } } cur_dev = cur_dev->next; } if (path_to_open) { handle = hid_open_path(path_to_open); } else { register_global_error(L"Device with requested VID/PID/(SerialNumber) not found"); } hid_free_enumeration(devs); return handle; } HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path) { hid_device *dev = NULL; wchar_t* interface_path = NULL; HANDLE device_handle = INVALID_HANDLE_VALUE; PHIDP_PREPARSED_DATA pp_data = NULL; HIDP_CAPS caps; if (hid_init() < 0) { goto end_of_function; } 89 interface_path = hid_internal_UTF8toUTF16(path); if (!interface_path) { register_string_error(dev, L"Path conversion failure"); goto end_of_function; } device_handle = open_device(interface_path, TRUE); if (device_handle == INVALID_HANDLE_VALUE) { device_handle = open_device(interface_path, FALSE); if (device_handle == INVALID_HANDLE_VALUE) { register_global_winapi_error(L"open_device"); goto end_of_function; } } if (!HidD_SetNumInputBuffers(device_handle, 64)) { register_global_winapi_error(L"set input buffers"); goto end_of_function; } if (!HidD_GetPreparsedData(device_handle, &pp_data)) { register_global_winapi_error(L"get preparsed data"); goto end_of_function; } if (HidP_GetCaps(pp_data, &caps) != HIDP_STATUS_SUCCESS) { register_global_error(L"HidP_GetCaps"); goto end_of_function; } dev = new_hid_device(); if (dev == NULL) { register_global_error(L"hid_device allocation error"); goto end_of_function; } dev->device_handle = device_handle; 90 device_handle = INVALID_HANDLE_VALUE; dev->output_report_length = caps.OutputReportByteLength; dev->input_report_length = caps.InputReportByteLength; dev->feature_report_length = caps.FeatureReportByteLength; dev->read_buf = (char*) malloc(dev->input_report_length); dev->device_info = hid_internal_get_device_info(interface_path, dev>device_handle); end_of_function: free(interface_path); CloseHandle(device_handle); if (pp_data) { HidD_FreePreparsedData(pp_data); } return dev; } int HID_API_EXPORT HID_API_CALL hid_write(hid_device *dev, const unsigned char *data, size_t length) { DWORD bytes_written = 0; int function_result = -1; BOOL res; BOOL overlapped = FALSE; unsigned char *buf; if (!data || !length) { register_string_error(dev, L"Zero buffer/length"); return function_result; } register_string_error(dev, NULL); if (length >= dev->output_report_length) { buf = (unsigned char *) data; } else { 91 if (dev->write_buf == NULL) dev->write_buf = (unsigned char *) malloc(dev>output_report_length); buf = dev->write_buf; memcpy(buf, data, length); memset(buf + length, 0, dev->output_report_length - length); length = dev->output_report_length; } res = WriteFile(dev->device_handle, buf, (DWORD) length, NULL, &dev>write_ol); if (!res) { if (GetLastError() != ERROR_IO_PENDING) { register_winapi_error(dev, L"WriteFile"); goto end_of_function; } overlapped = TRUE; } if (overlapped) { res = WaitForSingleObject(dev->write_ol.hEvent, 1000); if (res != WAIT_OBJECT_0) { register_winapi_error(dev, L"hid_write/WaitForSingleObject"); goto end_of_function; } res = GetOverlappedResult(dev->device_handle, &dev->write_ol, &bytes_written, FALSE/*wait*/); if (res) { function_result = bytes_written; } else { register_winapi_error(dev, L"hid_write/GetOverlappedResult"); goto end_of_function; } } 92 end_of_function: return function_result; } int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds) { DWORD bytes_read = 0; size_t copy_len = 0; BOOL res = FALSE; BOOL overlapped = FALSE; if (!data || !length) { register_string_error(dev, L"Zero buffer/length"); return -1; } register_string_error(dev, NULL); HANDLE ev = dev->ol.hEvent; if (!dev->read_pending) { dev->read_pending = TRUE; memset(dev->read_buf, 0, dev->input_report_length); ResetEvent(ev); res = ReadFile(dev->device_handle, dev->read_buf, (DWORD) dev>input_report_length, &bytes_read, &dev->ol); if (!res) { if (GetLastError() != ERROR_IO_PENDING) { register_winapi_error(dev, L"ReadFile"); CancelIo(dev->device_handle); dev->read_pending = FALSE; goto end_of_function; } overlapped = TRUE; } } else { 93 overlapped = TRUE; } if (overlapped) { if (milliseconds >= 0) { res = WaitForSingleObject(ev, milliseconds); if (res != WAIT_OBJECT_0) { return 0; } } res = GetOverlappedResult(dev->device_handle, &dev->ol, &bytes_read, TRUE/*wait*/); } dev->read_pending = FALSE; if (res && bytes_read > 0) { if (dev->read_buf[0] == 0x0) { bytes_read ; copy_len = length > bytes_read ? bytes_read : length; memcpy(data, dev->read_buf+1, copy_len); } else { copy_len = length > bytes_read ? bytes_read : length; memcpy(data, dev->read_buf, copy_len); } } if (!res) { register_winapi_error(dev, L"hid_read_timeout/GetOverlappedResult"); } end_of_function: if (!res) { return -1; } return (int) copy_len; } 94 int HID_API_EXPORT HID_API_CALL hid_read(hid_device *dev, unsigned char *data, size_t length) { return hid_read_timeout(dev, data, length, (dev->blocking)? -1: 0); } int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *dev, int nonblock) { dev->blocking = !nonblock; return 0; /* Success */ } int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length) { BOOL res = FALSE; unsigned char *buf; size_t length_to_send; if (!data || !length) { register_string_error(dev, L"Zero buffer/length"); return -1; } register_string_error(dev, NULL); /* Windows expects at least caps.FeatureReportByteLength bytes passed to HidD_SetFeature(), even if the report is shorter Any less sent and the function fails with error ERROR_INVALID_PARAMETER set Any more and HidD_SetFeature() silently truncates the data sent in the report to caps.FeatureReportByteLength */ if (length >= dev->feature_report_length) { buf = (unsigned char *) data; length_to_send = length; } else { if (dev->feature_buf == NULL) dev->feature_buf = (unsigned char *) malloc(dev>feature_report_length); 95 buf = dev->feature_buf; memcpy(buf, data, length); memset(buf + length, 0, dev->feature_report_length - length); length_to_send = dev->feature_report_length; } res = HidD_SetFeature(dev->device_handle, (PVOID)buf, (DWORD) length_to_send); if (!res) { register_winapi_error(dev, L"HidD_SetFeature"); return -1; } return (int) length; } static int hid_get_report(hid_device *dev, DWORD report_type, unsigned char *data, size_t length) { BOOL res; DWORD bytes_returned = 0; OVERLAPPED ol; memset(&ol, 0, sizeof(ol)); if (!data || !length) { register_string_error(dev, L"Zero buffer/length"); return -1; } register_string_error(dev, NULL); res = DeviceIoControl(dev->device_handle, report_type, data, (DWORD) length, data, (DWORD) length, &bytes_returned, &ol); if (!res) { 96 if (GetLastError() != ERROR_IO_PENDING) { register_winapi_error(dev, L"Get Input/Feature Report DeviceIoControl"); return -1; } } res = GetOverlappedResult(dev->device_handle, &ol, &bytes_returned, TRUE); if (!res) { register_winapi_error(dev, L"Get Input/Feature Report GetOverLappedResult"); return -1; } if (data[0] == 0x0) { bytes_returned++; } return bytes_returned; } int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length) { return hid_get_report(dev, IOCTL_HID_GET_FEATURE, data, length); } int HID_API_EXPORT HID_API_CALL hid_get_input_report(hid_device *dev, unsigned char *data, size_t length) { return hid_get_report(dev, IOCTL_HID_GET_INPUT_REPORT, data, length); } void HID_API_EXPORT HID_API_CALL hid_close(hid_device *dev) { if (!dev) return; 97 CancelIo(dev->device_handle); free_hid_device(dev); } int HID_API_EXPORT_CALL HID_API_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen) { if (!string || !maxlen) { register_string_error(dev, L"Zero buffer/length"); return -1; } if (!dev->device_info) { register_string_error(dev, L"NULL device info"); return -1; } wcsncpy(string, dev->device_info->manufacturer_string, maxlen); string[maxlen - 1] = L'\0'; register_string_error(dev, NULL); return 0; } int HID_API_EXPORT_CALL HID_API_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen) { if (!string || !maxlen) { register_string_error(dev, L"Zero buffer/length"); return -1; } if (!dev->device_info) { register_string_error(dev, L"NULL device info"); return -1; } wcsncpy(string, dev->device_info->product_string, maxlen); string[maxlen - 1] = L'\0'; 98 register_string_error(dev, NULL); return 0; } int HID_API_EXPORT_CALL HID_API_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen) { if (!string || !maxlen) { register_string_error(dev, L"Zero buffer/length"); return -1; } if (!dev->device_info) { register_string_error(dev, L"NULL device info"); return -1; } wcsncpy(string, dev->device_info->serial_number, maxlen); string[maxlen - 1] = L'\0'; register_string_error(dev, NULL); return 0; } HID_API_EXPORT struct hid_device_info * HID_API_CALL hid_get_device_info(hid_device *dev) { if (!dev->device_info) { register_string_error(dev, L"NULL device info"); return NULL; } return dev->device_info; } 99 int HID_API_EXPORT_CALL HID_API_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen) { BOOL res; res = HidD_GetIndexedString(dev->device_handle, string_index, string, sizeof(wchar_t) * (DWORD) MIN(maxlen, MAX_STRING_WCHARS)); if (!res) { register_winapi_error(dev, L"HidD_GetIndexedString"); return -1; } register_string_error(dev, NULL); return 0; } int HID_API_EXPORT_CALL hid_winapi_get_container_id(hid_device *dev, GUID *container_id) { wchar_t *interface_path = NULL, *device_id = NULL; CONFIGRET cr = CR_FAILURE; DEVINST dev_node; DEVPROPTYPE property_type; ULONG len; if (!container_id) { register_string_error(dev, L"Invalid Container ID"); return -1; } register_string_error(dev, NULL); interface_path = hid_internal_UTF8toUTF16(dev->device_info->path); if (!interface_path) { register_string_error(dev, L"Path conversion failure"); goto end; } 100 device_id = hid_internal_get_device_interface_property(interface_path, &DEVPKEY_Device_InstanceId, DEVPROP_TYPE_STRING); if (!device_id) { register_string_error(dev, L"Failed to get device interface property InstanceId"); goto end; } cr = CM_Locate_DevNodeW(&dev_node, (DEVINSTID_W)device_id, CM_LOCATE_DEVNODE_NORMAL); if (cr != CR_SUCCESS) { register_string_error(dev, L"Failed to locate device node"); goto end; } len = sizeof(*container_id); cr = CM_Get_DevNode_PropertyW(dev_node, &DEVPKEY_Device_ContainerId, &property_type, (PBYTE)container_id, &len, 0); if (cr == CR_SUCCESS && property_type != DEVPROP_TYPE_GUID) cr = CR_FAILURE; if (cr != CR_SUCCESS) register_string_error(dev, L"Failed to read ContainerId property from device node"); end: free(interface_path); free(device_id); return cr == CR_SUCCESS ? : -1; } HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *dev) { if (dev) { if (dev->last_error_str == NULL) return L"Success"; return (wchar_t*)dev->last_error_str; 101 } if (last_global_error_str == NULL) return L"Success"; return last_global_error_str; } #ifdef cplusplus } /* extern "C" */ #endif 102 LÝ LỊCH TRÍCH NGANG CỦA HỌC VIÊN I LÝ LỊCH SƠ LƢỢC: Họ tên: Vũ Quang Dũng Giới tính: Nam Ngày, tháng, n m sinh: 27/09/1995 Nơi sinh: Hải Phòng Email: vuquangdung2709@gmail.com Điện thoại: 0795350351 II QUÁ TRÌNH ĐÀO TẠO: Đại học chuyên nghành Điện điều khiển tự động – Đại học Cơng nghiệp Tp.HCM III Q TRÌNH CƠNG TÁC CHUN MƠN: Thời gian 2017-Nay Nơi cơng tác Công ty Cổ phần quốc tế Gymaster Công việc đảm nhiệm Trƣởng phòng kỹ thuật Tp HCM, ngày tháng Năm 2022 Ngƣời khai Vũ Quang Dũng 103

Ngày đăng: 20/06/2023, 14:06

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan