Skip to content

This report instructs how to make the connection between a Pixhawk PX4 and a Raspberry Pi 4.

Notifications You must be signed in to change notification settings

Annsiyu/RasberryPi4_and_Pixhawk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 

Repository files navigation

RasberryPi4_and_Pixhawk.

This report instructs how to make the connection between a Pixhawk (all versions) and a Raspberry Pi 4 using the MAVLink Protocol to control the drone remotely and see it information.

The information below is valid only to the OS: Linux (recommend Ubuntu 20.04 or later).

# Pixhawk:

1. Connect the Pixhawk with QGroundControl and configure the following Pixhawk parameters:


SERIAL2_PROTOCOL = 1 (Mavlink 1 = 1 or Mavlink 2 = 2)

SERIAL2_BAUD = 921 (baud rate = 921600)

EKF2_AID_MASK = use optical flow only

CBRK_SUPPLY_CHK = no check

CBRK_USB_CHK = no check

MAV_0_CONFIG = TELEM 2

MAV_0_MODE = Onboard

MAV_0_RATE = 1200 B/s

COM_OBL_ACT = land

COM_OBL_RC_ACT = land

CBRK_IO_SAFETY = no check

2. Telemetry connection.


Using jumpers, connect the TELEM 2 (Pixhawk) via USB-Serial adapter to an USB on the Raspberry Pi4. See the link below for more information:

https://dev.px4.io/master/en/companion_computer/pixhawk_companion.html#hardware-setup

# Raspberry Pi4:

3. Run the code below to see which USB port the Pixhawk is connected:
  $ lsusb

The device ID is important to the next step (the ID number is likely to change);

4. Run the line below to change the USB rules:


  $ sudo nano /etc/udev/rules.d/99-pixhawk.rules

5. Enter this line with the correct ID code:


  $ SUBSYSTEM=="tty", ATTRS{idVendor}=="HERE", ATTRS{idProduct}=="HERE", SYMLINK+="ttyPix4"

6. Run these commands to update and upgrade the packages in the Raspberry Pi 4 :

  $ sudo apt-get install screen python-wxgtk3.0 python-matplotlib python-opencv python-pip python-numpy python-dev libxml2-dev libxslt-dev
  $ sudo pip3 install future
  $ sudo pip3 install pymavlink
  $ sudo pip3 install mavproxy
  $ sudo apt-get update
  $ sudo apt-get upgrade
  $ sudo reboot now   (This step is necessary to compile all the changes)

7. Test the connection between Pixhawk and Raspberry Pi 4:


  $ sudo su
  $ mavproxy.py --master=/dev/ttyPix4 --baudrate 921600 --out=udp:0.0.0.0:14550 --out=udp:0.0.0.0:14551 --aircraft MyCopter
  ("--aircraft" will be the folder to store the log files.)

8. Install SSH on a Linux machine:


  $ sudo apt-get install ssh

or

  $ sudo apt-get install openssh-client

9. Enable SSH on Raspberry Pi 4:


  $ raspi-config

10. Go to [ Interfacing Options > SSH > Yes > Finish ]. And now reboot:


  $ sudo reboot now

11. In the Host pc, another LINUX computer, install the MAVproxy and DroneKit:


  $ sudo -H pip3 install mavproxy
  $ sudo -H pip3 install dronekit
  $ sudo -H pip3 install pymavlink

12. Clone the dronekit-python repository in the Host PC (Linux recommended):


  $ git clone https://github.com/dronekit/dronekit-python.git

13. Use the code magnetometer.py in the folder Examples/ to take the values of the magnetometer sensor as an example.


14. Type this line to connect to Pixhawk:


  $ python3 mag_pix4.py --connect "0.0.0.0:14551"

References


https://dronekit.netlify.app/

https://docs.px4.io/v1.9.0/en/advanced_config/parameter_reference.html

https://dev.px4.io/master/en/companion_computer/pixhawk_companion.html#hardware-setup

https://github.com/yingshaoxo/suicide-squad/tree/master/PX4

About

This report instructs how to make the connection between a Pixhawk PX4 and a Raspberry Pi 4.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published