def main(): parsed_args = parse_args() setup_gnd = False # If true we are operating on the ground station else we are on the UAV (by .profile via Cam) config = read_dronebridge_config() if parsed_args.gnd: setup_gnd = True print("---- Initializing adapters for ground station (v" + str(get_firmware_id()) + ")") else: print("---- Initializing adapters for UAV (v" + str(get_firmware_id()) + ")") print("Settings up network interfaces") setup_network_interfaces(setup_gnd, config) # blocks until interface becomes available if setup_gnd and config.get(GROUND, 'wifi_ap') == 'Y': setup_hotspot(config.get(GROUND, 'wifi_ap_if')) if setup_gnd and config.get(GROUND, 'eth_hotspot') == 'Y': setup_eth_hotspot()
def start_gnd_modules(): """ Reads the settings from the config file. Performs some checks and starts the DroneBridge modules on the ground station. """ config = read_dronebridge_config() if config is None: exit(-1) communication_id = config.getint(COMMON, 'communication_id') cts_protection = config.get(COMMON, 'cts_protection') fps = config.getfloat(COMMON, 'fps') video_blocks = config.getint(COMMON, 'video_blocks') video_fecs = config.getint(COMMON, 'video_fecs') video_blocklength = config.getint(COMMON, 'video_blocklength') compatibility_mode = config.getint(COMMON, 'compatibility_mode') datarate = config.getint(GROUND, 'datarate') interface_selection = config.get(GROUND, 'interface_selection') interface_control = config.get(GROUND, 'interface_control') interface_video = config.get(GROUND, 'interface_video') interface_comm = config.get(GROUND, 'interface_comm') interface_proxy = config.get(GROUND, 'interface_proxy') en_control = config.get(GROUND, 'en_control') en_video = config.get(GROUND, 'en_video') en_comm = config.get(GROUND, 'en_comm') en_plugin = config.get(GROUND, 'en_plugin') rc_proto = config.getint(GROUND, 'rc_proto') en_rc_overwrite = config.get(GROUND, 'en_rc_overwrite') joy_interface = config.getint(GROUND, 'joy_interface') fwd_stream = config.get(GROUND, 'fwd_stream') fwd_stream_port = config.getint(GROUND, 'fwd_stream_port') video_mem = config.get(GROUND, 'video_mem') # ---------- pre-init ------------------------ print(GND_STRING_TAG + "Communication ID: " + str(communication_id)) print(GND_STRING_TAG + "Trying to start individual modules...") if interface_selection == 'auto': interface_control = get_all_monitor_interfaces(True) print(f"\tUsing: {interface_control} for all modules") interface_video = interface_control interface_comm = interface_control interface_proxy = interface_control frametype = determine_frametype(cts_protection, get_interface()) # TODO: scan for WiFi traffic on all interfaces # ----------- start modules ------------------------ if en_comm == 'Y': print(f"{GND_STRING_TAG} Starting communication module...") comm = ["python3.7", os.path.join(DRONEBRIDGE_BIN_PATH, 'communication', 'db_communication_gnd.py'), "-m", "m", "-c", str(communication_id), "-a", str(compatibility_mode), "-f", str(frametype)] comm.extend(interface_comm.split()) Popen(comm, shell=False, stdin=None, stdout=None, stderr=None) print(f"{GND_STRING_TAG} Starting status module...") comm_status = [os.path.join(DRONEBRIDGE_BIN_PATH, 'status', 'db_status'), "-m", "m", "-c", str(communication_id)] comm_status.extend(interface_proxy.split()) Popen(comm_status, shell=False, stdin=None, stdout=None, stderr=None) print(f"{GND_STRING_TAG} Starting proxy module...") comm_proxy = [os.path.join(DRONEBRIDGE_BIN_PATH, 'proxy', 'db_proxy'), "-m", "m", "-c", str(communication_id), "-f", str(frametype), "-b", str(get_bit_rate(datarate)), "-a", str(compatibility_mode)] comm_proxy.extend(interface_proxy.split()) Popen(comm_proxy, shell=False, stdin=None, stdout=None, stderr=None) if en_control == 'Y': print(f"{GND_STRING_TAG} Starting control module...") comm_control = [os.path.join(DRONEBRIDGE_BIN_PATH, 'control', 'control_ground'), "-j", str(joy_interface), "-m", "m", "-v", str(rc_proto), "-o", str(en_rc_overwrite), "-c", str(communication_id), "-t", str(frametype), "-b", str(get_bit_rate(datarate)), "-a", str(compatibility_mode)] comm_control.extend(interface_control.split()) Popen(comm_control, shell=False, stdin=None, stdout=None, stderr=None, close_fds=True) if en_plugin == 'Y': print(GND_STRING_TAG + "Starting plugin module...") Popen(["python3.7", os.path.join(DRONEBRIDGE_BIN_PATH, 'plugin', 'db_plugin.py'), "-g"], shell=False, stdin=None, stdout=None, stderr=None, close_fds=True) print(GND_STRING_TAG + "Starting USBBridge module...") Popen([os.path.join(DRONEBRIDGE_BIN_PATH, 'usbbridge', 'usbbridge'), "-v", en_video, "-c", en_comm, "-p", "Y", "-s", "Y"], shell=False, stdin=None, stdout=None, stderr=None, close_fds=True) if en_video == 'Y': print(f"{GND_STRING_TAG} Starting video module... (FEC: {video_blocks}/{video_fecs}/{video_blocklength})") receive_comm = [os.path.join(DRONEBRIDGE_BIN_PATH, 'video', 'video_gnd'), "-d", str(video_blocks), "-r", str(video_fecs), "-f", str(video_blocklength), "-c", str(communication_id), "-p", "N", "-v", str(fwd_stream_port), "-o"] receive_comm.extend(interface_video.split()) db_video_receive = Popen(receive_comm, stdout=subprocess.PIPE, close_fds=True, shell=False, bufsize=0) print(f"{GND_STRING_TAG} Starting video player...") Popen([get_video_player(fps)], stdin=db_video_receive.stdout, close_fds=True, shell=False)
def start_uav_modules(): """ Reads the settings from the config file. Performs some checks and starts the DroneBridge modules on the UAV. """ config = read_dronebridge_config() if config is None: exit(-1) communication_id = config.getint(COMMON, 'communication_id') cts_protection = config.get(COMMON, 'cts_protection') compatibility_mode = config.getint(COMMON, 'compatibility_mode') datarate = config.getint(UAV, 'datarate') interface_selection = config.get(UAV, 'interface_selection') interface_control = config.get(UAV, 'interface_control') interface_video = config.get(UAV, 'interface_video') interface_comm = config.get(UAV, 'interface_comm') en_control = config.get(UAV, 'en_control') en_video = config.get(UAV, 'en_video') en_comm = config.get(UAV, 'en_comm') en_plugin = config.get(UAV, 'en_plugin') video_blocks = config.getint(COMMON, 'video_blocks') video_fecs = config.getint(COMMON, 'video_fecs') video_blocklength = config.getint(COMMON, 'video_blocklength') extraparams = config.get(UAV, 'extraparams') keyframerate = config.getint(UAV, 'keyframerate') width = config.getint(UAV, 'width') height = config.getint(UAV, 'height') fps = config.getfloat(COMMON, 'fps') video_bitrate = config.get(UAV, 'video_bitrate') video_channel_util = config.getint(UAV, 'video_channel_util') en_video_rec = config.get(UAV, 'en_video_rec') video_mem = config.get(UAV, 'video_mem') # path to video files serial_int_cont = config.get(UAV, 'serial_int_cont') baud_control = config.getint(UAV, 'baud_control') serial_prot = config.getint(UAV, 'serial_prot') pass_through_packet_size = config.getint(UAV, 'pass_through_packet_size') enable_sumd_rc = config.get(UAV, 'enable_sumd_rc') serial_int_sumd = config.get(UAV, 'serial_int_sumd') # ---------- pre-init ------------------------ if interface_selection == 'auto': interface_control = get_all_monitor_interfaces(True) print(f"\tUsing: {interface_control} for all modules") interface_video = interface_control interface_comm = interface_control frametype = determine_frametype( cts_protection, get_interface()) # TODO: scan for WiFi traffic on all interfaces if video_bitrate == 'auto' and en_video == 'Y': video_bitrate = int( measure_available_bandwidth(video_blocks, video_fecs, video_blocklength, frametype, datarate, get_all_monitor_interfaces(False))) print( f"{UAV_STRING_TAG} Available bandwidth is {video_bitrate / 1000} kbit/s" ) video_bitrate = int(video_channel_util / 100 * int(video_bitrate)) print( f"{UAV_STRING_TAG} Setting video bitrate to {video_bitrate / 1000} kbit/s" ) else: video_bitrate = str(int(video_bitrate) * 1000) # convert to bit/s (user enters kbit) # ---------- Error pre-check ------------------------ if serial_int_cont == serial_int_sumd and en_control == 'Y' and enable_sumd_rc == 'Y': print( UAV_STRING_TAG + "Error - Control module and SUMD output are assigned to the same serial port. Disabling " "SUMD") enable_sumd_rc = 'N' print(f"{UAV_STRING_TAG} Communication ID: {communication_id}") print(f"{UAV_STRING_TAG} Trying to start individual modules...") # ----------- start modules ------------------------ if en_comm == 'Y': print(f"{UAV_STRING_TAG} Starting communication module...") comm = [ "python3", os.path.join(DRONEBRIDGE_BIN_PATH, 'communication', 'db_communication_air.py'), "-m", "m", "-c", str(communication_id), "-a", str(compatibility_mode), "-f", str(frametype) ] comm.extend(interface_comm.split()) comm_module_process = Popen(comm, shell=False, stdin=None, stdout=None, stderr=None) if en_control == 'Y': print(f"{UAV_STRING_TAG} Starting control module...") comm = [ os.path.join(DRONEBRIDGE_BIN_PATH, 'control', 'control_air'), "-u", str(serial_int_cont), "-m", "m", "-c", str(communication_id), "-v", str(serial_prot), "-t", str(frametype), "-l", str(pass_through_packet_size), "-r", str(baud_control), "-e", str(enable_sumd_rc), "-s", str(serial_int_sumd), "-b", str(get_bit_rate(2)) ] comm.extend(interface_control.split()) control_module_process = Popen(comm, shell=False, stdin=None, stdout=None, stderr=None) if en_plugin == 'Y': print(f"{UAV_STRING_TAG} Starting plugin module...") Popen([ "python3", os.path.join(DRONEBRIDGE_BIN_PATH, 'plugin', 'db_plugin.py') ], shell=False, stdin=None, stdout=None, stderr=None) if en_video == 'Y': print( f"{UAV_STRING_TAG} Starting video transmission, FEC {video_blocks}/{video_fecs}/{video_blocklength} : " f"{width} x {height} fps {fps}, video bitrate: {video_bitrate} bit/s, key framerate: {keyframerate} " f"frame type: {frametype}") #read camera stream using raspivid raspivid_comm = [ "raspivid", "-w", str(width), "-h", str(height), "-fps", str(fps), "-b", str(video_bitrate), "-g", str(keyframerate), "-t", "0" ] raspivid_comm.extend(extraparams.split()) raspivid_comm.extend(["-o", "-"]) print(raspivid_comm) raspivid_task = Popen(raspivid_comm, stdout=subprocess.PIPE, stdin=None, stderr=None, close_fds=True, shell=False, bufsize=0) ########### add gstreamer vor computer vision print(f"{UAV_STRING_TAG} starting gstreamer cv module v.03") ###################################### FFMeg ############################################################ FFMPEG_BIN = "/usr/bin/ffmpeg" ffmpeg_comm = [ FFMPEG_BIN, '-i', '-', # fifo is the named pipe '-pix_fmt', 'bgr24', # opencv requires bgr24 pixel format. '-vcodec', 'h264', '-an', '-sn', # we want to disable audio processing (there is no audio) '-f', '-' ] print(ffmpeg_comm) ffmpeg_task = Popen(ffmpeg_comm, stdout=subprocess.PIPE, stdin=raspivid_task.stdout, stderr=None, close_fds=True, shell=False, bufsize=0) ###################################### Rover IMAGE PROC ############################################################ ROVER_SW = "/home/pi/pv_rover_sw/vision/test.py" rover_sw_comm = ['python3', ROVER_SW] pover_task = Popen(rover_sw_comm, stdout=None, stdin=ffmpeg_task.stdout, stderr=None, close_fds=True, shell=False, bufsize=0) ###################################### TEE Solution ########################################################## # tee_comm = ["tee", "/video.h264"] # tee_task = Popen(tee_comm, stdout=subprocess.PIPE, stdin=raspivid_task.stdout , stderr=None, close_fds=True, # shell=False, bufsize=0) ############################################################################################################ #camfifo = open('/home/pi/DroneBridge/videofile.h264', 'w') #gst-launch-1.0 -v fdsrc ! h264parse ! tee name=splitter ! queue ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.123.106 port=5000 splitter. ! queue ! filesink location="videofile.h264" # gstreamer_comm = ['gst-launch-1.0', 'fdsrc', '!', 'h264parse', '!', 'tee', 'name=splitter', '!', 'queue', '!', # 'rtph264pay', 'config-interval=10', 'pt=96', '!' , 'udpsink', 'host=192.168.123.105','port=5000', # splitter.', '!' ,'queue', '!', 'filesink', 'location=/home/pi/DroneBridge/videofile.h264'] #gstreamer_comm = ['gst-launch-1.0', 'filesrc', 'location=/video.h264' , '!', 'h264parse', '!', 'queue', '!', # 'rtph264pay', 'config-interval=10', 'pt=96', '!' , 'udpsink', 'host=192.168.123.105','port=5000'] #'location=/home/pi/DroneBridge/videofile.h264' #raspivid_comm= ' '.join(map(str, raspivid_comm)) + str(gstreamer_comm) #print(f"{UAV_STRING_TAG} {raspivid_comm}") #gst-launch-1.0 -v fdsrc ! h264parse ! tee name=splitter ! queue ! rtph264pay config-interval=10 pt=96 ! udpsink host=192.168.123.105 port=5000 splitter. ! queue ! filesink location=/dev/stdout #gstreamer_task = Popen(gstreamer_comm, stdout=None, stdin=None, stderr=None, close_fds=True, # shell=False, bufsize=0) ################################################################################################################## video_air_comm = [ os.path.join(DRONEBRIDGE_BIN_PATH, 'video', 'video_air'), "-d", str(video_blocks), "-r", str(video_fecs), "-f", str(video_blocklength), "-t", str(frametype), "-b", str(get_bit_rate(datarate)), "-c", str(communication_id), "-a", str(compatibility_mode) ] video_air_comm.extend(interface_video.split()) # video_air_process = Popen(video_air_comm, stdin =raspivid_task.stdout , stdout=None, stderr=None, close_fds=True, # shell=False) if en_video_rec == 'Y' and video_mem != "": if video_mem.endswith("/"): video_mem = video_mem[:-1] print(f"{UAV_STRING_TAG} Starting video recording to {video_mem}") comm = [ os.path.join(DRONEBRIDGE_BIN_PATH, 'recorder', 'db_recorder'), video_mem ] Popen(comm, shell=False, stdin=None, stdout=None, stderr=None)
def start_uav_modules(): """ Reads the settings from the config file. Performs some checks and starts the DroneBridge modules on the UAV. """ config = read_dronebridge_config() if config is None: exit(-1) communication_id = config.getint(COMMON, 'communication_id') cts_protection = config.get(COMMON, 'cts_protection') compatibility_mode = config.getint(COMMON, 'compatibility_mode') datarate = config.getint(UAV, 'datarate') interface_selection = config.get(UAV, 'interface_selection') interface_control = config.get(UAV, 'interface_control') interface_video = config.get(UAV, 'interface_video') interface_comm = config.get(UAV, 'interface_comm') en_control = config.get(UAV, 'en_control') en_video = config.get(UAV, 'en_video') en_comm = config.get(UAV, 'en_comm') en_plugin = config.get(UAV, 'en_plugin') video_blocks = config.getint(COMMON, 'video_blocks') video_fecs = config.getint(COMMON, 'video_fecs') video_blocklength = config.getint(COMMON, 'video_blocklength') extraparams = config.get(UAV, 'extraparams') keyframerate = config.getint(UAV, 'keyframerate') width = config.getint(UAV, 'width') height = config.getint(UAV, 'height') fps = config.getfloat(COMMON, 'fps') video_bitrate = config.get(UAV, 'video_bitrate') video_channel_util = config.getint(UAV, 'video_channel_util') serial_int_cont = config.get(UAV, 'serial_int_cont') baud_control = config.getint(UAV, 'baud_control') serial_prot = config.getint(UAV, 'serial_prot') pass_through_packet_size = config.getint(UAV, 'pass_through_packet_size') enable_sumd_rc = config.get(UAV, 'enable_sumd_rc') serial_int_sumd = config.get(UAV, 'serial_int_sumd') # ---------- pre-init ------------------------ if interface_selection == 'auto': interface_control = get_all_monitor_interfaces(True) print(f"\tUsing: {interface_control} for all modules") interface_video = interface_control interface_comm = interface_control frametype = determine_frametype(cts_protection, get_interface()) # TODO: scan for WiFi traffic on all interfaces if video_bitrate == 'auto' and en_video == 'Y': video_bitrate = int(measure_available_bandwidth(video_blocks, video_fecs, video_blocklength, frametype, datarate, get_all_monitor_interfaces(False))) print(f"{UAV_STRING_TAG} Available bandwidth is {video_bitrate / 1000} kbit/s") video_bitrate = int(video_channel_util / 100 * int(video_bitrate)) print( f"{UAV_STRING_TAG} Setting video bitrate to {video_bitrate / 1000} kbit/s") else: video_bitrate = str(int(video_bitrate) * 1000) # convert to bit/s (user enters kbit) # ---------- Error pre-check ------------------------ if serial_int_cont == serial_int_sumd and en_control == 'Y' and enable_sumd_rc == 'Y': print(UAV_STRING_TAG + "Error - Control module and SUMD output are assigned to the same serial port. Disabling " "SUMD") enable_sumd_rc = 'N' print(f"{UAV_STRING_TAG} Communication ID: {communication_id}") print(f"{UAV_STRING_TAG} Trying to start individual modules...") # ----------- start modules ------------------------ if en_comm == 'Y': print(f"{UAV_STRING_TAG} Starting communication module...") comm = ["python3.7", os.path.join(DRONEBRIDGE_BIN_PATH, 'communication', 'db_communication_air.py'), "-m", "m", "-c", str(communication_id), "-a", str(compatibility_mode), "-f", str(frametype)] comm.extend(interface_comm.split()) Popen(comm, shell=False, stdin=None, stdout=None, stderr=None) if en_control == 'Y': print(f"{UAV_STRING_TAG} Starting control module...") comm = [os.path.join(DRONEBRIDGE_BIN_PATH, 'control', 'control_air'), "-u", str(serial_int_cont), "-m", "m", "-c", str(communication_id), "-v", str(serial_prot), "-t", str(frametype), "-l", str(pass_through_packet_size), "-r", str(baud_control), "-e", str(enable_sumd_rc), "-s", str(serial_int_sumd), "-b", str(get_bit_rate(2))] comm.extend(interface_control.split()) Popen(comm, shell=False, stdin=None, stdout=None, stderr=None) if en_plugin == 'Y': print(f"{UAV_STRING_TAG} Starting plugin module...") Popen(["python3.7", os.path.join(DRONEBRIDGE_BIN_PATH, 'plugin', 'db_plugin.py')], shell=False, stdin=None, stdout=None, stderr=None) if en_video == 'Y': print(f"{UAV_STRING_TAG} Starting video transmission, FEC {video_blocks}/{video_fecs}/{video_blocklength} : " f"{width} x {height} fps {fps}, video bitrate: {video_bitrate} bit/s, key framerate: {keyframerate} " f"frame type: {frametype}") raspivid_comm = ["raspivid", "-w", str(width), "-h", str(height), "-fps", str(fps), "-b", str(video_bitrate), "-g", str(keyframerate), "-t", "0"] raspivid_comm.extend(extraparams.split()) raspivid_comm.extend(["-o", "-"]) raspivid_task = Popen(raspivid_comm, stdout=subprocess.PIPE, stdin=None, stderr=None, close_fds=True, shell=False, bufsize=0) video_air_comm = [os.path.join(DRONEBRIDGE_BIN_PATH, 'video', 'video_air'), "-d", str(video_blocks), "-r", str(video_fecs), "-f", str(video_blocklength), "-t", str(frametype), "-b", str(get_bit_rate(datarate)), "-c", str(communication_id), "-a", str(compatibility_mode)] video_air_comm.extend(interface_video.split()) Popen(video_air_comm, stdin=raspivid_task.stdout, stdout=None, stderr=None, close_fds=True, shell=False)
def start_uav_modules(): """ Reads the settings from the config file. Performs some checks and starts the DroneBridge modules on the UAV. """ config = read_dronebridge_config() if config is None: exit(-1) communication_id = config.getint(COMMON, 'communication_id') cts_protection = config.get(COMMON, 'cts_protection') compatibility_mode = config.getint(COMMON, 'compatibility_mode') datarate = config.getint(UAV, 'datarate') interface_selection = config.get(UAV, 'interface_selection') interface_control = config.get(UAV, 'interface_control') interface_video = config.get(UAV, 'interface_video') interface_comm = config.get(UAV, 'interface_comm') en_control = config.get(UAV, 'en_control') en_video = config.get(UAV, 'en_video') en_comm = config.get(UAV, 'en_comm') en_plugin = config.get(UAV, 'en_plugin') video_blocks = config.getint(COMMON, 'video_blocks') video_fecs = config.getint(COMMON, 'video_fecs') video_blocklength = config.getint(COMMON, 'video_blocklength') extraparams = config.get(UAV, 'extraparams') keyframerate = config.getint(UAV, 'keyframerate') width = config.getint(UAV, 'width') height = config.getint(UAV, 'height') fps = config.getfloat(COMMON, 'fps') video_bitrate = config.get(UAV, 'video_bitrate') video_channel_util = config.getint(UAV, 'video_channel_util') en_video_rec = config.get(UAV, 'en_video_rec') video_mem = config.get(UAV, 'video_mem') # path to video files serial_int_cont = config.get(UAV, 'serial_int_cont') baud_control = config.getint(UAV, 'baud_control') serial_prot = config.getint(UAV, 'serial_prot') pass_through_packet_size = config.getint(UAV, 'pass_through_packet_size') enable_sumd_rc = config.get(UAV, 'enable_sumd_rc') serial_int_sumd = config.get(UAV, 'serial_int_sumd') # ---------- pre-init ------------------------ if interface_selection == 'auto': interface_control = get_all_monitor_interfaces(True) print(f"\tUsing: {interface_control} for all modules") interface_video = interface_control interface_comm = interface_control frametype = determine_frametype( cts_protection, get_interface()) # TODO: scan for WiFi traffic on all interfaces if video_bitrate == 'auto' and en_video == 'Y': video_bitrate = int( measure_available_bandwidth(video_blocks, video_fecs, video_blocklength, frametype, datarate, get_all_monitor_interfaces(False))) print( f"{UAV_STRING_TAG} Available bandwidth is {video_bitrate / 1000} kbit/s" ) video_bitrate = int(video_channel_util / 100 * int(video_bitrate)) print( f"{UAV_STRING_TAG} Setting video bitrate to {video_bitrate / 1000} kbit/s" ) else: video_bitrate = str(int(video_bitrate) * 1000) # convert to bit/s (user enters kbit) # ---------- Error pre-check ------------------------ if serial_int_cont == serial_int_sumd and en_control == 'Y' and enable_sumd_rc == 'Y': print( UAV_STRING_TAG + "Error - Control module and SUMD output are assigned to the same serial port. Disabling " "SUMD") enable_sumd_rc = 'N' print(f"{UAV_STRING_TAG} Communication ID: {communication_id}") print(f"{UAV_STRING_TAG} Trying to start individual modules...") # ----------- start modules ------------------------ if en_comm == 'Y': print(f"{UAV_STRING_TAG} Starting communication module...") comm = [ "python3", os.path.join(DRONEBRIDGE_BIN_PATH, 'communication', 'db_communication_air.py'), "-m", "m", "-c", str(communication_id), "-a", str(compatibility_mode), "-f", str(frametype) ] comm.extend(interface_comm.split()) comm_module_process = Popen(comm, shell=False, stdin=None, stdout=None, stderr=None) if en_control == 'Y': print(f"{UAV_STRING_TAG} Starting control module...") comm = [ os.path.join(DRONEBRIDGE_BIN_PATH, 'control', 'control_air'), "-u", str(serial_int_cont), "-m", "m", "-c", str(communication_id), "-v", str(serial_prot), "-t", str(frametype), "-l", str(pass_through_packet_size), "-r", str(baud_control), "-e", str(enable_sumd_rc), "-s", str(serial_int_sumd), "-b", str(get_bit_rate(2)) ] comm.extend(interface_control.split()) control_module_process = Popen(comm, shell=False, stdin=None, stdout=None, stderr=None) if en_plugin == 'Y': print(f"{UAV_STRING_TAG} Starting plugin module...") Popen([ "python3", os.path.join(DRONEBRIDGE_BIN_PATH, 'plugin', 'db_plugin.py') ], shell=False, stdin=None, stdout=None, stderr=None) if en_video == 'Y': print( f"{UAV_STRING_TAG} Starting video transmission, FEC {video_blocks}/{video_fecs}/{video_blocklength} : " f"{width} x {height} fps {fps}, video bitrate: {video_bitrate} bit/s, key framerate: {keyframerate} " f"frame type: {frametype}") # Raspvid raspivid_comm = [ "raspivid", "-w", str(width), "-h", str(height), "-fps", str(fps), "-b", str(video_bitrate), "-g", str(keyframerate), "-t", "0" ] raspivid_comm.extend(extraparams.split()) raspivid_comm.extend(["-o", "-"]) video_task = Popen(raspivid_comm, stdout=subprocess.PIPE, stdin=None, stderr=None, close_fds=True, shell=False, bufsize=0) # USB camera #USBCamera="gst-launch-1.0 uvch264src device=/dev/video0 initial-bitrate=\$1 average-bitrate=\$1 iframe-period=1000 name=src auto-start=true src.vidsrc ! queue ! video/x-h264,width=1280,height=720,framerate=30/1 ! h264parse ! rtph264pay ! udpsink host=127.0.0.1 port=5600" # USB working pipline #gst-launch-1.0 uvch264src device=/dev/video1 iframe-period=1000 name=src auto-start=true src.vidsrc ! queue ! filesink location=/dev/stdout # gstreamer_comm = [ # "gst-launch-1.0", # "uvch264src" , # "device=/dev/video1", "iframe-period=1000", "name=src", "auto-start=true", "src.vidsrc", "!", # "queue", "!", # "filesink", "location=/dev/stdout" # ] # video_task = Popen(gstreamer_comm, stdout=subprocess.PIPE, stdin=None, stderr=None, close_fds=True, # shell=False, bufsize=0) # start wifi broadcast video_air_comm = [ os.path.join(DRONEBRIDGE_BIN_PATH, 'video', 'video_air'), "-d", str(video_blocks), "-r", str(video_fecs), "-f", str(video_blocklength), "-t", str(frametype), "-b", str(get_bit_rate(datarate)), "-c", str(communication_id), "-a", str(compatibility_mode) ] video_air_comm.extend(interface_video.split()) video_air_process = Popen(video_air_comm, stdin=video_task.stdout, stdout=None, stderr=None, close_fds=True, shell=False) # Recording if en_video_rec == 'Y' and video_mem != "": if video_mem.endswith("/"): video_mem = video_mem[:-1] print(f"{UAV_STRING_TAG} Starting video recording to {video_mem}") comm = [ os.path.join(DRONEBRIDGE_BIN_PATH, 'recorder', 'db_recorder'), video_mem ] Popen(comm, shell=False, stdin=None, stdout=None, stderr=None)