Skip to content
Snippets Groups Projects
UAS.cc 36.5 KiB
Newer Older
  • Learn to ignore specific revisions
  • pixhawk's avatar
    pixhawk committed
    {
        quint64 dt = MG::TIME::getGroundTimeNow() - startTime;
        double seconds = dt / 1000.0f;
        double voltDifference = startVoltage - currentVoltage;
        if (voltDifference <= 0) voltDifference = 0.00000000001f;
        double dischargePerSecond = voltDifference / seconds;
        int remaining = static_cast<int>((currentVoltage - emptyVoltage) / dischargePerSecond);
        // Can never be below 0
        if (remaining < 0) remaining = 0;
        return remaining;
    }
    
    
    lm's avatar
    lm committed
    /**
     * @return charge level in percent - 0 - 100
     */
    
    pixhawk's avatar
    pixhawk committed
    double UAS::getChargeLevel()
    {
        return 100.0f * ((lpVoltage - emptyVoltage)/(fullVoltage - emptyVoltage));
    }
    
    
    lm's avatar
    lm committed
    void UAS::startLowBattAlarm()
    {
        if (!lowBattAlarm)
        {
            GAudioOutput::instance()->startEmergency("BATTERY");
            lowBattAlarm = true;
        }
    }
    
    void UAS::stopLowBattAlarm()
    {
        if (lowBattAlarm)
        {
            GAudioOutput::instance()->stopEmergency();
            lowBattAlarm = false;
        }
    }
    
    
    pixhawk's avatar
    pixhawk committed
    void UAS::clearWaypointList()
    {
        mavlink_message_t message;
        // FIXME
        //messagePackRemoveWaypoints(MG::SYSTEM::ID, &message);
        sendMessage(message);
        qDebug() << "UAS clears Waypoints!";
    }