|
|
|
@ -41,123 +41,7 @@ void MainWindow::initUis(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::setBtnStyles(){
|
|
|
|
|
/*
|
|
|
|
|
* set PushButton state
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
ui->btn_main->setIcon(QIcon("://images/up.png"));
|
|
|
|
|
ui->btn_main->setText("mainWidget");
|
|
|
|
|
ui->btn_main->setStyleSheet(
|
|
|
|
|
"QPushButton:hover{"
|
|
|
|
|
"background-color:rgb(186, 189, 182);"
|
|
|
|
|
"border-bottom:2px solid rgb(67, 154, 246);}"
|
|
|
|
|
"QPushButton:checked{"
|
|
|
|
|
"background-color:cyan;"
|
|
|
|
|
"border-bottom:2px solid white}"
|
|
|
|
|
"QPushButton:pressed{"
|
|
|
|
|
"background-color:rgb(67, 154, 246)}"
|
|
|
|
|
"QPushButton{"
|
|
|
|
|
"background-color:rgb(238, 238, 236);"
|
|
|
|
|
"border:none;"
|
|
|
|
|
"padding:0px 0px 0px 0px;"
|
|
|
|
|
"margin:0px 0px 0px 0px;}");
|
|
|
|
|
|
|
|
|
|
ui->btn_uav->setStyleSheet(
|
|
|
|
|
"QPushButton:hover{"
|
|
|
|
|
"background-color:rgb(186, 189, 182);"
|
|
|
|
|
"border-bottom:2px solid rgb(67, 154, 246);}"
|
|
|
|
|
"QPushButton:checked{"
|
|
|
|
|
"background-color:cyan;"
|
|
|
|
|
"border-bottom:2px solid white}"
|
|
|
|
|
"QPushButton:pressed{"
|
|
|
|
|
"background-color:rgb(67, 154, 246)}"
|
|
|
|
|
"QPushButton{"
|
|
|
|
|
"background-color:rgb(238, 238, 236);"
|
|
|
|
|
"border:none;"
|
|
|
|
|
"padding:0px 0px 0px 0px;"
|
|
|
|
|
"margin:0px 0px 0px 0px;}");
|
|
|
|
|
|
|
|
|
|
ui->btn_ugv->setStyleSheet(
|
|
|
|
|
"QPushButton:hover{"
|
|
|
|
|
"background-color:rgb(186, 189, 182);"
|
|
|
|
|
"border-bottom:2px solid rgb(67, 154, 246);}"
|
|
|
|
|
"QPushButton:checked{"
|
|
|
|
|
"background-color:cyan;"
|
|
|
|
|
"border-bottom:2px solid white}"
|
|
|
|
|
"QPushButton:pressed{"
|
|
|
|
|
"background-color:rgb(67, 154, 246)}"
|
|
|
|
|
"QPushButton{"
|
|
|
|
|
"background-color:rgb(238, 238, 236);"
|
|
|
|
|
"border:none;"
|
|
|
|
|
"padding:0px 0px 0px 0px;"
|
|
|
|
|
"margin:0px 0px 0px 0px;}");
|
|
|
|
|
|
|
|
|
|
// 8 -> Forward: ↑
|
|
|
|
|
ui->pushButton_Forward->setShortcut(Qt::Key_8);
|
|
|
|
|
ui->pushButton_Forward->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/up.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/up_2.png)}");
|
|
|
|
|
ui->pushButton_Forward->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 2 -> Back: ↓
|
|
|
|
|
ui->pushButton_Back->setShortcut(Qt::Key_2);
|
|
|
|
|
ui->pushButton_Back->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/down.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/down_2.png)}");
|
|
|
|
|
ui->pushButton_Back->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 4 -> Left: ←
|
|
|
|
|
ui->pushButton_Left->setShortcut(Qt::Key_4);
|
|
|
|
|
ui->pushButton_Left->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/left.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/left_2.png)}");
|
|
|
|
|
ui->pushButton_Left->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 6 -> Right: →
|
|
|
|
|
ui->pushButton_Right->setShortcut(Qt::Key_6);
|
|
|
|
|
ui->pushButton_Right->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/right.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/right_2.png)}");
|
|
|
|
|
ui->pushButton_Right->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 7 -> Left_Forward: ↖
|
|
|
|
|
ui->pushButton_Left_Forward->setShortcut(Qt::Key_7);
|
|
|
|
|
ui->pushButton_Left_Forward->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/up_left.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/up_left_2.png)}");
|
|
|
|
|
ui->pushButton_Left_Forward->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 9 -> Right_Forward: ↗
|
|
|
|
|
ui->pushButton_Right_Forward->setShortcut(Qt::Key_9);
|
|
|
|
|
ui->pushButton_Right_Forward->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/up_right.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/up_right_2.png)}");
|
|
|
|
|
ui->pushButton_Right_Forward->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 1 -> Left_Back: ↙
|
|
|
|
|
ui->pushButton_Left_Back->setShortcut(Qt::Key_1);
|
|
|
|
|
ui->pushButton_Left_Back->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/down_left.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/down_left_2.png)}");
|
|
|
|
|
ui->pushButton_Left_Back->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 3 -> Right_Back: ↘
|
|
|
|
|
ui->pushButton_Right_Back->setShortcut(Qt::Key_3);
|
|
|
|
|
ui->pushButton_Right_Back->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/down_right.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/down_right_2.png)}");
|
|
|
|
|
ui->pushButton_Right_Back->setFlat(true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::slot_keyboard_control(){
|
|
|
|
@ -189,6 +73,7 @@ void MainWindow::slot_keyboard_control(){
|
|
|
|
|
float turn = ui->horizontalSlider_raw->value() * 0.01;
|
|
|
|
|
//bool is_rage_mode = ui->checkBox_rage_mode->isChecked();
|
|
|
|
|
//std::cout<<liner<<" "<<turn<<std::endl;
|
|
|
|
|
//qnode.AutoMove(0.2,0,1,0);
|
|
|
|
|
qnode.KeyboardMove(key, liner, turn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -228,6 +113,26 @@ void MainWindow::slot_rockKeyChange(int key){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::slot_batteryState(sensor_msgs::BatteryState msg) {
|
|
|
|
|
ui->label_power->setText("10V");
|
|
|
|
|
ui->label_power->setText(QString::number(msg.voltage).mid(0, 5) + "V");
|
|
|
|
|
double percentage = msg.percentage;
|
|
|
|
|
m_DashBoard_x->set_oil(percentage);
|
|
|
|
|
ui->progressBar->setValue(percentage > 100 ? 100 : percentage);
|
|
|
|
|
//当电量过低时发出提示
|
|
|
|
|
if (percentage <= 20) {
|
|
|
|
|
ui->progressBar->setStyleSheet(
|
|
|
|
|
"QProgressBar::chunk {background-color: red;width: 20px;} QProgressBar "
|
|
|
|
|
"{border: 2px solid grey;border-radius: 5px;text-align: center;}");
|
|
|
|
|
// QMessageBox::warning(NULL, "电量不足", "电量不足,请及时充电!",
|
|
|
|
|
// QMessageBox::Yes , QMessageBox::Yes);
|
|
|
|
|
} else {
|
|
|
|
|
ui->progressBar->setStyleSheet(
|
|
|
|
|
"QProgressBar {border: 2px solid grey;border-radius: 5px;text-align: "
|
|
|
|
|
"center;}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::connections(){
|
|
|
|
|
QObject::connect(ui->btn_main, &QPushButton::clicked, this, [=](){
|
|
|
|
|
ui->stackedWidget_main->setCurrentIndex(0);
|
|
|
|
@ -279,7 +184,11 @@ void MainWindow::connections(){
|
|
|
|
|
connect(&qnode, SIGNAL(speed_x(double)), this, SLOT(slot_speed_x(double)));
|
|
|
|
|
connect(&qnode, SIGNAL(speed_th(double)), this, SLOT(slot_speed_th(double)));
|
|
|
|
|
|
|
|
|
|
QObject::connect(&qnode,SIGNAL(loggingCamera()),this,SLOT(updateLogcamera()));
|
|
|
|
|
//电源的信号
|
|
|
|
|
connect(&qnode, SIGNAL(batteryState(sensor_msgs::BatteryState)), this,
|
|
|
|
|
SLOT(slot_batteryState(sensor_msgs::BatteryState)));
|
|
|
|
|
|
|
|
|
|
connect(&qnode, SIGNAL(show_image(QImage)), this, SLOT(slot_show_image(QImage)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -325,7 +234,7 @@ void MainWindow::Slider_linear_valueChanged(int v) {
|
|
|
|
|
ui->label_linear->setText(QString::number(v));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::displayCamera(const QImage &image)
|
|
|
|
|
void MainWindow::slot_show_image(QImage image)
|
|
|
|
|
{
|
|
|
|
|
qimage_mutex_.lock();
|
|
|
|
|
qimage_ = image.copy();
|
|
|
|
@ -333,7 +242,122 @@ void MainWindow::displayCamera(const QImage &image)
|
|
|
|
|
ui->label_camera->resize(ui->label_camera->pixmap()->size());
|
|
|
|
|
qimage_mutex_.unlock();
|
|
|
|
|
}
|
|
|
|
|
void MainWindow::updateLogcamera()
|
|
|
|
|
{
|
|
|
|
|
displayCamera(qnode.image);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::setBtnStyles(){
|
|
|
|
|
/*
|
|
|
|
|
* set PushButton state
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
ui->btn_main->setIcon(QIcon("://images/up.png"));
|
|
|
|
|
ui->btn_main->setText("mainWidget");
|
|
|
|
|
ui->btn_main->setStyleSheet(
|
|
|
|
|
"QPushButton:hover{"
|
|
|
|
|
"background-color:rgb(186, 189, 182);"
|
|
|
|
|
"border-bottom:2px solid rgb(67, 154, 246);}"
|
|
|
|
|
"QPushButton:checked{"
|
|
|
|
|
"background-color:cyan;"
|
|
|
|
|
"border-bottom:2px solid white}"
|
|
|
|
|
"QPushButton:pressed{"
|
|
|
|
|
"background-color:rgb(67, 154, 246)}"
|
|
|
|
|
"QPushButton{"
|
|
|
|
|
"background-color:rgb(238, 238, 236);"
|
|
|
|
|
"border:none;"
|
|
|
|
|
"padding:0px 0px 0px 0px;"
|
|
|
|
|
"margin:0px 0px 0px 0px;}");
|
|
|
|
|
|
|
|
|
|
ui->btn_uav->setStyleSheet(
|
|
|
|
|
"QPushButton:hover{"
|
|
|
|
|
"background-color:rgb(186, 189, 182);"
|
|
|
|
|
"border-bottom:2px solid rgb(67, 154, 246);}"
|
|
|
|
|
"QPushButton:checked{"
|
|
|
|
|
"background-color:cyan;"
|
|
|
|
|
"border-bottom:2px solid white}"
|
|
|
|
|
"QPushButton:pressed{"
|
|
|
|
|
"background-color:rgb(67, 154, 246)}"
|
|
|
|
|
"QPushButton{"
|
|
|
|
|
"background-color:rgb(238, 238, 236);"
|
|
|
|
|
"border:none;"
|
|
|
|
|
"padding:0px 0px 0px 0px;"
|
|
|
|
|
"margin:0px 0px 0px 0px;}");
|
|
|
|
|
|
|
|
|
|
ui->btn_ugv->setStyleSheet(
|
|
|
|
|
"QPushButton:hover{"
|
|
|
|
|
"background-color:rgb(186, 189, 182);"
|
|
|
|
|
"border-bottom:2px solid rgb(67, 154, 246);}"
|
|
|
|
|
"QPushButton:checked{"
|
|
|
|
|
"background-color:cyan;"
|
|
|
|
|
"border-bottom:2px solid white}"
|
|
|
|
|
"QPushButton:pressed{"
|
|
|
|
|
"background-color:rgb(67, 154, 246)}"
|
|
|
|
|
"QPushButton{"
|
|
|
|
|
"background-color:rgb(238, 238, 236);"
|
|
|
|
|
"border:none;"
|
|
|
|
|
"padding:0px 0px 0px 0px;"
|
|
|
|
|
"margin:0px 0px 0px 0px;}");
|
|
|
|
|
|
|
|
|
|
// 8 -> Forward: ↑
|
|
|
|
|
ui->pushButton_Forward->setShortcut(Qt::Key_8);
|
|
|
|
|
ui->pushButton_Forward->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/up.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/up_2.png)}");
|
|
|
|
|
ui->pushButton_Forward->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 2 -> Back: ↓
|
|
|
|
|
ui->pushButton_Back->setShortcut(Qt::Key_2);
|
|
|
|
|
ui->pushButton_Back->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/down.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/down_2.png)}");
|
|
|
|
|
ui->pushButton_Back->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 4 -> Left: ←
|
|
|
|
|
ui->pushButton_Left->setShortcut(Qt::Key_4);
|
|
|
|
|
ui->pushButton_Left->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/left.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/left_2.png)}");
|
|
|
|
|
ui->pushButton_Left->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 6 -> Right: →
|
|
|
|
|
ui->pushButton_Right->setShortcut(Qt::Key_6);
|
|
|
|
|
ui->pushButton_Right->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/right.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/right_2.png)}");
|
|
|
|
|
ui->pushButton_Right->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 7 -> Left_Forward: ↖
|
|
|
|
|
ui->pushButton_Left_Forward->setShortcut(Qt::Key_7);
|
|
|
|
|
ui->pushButton_Left_Forward->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/up_left.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/up_left_2.png)}");
|
|
|
|
|
ui->pushButton_Left_Forward->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 9 -> Right_Forward: ↗
|
|
|
|
|
ui->pushButton_Right_Forward->setShortcut(Qt::Key_9);
|
|
|
|
|
ui->pushButton_Right_Forward->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/up_right.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/up_right_2.png)}");
|
|
|
|
|
ui->pushButton_Right_Forward->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 1 -> Left_Back: ↙
|
|
|
|
|
ui->pushButton_Left_Back->setShortcut(Qt::Key_1);
|
|
|
|
|
ui->pushButton_Left_Back->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/down_left.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/down_left_2.png)}");
|
|
|
|
|
ui->pushButton_Left_Back->setFlat(true);
|
|
|
|
|
|
|
|
|
|
// 3 -> Right_Back: ↘
|
|
|
|
|
ui->pushButton_Right_Back->setShortcut(Qt::Key_3);
|
|
|
|
|
ui->pushButton_Right_Back->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/down_right.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/down_right_2.png)}");
|
|
|
|
|
ui->pushButton_Right_Back->setFlat(true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|