Ejemplo n.º 1
0
from dji_asdk_to_python.products.aircraft import Aircraft
from dji_asdk_to_python.battery.battery_state import BatteryState

APP_IP = "192.168.0.174"

drone = Aircraft(APP_IP)
battery = drone.getBattery()
battery_state = battery.getBatteryState()

print("battery state %s " % battery_state.getChargeRemainingInPercent())
Ejemplo n.º 2
0
while elapsed < MIN_ELAPSED_TIME or flying:
    #while i != 2:
    #i += 1
    # Updating time variables
    if time.time() >= time_0 + 1.0 / FREQ_SEND:
        now = datetime.datetime.now()
        print("Current date and time : ")
        print(now.strftime("%Y-%m-%d %H:%M:%S"))
        count += 1
        print(count)
        time_0 = time.time()
        elapsed = time_0 - start

        # Getting battery state and flight controller state

        battery = aircraft.getBattery()
        battery_state = battery.getBatteryState()
        flight_controller_state = flight_controller.getState()

        # Evaluating a correct flight controller state

        if not isinstance(flight_controller_state, FlightControllerState):
            continue

        # Getting parameters for drone in flight

        flying = flight_controller_state.isFlying()
        aircraft_attitude = flight_controller_state.getAttitude()
        aircraft_location = flight_controller_state.getAircraftLocation()

        remaining_battery = battery_state.getChargeRemainingInPercent()