## 使用硬體 pixhawk、 Raspi Raspberry pi5 python venv install pymavlink pixhawk 6x connect use usb or uart [Companion Computers Communicating with Raspberry Pi via MAVLink](https://ardupilot.org/dev/docs/raspberry-pi-via-mavlink.html) ``` listen.py ------------------------------------------ from pymavlink import mavutil the_connection = mavutil.mavlink_connection("/dev/ttyACM0") the_connection.wait_heartbeat() print("Heartbeat from system (system %u component %u)" % (the_connection.target_system, the_connection.target_component)) --------------------------------------------- (yolov7) richard@raspberrypi5:~/pymavlink $ python listen.py Heartbeat from system (system 1 component 0) ``` 連線成功的輸出如下圖  使用 mavproxy.py 的輸出如下圖  mavlink_connection()參數:  connection string:  從 pixhawk 收資訊: ``` # listen.py from pymavlink import mavutil import time the_connection = mavutil.mavlink_connection('/dev/ttyACM1') # 'udpin:localhost:14550' # '/dev/ttyACM0' the_connection.wait_heartbeat() print("Heartbeat from system (system %u component %u)" % (the_connection.target_system, the_connection.target_component)) # the_connection.mav.system_time_send(int(time.time()), int(time.time())) while 1: msg = the_connection.recv_match(type='SYS_STATUS', blocking=True) print(msg) ```  ## 如何使用虛擬環境 sim_vehcile.py & sitl 安裝: ardupilot & submodule git clone https://github.com/ArduPilot/ardupilot.git 安裝 submodule (因為ardupilot github裡面沒有這些submodule) git submodule update --recursive git submodule init 安裝後才能執行 sim_vehcile.py  執行後如下   執行 mavproxy.py  執行 listen.py ``` from pymavlink import mavutil the_connection = mavutil.mavlink_connection('udpin:localhost:14550') the_connection.wait_heartbeat() print("Heartbeat from system (system %u component %u)" % (the_connection.target_system, the_connection.target_component)) ```  ## sim_7600x minicom -D /dev/ttyUSB3  ## usbcam install picamera2 https://datasheets.raspberrypi.com/camera/picamera2-manual.pdf ``` sudo apt install -y python3-picamera2 ... ``` 注意: picamera2 對 usb 的支援有限制,需進一步測試! 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up