NCTU AUV TEAM
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 暑假大爆發 [TOC] ## 8/12 1. 安裝Jetpcak 4.2 (opencv 3.3.1, Cuda 10.0) 2. 有door.cfg 缺對應的 weights **使用door.yaml即可** ## 8/13 1. DVL 界面 work (下載官網Nortek Discover) [Link](https://www.nortekgroup.com/software?i) 4. ZED SDK and ZED ros wrapper 5. 用Arduino讀到MPU9250 data [Ref](https://hackmd.io/Wth1-ZdVROSO5xjWDoEjEA#Install-MPU9250-Arduino-LIbrary) 6. 讀PID ----- - 子昊玩方向盤(駕訓班第一天) - 昀洛畢業證書 - 水聽桶子換水 - **生智學會吹口哨** ----- Arduino code ``` arduino= // https://github.com/hideakitai/MPU9250 #include "MPU9250.h" MPU9250 mpu; struct Imu { float ax, ay, az; float gx, gy, gz; float mx, my, mz; float roll, yaw, pitch; }; void setup() { Serial.begin(9600); Wire.begin(); delay(2000); mpu.setup(); } void loop() { static uint32_t prev_ms = millis(); if ((millis() - prev_ms) > 90) // 0.1s { mpu.update(); // mpu.print(); // Direct use write() to sedn buffer data Imu data = {mpu.getAcc(0), mpu.getAcc(1), mpu.getAcc(2), mpu.getGyro(0), mpu.getGyro(1), mpu.getGyro(2), mpu.getMag(0), mpu.getMag(1), mpu.getMag(2), mpu.getRoll(), mpu.getYaw(), mpu.getPitch()}; Serial.write((byte*)&data, sizeof(data)); Serial.write(10); // Could use print() & println() to sedn over String /* Serial.print(mpu.getAcc(0)); Serial.print(" "); Serial.print(mpu.getAcc(1)); Serial.println(); */ prev_ms = millis(); } } ``` 用 Pyserial 在TX2讀出 ```python= #!/usr/bin/env python3 import serial from struct import * # import rospy # from std_msgs.msg import String # from std_msgs.msg import Float32 # from sensor_msgs.msg import Imu port = '/dev/ttyACM0' arduino = serial.Serial(port, 9600, timeout=1) if not arduino.is_open: arduino.open() a = 1 # for i in range(30): # data_raw = arduino.readline() while(arduino.is_open): a += 1 data_raw = arduino.readline() # data = tuple() try: data = unpack('ffffffffffffc', data_raw) print(a, data) except Exception as e: print('length: '+ str(len(data_raw))) print(e) ''' readline() until asscii 10 Serial.write(10) ''' # print(a, data_raw) ``` ## 8/14 1. 發現tx2開發板不支援PWM ## 8/25 1. 整理 github Controller repo 的 branch 2. 測試同時兩顆馬達的運轉狀況 -> 良好 3. **要確保不會短路** 4. 測試 mpu9250 的 PID code ## 8/26 ### 育騰大爆發 ```python= import cv2 import numpy as np from matplotlib.pyplot import imshow from matplotlib import pyplot as plt from scipy.stats import linregress import matplotlib.pyplot as plt %matplotlib inline img = cv2.imread('floor.jpg') gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) bw = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, \ cv2.THRESH_BINARY, 15, -2) kernel_size = 5 blur_gray = cv2.GaussianBlur(gray,(kernel_size, kernel_size),0) low_threshold = 20 high_threshold = 50 edges = cv2.Canny(blur_gray, low_threshold, high_threshold) rho = 5 # distance resolution in pixels of the Hough grid theta = np.pi / 180 # angular resolution in radians of the Hough grid threshold = 100 # minimum number of votes (intersections in Hough grid cell) min_line_length = 25 # minimum number of pixels making up a line max_line_gap = 10 # maximum gap in pixels between connectable line segments line_image = np.copy(img) * 0 # creating a blank to draw lines on lines = [] # Run Hough on edge detected image # Output "lines" is an array containing endpoints of detected line segments lines = cv2.HoughLinesP(edges, rho, theta, threshold, np.array([]), min_line_length, max_line_gap) count=0 for line in lines: count+=1 for x1,y1,x2,y2 in line: cv2.line(line_image,(x1,y1),(x2,y2),(255,0,0),5) # Draw the lines on the image lines_edges = cv2.addWeighted(img, 0.8, line_image, 1, 0) # x1 x2 y1 y2 can form a line lines = lines.reshape(count,4) slope = [] for i in range(count): x_coordinate = [] y_coordinate = [] for j in range(4): if j%2: y_coordinate.append(lines[i][j]) #y coordinate for y1 y2 else: x_coordinate.append(lines[i][j]) #x coordinate for x1 x2 #do a linear regression to get slope of line result = linregress(x_coordinate, y_coordinate) # got the degree by slope result = np.degrees(np.arctan(result[0])) # turn two slope into the same theta if abs(result)>45: slope.append(abs(result)) else: slope.append(90-abs(result)) #delete the nan slope = [slope for slope in slope if str(slope) != 'nan'] #average all possible slope if len(slope) >0: s = sum(slope)/len(slope) print(s) plt.imshow(lines_edges) plt.show ``` ![](https://i.imgur.com/rB1KsP7.png) / - yaw 最終版本:超過45度就不準了 ```python= import numpy as np import cv2 import time from matplotlib.pyplot import imshow from matplotlib import pyplot as plt from scipy.stats import linregress import matplotlib.pyplot as plt from numpy import * import sys %matplotlib inline cap = cv2.VideoCapture(0) while(True): #cv2.waitKey(delay_time) ret, frame = cap.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) bw = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, \ cv2.THRESH_BINARY, 15, -2) kernel_size = 5 blur_gray = cv2.GaussianBlur(gray,(kernel_size, kernel_size),0) low_threshold = 20 high_threshold = 50 edges = cv2.Canny(blur_gray, low_threshold, high_threshold) rho = 6 # distance resolution in pixels of the Hough grid theta = np.pi / 60 # angular resolution in radians of the Hough grid threshold = 400 # minimum number of votes (intersections in Hough grid cell) min_line_length = 50 # minimum number of pixels making up a line max_line_gap = 25 # maximum gap in pixels between connectable line segments line_image = np.copy(blur_gray) * 0 # creating a blank to draw lines on lines = [] # Run Hough on edge detected image # Output "lines" is an array containing endpoints of detected line segments lines = cv2.HoughLinesP(edges, rho, theta, threshold, np.array([]), min_line_length, max_line_gap) count=0 #print(lines is None) if lines is None: continue #print(lines) for line in lines: count+=1 for x1,y1,x2,y2 in line: cv2.line(line_image,(x1,y1),(x2,y2),(255,0,0),5) # Draw the lines on the image lines_edges = cv2.addWeighted(blur_gray, 0.8, line_image, 1, 0) lines = lines.reshape(count,4) slope1=[] slope2=[] for i in range(count): x_coordinate = [] y_coordinate = [] for j in range(4): if j%2: y_coordinate.append(lines[i][j]) else: x_coordinate.append(lines[i][j]) result=linregress(x_coordinate,y_coordinate) result=np.degrees(np.arctan(result[0])) #print(result) if result>=0: slope1.append(result) else: slope2.append(result) slope1=[slope1 for slope1 in slope1 if str(slope1) != 'nan'] slope2=[slope2 for slope2 in slope2 if str(slope2) != 'nan'] #print('slope1=',slope1) #print('slope2=',slope2) s1=sum(slope1)/len(slope1) s2=sum(slope2)/len(slope2) if len(slope1)>0: s1=sum(slope1)/len(slope1) #print('average1=',s1) if len(slope2)>0: s2=sum(slope2)/len(slope2) #print('average2=',s2) final1=[] final2=[] if(s1<45): final1.append(s1) for i in range(len(final1)): final1= [x for x in final1 if x != max] print('final1=',final1) if(abs(s2)<45): final2.append(s2) for i in range(len(final2)): final2= [x for x in final2 if x != max] print('final2=',final2) #out.write(lines_edges) cv2.imshow('lines_edges',lines_edges) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cap.release() cv2.destroyAllWindows() sys.exit() ``` ![](https://i.imgur.com/V79gD1x.png) ### PCA9685 1. 將 motor control 以 array 傳控制訊號 (kgf) 2. 將 motor control node 包成 class [github](https://github.com/NCTU-AUV/Controller/commit/4dddec15b6373e20a370aa9e72643258fcdbd3e3) 3. 利用 pyqtgraph 視覺化 pitch roll 4. 如果要更改 pca9685 的頻率 要先改回睡眠模式 [網站](http://blog.ittraining.com.tw/2015/07/raspberry-pi2-python-i2c-16-pwm-pca9685.html)的頻率公式有錯 **正確:** ![](https://i.imgur.com/GEr4RQJ.png) 5. [相關細節](https://hackmd.io/yRG0nUkNSgiBiFhXCQy25w?both#PyQt-amp-PyQtGraph) ## 9/2 - PID control 可以在螢幕上跑了 泳池來要去調參數 - Yaw 的地板版本完成即時 ## 9/3 :::danger # 水聽大爆發 :+1: :fire: :dancers: :baby: - 感謝交大第一顏值擔當 aka 水聽組扛壩子 -- 梁育騰 - 直接拿資料成功 - 肉眼可以看出波形前後 - 麥克風2 (Due板A1) 比較強勢 - 大家回去辨識資料看看 - [FFT & Amplifier & Hilbert](https://wizardforcel.gitbooks.io/hyry-studio-scipy/content/20.html) ::: ------- ## 9/4 - FSM 第一版完成 - 壓力計換算測試 ## Detail 想說為了排版方便,就把雜亂的東東丟過來 ### PyQt & PyQtGraph 1. https://www.learnpyqt.com/courses/graphics-plotting/plotting-pyqtgraph/ 2. https://www.cnblogs.com/linyfeng/p/12239856.html #### 8/26 pid code https://www-users.cs.york.ac.uk/~mjf/perpetual_pi/Python/pid.py ### xlxs with python To read T200 data sheet ``` python= from openpyxl import load_workbook wb = load_workbook('T200.xlsx') sheet_16v = wb.get_sheet_by_name('16 V') # col_force = [col.value for col in sheet_16v['F']] # for val in col_force: # print(val, end=', ') col_signal = [col.value for col in sheet_16v['H']] for val in col_signal: print(val, end=', ') ``` # ### 壓力計 ``` python= #include <Wire.h> #include "MS5837.h" MS5837 sensor; void setup() { Serial.begin(9600); Serial.println("Starting"); Wire.begin(); sensor.setModel(MS5837::MS5837_30BA); sensor.setFluidDensity(997); // kg/m^3 (freshwater, 1029 for seawater) } void loop() { sensor.read(); Serial.print(5.26*(sensor.depth()-196)+1.584); delay(10); } ``` ## 12/6 檢討 1. NUC 試用 2. Rpi 使用PWM __ **(connect arduino*2)** 3. TX2 視覺 ### 配重: 1. 把白色板子拔掉 2. 算浮心 3. 想辦法把密度變成0.9 ### 購買: 1. 鉛塊 2. 銅柱 3. 穩壓 (switch 和 NUC 和 TX2) 5. 鰭片 6. 散熱膏 7. KillButtom ### 馬達: 1. 重新焊接 ### 鏡頭: 1. train 泥庫

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully