To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 711b0e83 authored by beuchatp's avatar beuchatp
Browse files

Fixed a few bugs, but the .pro file needs to know about the resources

parent 3b3619a2
......@@ -214,11 +214,11 @@ private:
int m_battery_state;
// BATTERY EMPTY VOLTAGES (THESE SHOULD BE READ IN AS PARAMTERS)
//const std::vector<float> m_cutoff_voltages {3.1966, 3.2711, 3.3061, 3.3229, 3.3423, 3.3592, 3.3694, 3.385, 3.4006, 3.4044, 3.4228, 3.4228, 3.4301, 3.4445, 3.4531, 3.4677, 3.4705, 3.4712, 3.4756, 3.483, 3.4944, 3.5008, 3.5008, 3.5084, 3.511, 3.5122, 3.5243, 3.5329, 3.5412, 3.5529, 3.5609, 3.5625, 3.5638, 3.5848, 3.6016, 3.6089, 3.6223, 3.628, 3.6299, 3.6436, 3.6649, 3.6878, 3.6983, 3.7171, 3.7231, 3.7464, 3.7664, 3.7938, 3.8008, 3.816, 3.8313, 3.8482, 3.866, 3.8857, 3.8984, 3.9159, 3.9302, 3.9691, 3.997, 4.14 };
const float battery_voltage_empty_while_flying = 2.80 // in Volts
const float battery_voltage_empty_while_motors_off = 3.30 // in Volts
const float battery_voltage_empty_while_flying = 2.80; // in Volts
const float battery_voltage_empty_while_motors_off = 3.30; // in Volts
// BATTERY FULL VOLTAGES
const float battery_voltage_full_while_flying = 3.40 // in Volts
const float battery_voltage_full_while_motors_off = 4.20 // in Volts
const float battery_voltage_full_while_flying = 3.40; // in Volts
const float battery_voltage_full_while_motors_off = 4.20; // in Volts
ros::Publisher crazyRadioCommandPublisher;
ros::Subscriber crazyRadioStatusSubscriber;
......
......@@ -172,6 +172,16 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) :
ui->label_battery->setStyleSheet("QLabel { color : red; }");
m_battery_state = BATTERY_STATE_NORMAL;
// SET THE IMAGE FOR THE BATTERY STATUS LABEL
QPixmap battery_empty_pixmap(":/images/battery_empty.png");
ui->label_battery->setPixmap(battery_empty_pixmap);
ui->label_battery->setScaledContents(true);
// SET THE IMAGE FOR THE BATTERY STATUS LABEL
QPixmap rf_disconnected_pixmap(":/images/rf_disconnected.png");
ui->rf_status_label->setPixmap(rf_disconnected_pixmap);
ui->rf_status_label->setScaledContents(true);
ui->error_label->setStyleSheet("QLabel { color : red; }");
ui->error_label->clear();
......@@ -372,6 +382,7 @@ void MainWindow::batteryStateChangedCallback(const std_msgs::Int32& msg)
switch(msg.data)
{
case BATTERY_STATE_LOW:
{
qstr.append("Low Battery!");
ui->take_off_button->setEnabled(false);
ui->land_button->setEnabled(false);
......@@ -387,7 +398,10 @@ void MainWindow::batteryStateChangedCallback(const std_msgs::Int32& msg)
// SET THE CLASS VARIABLE FOR TRACKING THE BATTERY STATE
m_battery_state = BATTERY_STATE_LOW;
break;
}
case BATTERY_STATE_NORMAL:
{
// ui->groupBox_4->setEnabled(true);
ui->take_off_button->setEnabled(true);
ui->land_button->setEnabled(true);
......@@ -397,6 +411,8 @@ void MainWindow::batteryStateChangedCallback(const std_msgs::Int32& msg)
// SET THE CLASS VARIABLE FOR TRACKING THE BATTERY STATE
m_battery_state = BATTERY_STATE_NORMAL;
break;
}
default:
break;
}
......@@ -463,7 +479,7 @@ float MainWindow::fromVoltageToPercent(float voltage)
}
// COMPUTE THE PERCENTAGE
float percentage = 100 * (voltage-voltage_when_empty)/(voltage_when_full-voltage_when_empty)
float percentage = 100 * (voltage-voltage_when_empty)/(voltage_when_full-voltage_when_empty);
// CLIP THE PERCENTAGE TO BE BETWEEN [0,100]
......@@ -495,14 +511,17 @@ void MainWindow::updateBatteryVoltage(float battery_voltage)
{
// WHEN THE BATTERY IS IN A LOW STATE
case BATTERY_STATE_LOW:
{
// SET THE IMAGE FOR THE BATTERY STATUS LABEL
QPixmap battery_empty_pixmap(":/images/battery_empty.png");
ui->label_battery->setPixmap(battery_empty_pixmap);
ui->label_battery->setScaledContents(true);
break;
}
// WHEN THE BATTERY IS IN A NORMAL STATE
case BATTERY_STATE_NORMAL:
{
if (battery_voltage_percentage <= 0)
{
// SET THE IMAGE FOR THE BATTERY STATUS LABEL
......@@ -546,7 +565,7 @@ void MainWindow::updateBatteryVoltage(float battery_voltage)
ui->label_battery->setScaledContents(true);
}
break;
}
default:
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment