Running All the Above Python Scripts as Single Master Python Script on Startup on Companion Computer

                We have seen that VPN services incase of Beagle Bone Blue or companion computer are auto running on startup using systemd file. But the MAVPROXY for MAVlink, BMS data capture and mm Wave radar python scripts need to be run on start up. Hence, we make a master python script which will run all the three python scripts on startup using .bashrc file on startup. This master python script will auto run incase of Raspberry Pi 4 but incase of Jetson Nano, the user will have to login to ssh before all are master python script is triggered on due to higher security settings in Jetson Nano. This allows better user control and security of drone incase of Jetson Nano.

                Master python script is used to run MAVPROXY, BMS Data capture and mm Wave Radar python scripts on startup though .bashrc file. Once can always omit the part not required by commenting the relevant section of this python script.

For running master_script.py on boot, amend bash.rc

For Raspberry Pi 4

sudo nano /home/pi/.bashrc
Add the lines
echo Running at boot
python3 master_script.py

For Jetson Nano

sudo nano /home/maverick/.bashrc
Add the lines
echo Running at boot
sudo python3 master_script.py

Note: Replace maverick with your username on Nano

Master_script.py for Raspberry Pi 4

#!/usr/bin/env python3

##  Running these two scripts simultaneously:       ##
##   - mmwave_to_mavlink.py                                ##
##   - bms_data_capture.py                                      ##
##   - mavproxy.py                                                  ##  
##                                                                            ##

import os
import os.path
import threading
import serial

connection_in_port = “/dev/ttyS0”        # Serial port connected to FCU
connection_in_baud = “921600”            # As per Mission Planner settings
connection_out_p01 = “127.0.0.1:14550”   # Radar
connection_out_p02 = “100.96.1.34:1194”  # Mission Planner

def mavproxy_create_connection():
    os.system(“python3 $HOME/.local/bin/mavproxy.py” + \
            “ –master=”   + connection_in_port + \
            “ –baudrate=” + connection_in_baud + \
            “ –out udp:”  + connection_out_p01 + \
            “ –out udp:”  + connection_out_p02)

def run_radar():
   os.system(“python3 ~/mm_Wave_Radar_IWR6843AOPEVM/mmwave_to_mavlink.py”)

def run_battcapture():
   os.system(“python3 ~/BattMgmtSys_Dashboard/bms_data_capture.py”)

thread1 = threading.Thread(target=mavproxy_create_connection)
thread1.start()

thread2 = threading.Thread(target=run_radar)
thread2.start()

thread3 = threading.Thread(target=run_battcapture)
thread3.start()

Master_script.py for Jetson Nano                                               

#!/usr/bin/env python3

##  Running these two scripts simultaneously:       ##
##   - mmwave_to_mavlink.py                               ##
##   - bms_data_capture.py                                     ##
##   - mavproxy.py                                                 ##  
##                                                                            ##

import os
import os.path
import threading
import serial

connection_in_port = “/dev/ttyTHS1”        # Serial port connected to FCU
connection_in_baud = “921600”              # As per Mission Planner settings
connection_out_p01 = “127.0.0.1:14550”     # Radar
connection_out_p02 = “100.96.1.34:1194”    # Mission Planner

def mavproxy_create_connection():
    os.system(“python3 /home/maverick/.local/bin/mavproxy.py” + \
            “ –master=”   + connection_in_port + \
            “ –baudrate=” + connection_in_baud + \
            “ –out udp:”  + connection_out_p01 + \
            “ –out udp:”  + connection_out_p02)

def run_radar():
os.system(“python3 /home/maverick/mm_Wave_Radar_IWR6843AOPEVM/mmwave_to_mavlink.py”)

def run_battcapture():
  os.system(“python3 /home/maverick/BattMgmtSys_Dashboard/bms_data_capture.py”)

thread1 = threading.Thread(target=mavproxy_create_connection)
thread1.start()

thread2 = threading.Thread(target=run_radar)
thread2.start()

thread3 = threading.Thread(target=run_battcapture)
thread3.start()

Overall companion computer connectivity diagram

Overall Connectivity diagrams         So now we see the overall connectivity diagram of companion computers with connected peripherals/sensors namely proximity sensor  IWR6843AOPEVM mm Wave radar, onboard camera and smart battery with BMS.

For Raspberry Pi 4 as companion computer

The connectivity diagram for physical integration of Companion computer (Raspberry Pi 4) with proximity sensor  IWR6843AOPEVM mm Wave radar, onboard camera and smart battery with BMS
The connectivity diagram for physical integration of Companion computer (Raspberry Pi 4) with proximity sensor IWR6843AOPEVM mm Wave radar, onboard camera and smart battery with BMS

For Jetson Nano as companion computer

The connectivity diagram for physical integration of Companion computer (Jetson Nano) with proximity sensor  IWR6843AOPEVM mm Wave radar, onboard camera and smart battery with BMS
The connectivity diagram for physical integration of Companion computer (Jetson Nano) with proximity sensor IWR6843AOPEVM mm Wave radar, onboard camera and smart battery with BMS

            The overall power distribution connectivity block diagram of the drones have been depicted below. It is important to note that a dedicated effort was done to keep the power and signal connections separate with no sensor being powered through Beagle Bone Blue. Though  Beagle Bone Blue is capable of providing 5V power to sensors like GPS and 5V power output option, it was intentionally avoided to prevent any damage to Beagle Bone Blue which being the Flight Controller Unit (FCU) is the most critical component of a drone. Hence, the power to each sensor or component has been distributed separately through power distribution board or DC-DC convertor. The setup was tested on all three drones.  

            Small X-Type quadcopter        The small X-type drone is powered through 3s (11.1V nominal and 12.6V peak) LiPo battery pack. Here, the power was distributed through a power distribution panel with frame itself for Electronic Speed Controls which in turn are powering the motors. The sensors have been powered by 5V DC-DC convertor. There are only two sensors/peripherals on board namely GPS with compass and radio controller 9RC) receiver. The flight controller is Beagle Bone Blue and it acts like both the FCU and companion computer. The 4G communication module is connected to Beagle Bone Blue. The broad connectivity diagram for power distribution is as below

Overall power distribution block diagram of X-Type Quadcopter
Overall power distribution block diagram of X-Type Quadcopter

          Small V Type quadcopter         The small V type drone is powered through 4s (14.8V nominal and 16.8V peak) LiPo battery pack. Here the power was distributed through a power distribution module which takes input of 4s (16.5V) and gives 16.5V for distribution to ESCs and DC-DC converted 12V and 5V output for powering sensors. Only Companion computer was powered through another dedicated DC-DC convertor giving 5V and 2-3 Amps as companion computer was powering the mmWave radar through USB and camera through USB. The board connectivity diagram is as below:

Overall power distribution block diagram of V-Type Quadcopter
Overall power distribution block diagram of V-Type Quadcopter

          Medium weight drone (Hexacopter)            The medium weight Hex copter type drone is powered through 6s (22.2V nominal and 25.2V peak) LiPo battery pack. Here the power was distributed through dedicated DC-DC convertor giving 12V output for Beagle Bone Blue while 5V for all other sensors including companion. The board connectivity diagram is as below

Overall power distribution block diagram of Hexacopter
Overall power distribution block diagram of Hexacopter

About the Author

Leave a Reply

Your email address will not be published. Required fields are marked *

You may also like these