if __name__ == "__main__": import time import PPM import pigpio pi = pigpio.pi() if not pi.connected: exit(0) pi.wave_tx_stop() # Start with a clean slate. ppm = PPM.X(pi, 4, frame_ms=20) updates = 0 start = time.time() for chan in range(8): for pw in range(1000, 2000, 5): ppm.update_channel(chan, pw) updates += 1 end = time.time() secs = end - start print("{} updates in {:.1f} seconds ({}/s)".format(updates, secs, int(updates / secs))) ppm.update_channels([1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000]) time.sleep(2)
if __name__ == "__main__": import pandas as pd import time import PPM import pigpio df = pd.read_excel('dataset/dummy.xlsx') print(df) pi = pigpio.pi() pi.wave_tx_stop() # start with a clean start ppm = PPM.X(pi, 6, frame_ms=20) updates = 0 for pw in range(450, 600, 20): for chan in range(8): ppm.update_channel(chan, pw) updates += 1 time.sleep(2) for i in range(len(df)): pwm_lst = df.iloc[i, 1:7].tolist() final_lst = list(map(int, pwm_lst)) print(final_lst) ppm.update_channels(final_lst) updates += 1
def buzzFailure(): GPIO.output(BUZZER, GPIO.HIGH) time.sleep(2) GPIO.output(BUZZER, GPIO.LOW) time.sleep(1) pi = pigpio.pi() if not pi.connected: print("error") exit(0) pi.wave_tx_stop() # Start with a clean slate. ppm = PPM.X(pi, 6, frame_ms=27) # GPIO 6 for PPM class flightBehavior: GPS_COORDINATES = 1 HOVER = 2 NAVIGATE_TO_DESTINATION = 3 GIVE_SAMPLE = 4 RETURN_TO_HOME = 5 # important function to send signals to Arduino def signalParameters(throttle, yaw, pitch, roll, ARM, FAILSAFE, ANGLE_MODE, ALTHOLD): print("throttle = ", throttle) print("yaw = ", yaw)