|
|
|
@ -9,7 +9,7 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) :
|
|
|
|
|
{
|
|
|
|
|
qnode.init();
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
setBtnStates();
|
|
|
|
|
initUis();
|
|
|
|
|
connections();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -19,41 +19,12 @@ MainWindow::~MainWindow()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::initUis(){
|
|
|
|
|
/*
|
|
|
|
|
* set PushButton state
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void MainWindow::slot_keyboard_control(){
|
|
|
|
|
QPushButton *btn = qobject_cast<QPushButton *>(sender());
|
|
|
|
|
std::string btn_name = btn->text().toStdString();
|
|
|
|
|
char key = ' ';
|
|
|
|
|
|
|
|
|
|
if (btn_name == "↙")
|
|
|
|
|
key = '1';
|
|
|
|
|
else if (btn_name == "↓")
|
|
|
|
|
key = '2';
|
|
|
|
|
else if (btn_name == "↘")
|
|
|
|
|
key = '3';
|
|
|
|
|
else if (btn_name == "←")
|
|
|
|
|
key = '4';
|
|
|
|
|
//else if (btn_name == "")
|
|
|
|
|
// key = '5';
|
|
|
|
|
else if (btn_name == "→")
|
|
|
|
|
key = '6';
|
|
|
|
|
else if (btn_name == "↖")
|
|
|
|
|
key = '7';
|
|
|
|
|
else if (btn_name == "↑")
|
|
|
|
|
key = '8';
|
|
|
|
|
else if (btn_name == "↗")
|
|
|
|
|
key = '9';
|
|
|
|
|
|
|
|
|
|
//速度
|
|
|
|
|
float liner = ui->horizontalSlider_linear->value() * 0.01;
|
|
|
|
|
float turn = ui->horizontalSlider_raw->value() * 0.01;
|
|
|
|
|
//bool is_rage_mode = ui->checkBox_rage_mode->isChecked();
|
|
|
|
|
std::cout<<liner<<" "<<turn<<std::endl;
|
|
|
|
|
qnode.KeyboardMove(key, liner, turn);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::setBtnStates(){
|
|
|
|
|
// 8 -> Forward: ↑
|
|
|
|
|
ui->pushButton_Forward->setShortcut(Qt::Key_8);
|
|
|
|
|
ui->pushButton_Forward->setStyleSheet(
|
|
|
|
|
"QPushButton{border-image: url(://images/up.png)}"
|
|
|
|
@ -61,67 +32,165 @@ void MainWindow::setBtnStates(){
|
|
|
|
|
"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/up.png)}"
|
|
|
|
|
"QPushButton{border-image: url(://images/down.png)}"
|
|
|
|
|
"QPushButton{border:none}"
|
|
|
|
|
"QPushButton:pressed{border-image: url(://images/up_2.png)}");
|
|
|
|
|
"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("border:none");
|
|
|
|
|
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("border:none");
|
|
|
|
|
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("border:none");
|
|
|
|
|
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("border:none");
|
|
|
|
|
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("border:none");
|
|
|
|
|
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("border:none");
|
|
|
|
|
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::connections(){
|
|
|
|
|
//绑定速度控制按钮
|
|
|
|
|
// 8 -> Forward:↑
|
|
|
|
|
/*
|
|
|
|
|
* init
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
connect(ui->pushButton_Forward, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
rock_widget = new JoyStick(ui->JoyStick_widget);
|
|
|
|
|
rock_widget->show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui->pushButton_Back, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(ui->pushButton_Left, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
void MainWindow::slot_keyboard_control(){
|
|
|
|
|
QPushButton *btn = qobject_cast<QPushButton *>(sender());
|
|
|
|
|
std::string btn_name = btn->text().toStdString();
|
|
|
|
|
char key = ' ';
|
|
|
|
|
|
|
|
|
|
if (btn_name == "↙")
|
|
|
|
|
key = '1';
|
|
|
|
|
else if (btn_name == "↓")
|
|
|
|
|
key = '2';
|
|
|
|
|
else if (btn_name == "↘")
|
|
|
|
|
key = '3';
|
|
|
|
|
else if (btn_name == "←")
|
|
|
|
|
key = '4';
|
|
|
|
|
//else if (btn_name == "")
|
|
|
|
|
// key = '5';
|
|
|
|
|
else if (btn_name == "→")
|
|
|
|
|
key = '6';
|
|
|
|
|
else if (btn_name == "↖")
|
|
|
|
|
key = '7';
|
|
|
|
|
else if (btn_name == "↑")
|
|
|
|
|
key = '8';
|
|
|
|
|
else if (btn_name == "↗")
|
|
|
|
|
key = '9';
|
|
|
|
|
|
|
|
|
|
connect(ui->pushButton_Right, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
//速度
|
|
|
|
|
float liner = ui->horizontalSlider_linear->value() * 0.01;
|
|
|
|
|
float turn = ui->horizontalSlider_raw->value() * 0.01;
|
|
|
|
|
//bool is_rage_mode = ui->checkBox_rage_mode->isChecked();
|
|
|
|
|
//std::cout<<liner<<" "<<turn<<std::endl;
|
|
|
|
|
qnode.KeyboardMove(key, liner, turn);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect(ui->pushButton_Left_Forward, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
|
|
|
|
|
void MainWindow::slot_rockKeyChange(int key){
|
|
|
|
|
//速度
|
|
|
|
|
float liner = ui->horizontalSlider_linear->value() * 0.01;
|
|
|
|
|
float turn = ui->horizontalSlider_raw->value() * 0.01;
|
|
|
|
|
switch (key) {
|
|
|
|
|
case upleft:
|
|
|
|
|
qnode.KeyboardMove('7', liner, turn);
|
|
|
|
|
break;
|
|
|
|
|
case up:
|
|
|
|
|
qnode.KeyboardMove('8', liner, turn);
|
|
|
|
|
break;
|
|
|
|
|
case upright:
|
|
|
|
|
qnode.KeyboardMove('9', liner, turn);
|
|
|
|
|
break;
|
|
|
|
|
case left:
|
|
|
|
|
qnode.KeyboardMove('4', liner, turn);
|
|
|
|
|
break;
|
|
|
|
|
case right:
|
|
|
|
|
qnode.KeyboardMove('6', liner, turn);
|
|
|
|
|
break;
|
|
|
|
|
case downleft:
|
|
|
|
|
qnode.KeyboardMove('1', liner, turn);
|
|
|
|
|
break;
|
|
|
|
|
case down:
|
|
|
|
|
qnode.KeyboardMove('2', liner, turn);
|
|
|
|
|
break;
|
|
|
|
|
case downright:
|
|
|
|
|
qnode.KeyboardMove('3', liner, turn);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect(ui->pushButton_Right_Forward, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::connections(){
|
|
|
|
|
/*
|
|
|
|
|
* 绑定速度控制按钮
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// 8 -> Forward: ↑
|
|
|
|
|
connect(ui->pushButton_Forward, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
// 2 -> Back: ↓
|
|
|
|
|
connect(ui->pushButton_Back, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
// 4 -> Left: ←
|
|
|
|
|
connect(ui->pushButton_Left, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
// 6 -> Right: →
|
|
|
|
|
connect(ui->pushButton_Right, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
// 7 -> Left_Forward: ↖
|
|
|
|
|
connect(ui->pushButton_Left_Forward, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
// 9 -> Right_Forward: ↗
|
|
|
|
|
connect(ui->pushButton_Right_Forward, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
// 1 -> Left_Back: ↙
|
|
|
|
|
connect(ui->pushButton_Left_Back, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3 -> Right_Back: ↘
|
|
|
|
|
connect(ui->pushButton_Right_Back, SIGNAL(clicked()), this, SLOT(slot_keyboard_control()));
|
|
|
|
|
|
|
|
|
|
connect(rock_widget, SIGNAL(keyNumchanged(int)), this,
|
|
|
|
|
SLOT(slot_rockKeyChange(int)));
|
|
|
|
|
|
|
|
|
|
//绑定slider的函数
|
|
|
|
|
connect(ui->horizontalSlider_raw, SIGNAL(valueChanged(int)), this,
|
|
|
|
|