diff --git a/CMakeLists.txt b/CMakeLists.txt index ec4c611..42f69d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ find_package(catkin REQUIRED COMPONENTS roscpp std_msgs cv_bridge + sensor_msgs image_transport ) @@ -122,16 +123,19 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(SOURCES src/include/qnode.hpp - src/include/roskeyboardteleopnode.h + src/include/joystick.h src/main/main.cpp src/main/mainwindow.cpp src/main/qnode.cpp - src/main/roskeyboardteleopnode.cpp + src/main/joystick.cpp src/ui/mainwindow.hpp src/ui/mainwindow.ui + ) + +QT5_add_resources(qrc_Files src/resources/images.qrc) ## Specify additional locations of header files ## Your package locations should be listed before other locations include_directories( @@ -140,7 +144,7 @@ include_directories( ${OpenCV_INCLUDE_DIRS} ) -add_executable(Air_Ground_CEC ${SOURCES}) +add_executable(Air_Ground_CEC ${SOURCES} ${qrc_Files}) target_link_libraries(Air_Ground_CEC Qt5::Widgets ${catkin_LIBRARIES} diff --git a/doc/空地协同无人侦察系统-软件设计规格说明书.doc b/doc/空地协同无人侦察系统-软件设计规格说明书.doc new file mode 100644 index 0000000..21c3aba Binary files /dev/null and b/doc/空地协同无人侦察系统-软件设计规格说明书.doc differ diff --git a/doc/空地协同无人侦察系统-软件需求构思及描述.docx b/doc/空地协同无人侦察系统-软件需求构思及描述.docx new file mode 100644 index 0000000..98af291 Binary files /dev/null and b/doc/空地协同无人侦察系统-软件需求构思及描述.docx differ diff --git a/doc/空地协同无人侦查系统-软件需求规格说明书.docx b/doc/空地协同无人侦察系统-软件需求规格说明书.docx similarity index 100% rename from doc/空地协同无人侦查系统-软件需求规格说明书.docx rename to doc/空地协同无人侦察系统-软件需求规格说明书.docx diff --git a/doc/空地协同无人侦查系统-软件设计规格说明书.doc b/doc/空地协同无人侦查系统-软件设计规格说明书.doc deleted file mode 100644 index e6854b4..0000000 Binary files a/doc/空地协同无人侦查系统-软件设计规格说明书.doc and /dev/null differ diff --git a/doc/空地协同无人侦查系统-软件需求构思及描述模板.docx b/doc/空地协同无人侦查系统-软件需求构思及描述模板.docx deleted file mode 100755 index e9dff3b..0000000 Binary files a/doc/空地协同无人侦查系统-软件需求构思及描述模板.docx and /dev/null differ diff --git a/src/include/joystick.h b/src/include/joystick.h new file mode 100644 index 0000000..26969d3 --- /dev/null +++ b/src/include/joystick.h @@ -0,0 +1,55 @@ +#ifndef JOYSTICK_H +#define JOYSTICK_H + +#include +#include +#include +#include +#include +#include +#include +class JoyStick : public QWidget { + Q_OBJECT + + public: + JoyStick(QWidget *parent = 0); + ~JoyStick(); + enum { + upleft = 0, + up, + upright, + left, + stop, + right, + downleft, + down, + downright + }; + signals: + void keyNumchanged(int num); + + protected: + void paintEvent(QPaintEvent *event) override; + void mouseMoveEvent(QMouseEvent *event) override; + void mouseReleaseEvent(QMouseEvent *event) override; + void mousePressEvent(QMouseEvent *event) override; + // void resizeEvent(QResizeEvent *event)override; + private: + int mouseX; + int mouseY; + int JoyStickX; //摇杆 + int JoyStickY; + int JoyStickR; + int padX; //底盘 + int padY; + int padR; + double handPadDis; //两圆圆心距离 + bool mousePressed; + QTimer *tim; + + private: + double Pointdis(int a, int b, int x, int y); //两点距离 + int getKeyNum(); +}; + +#endif // JoyStick_H diff --git a/src/include/qnode.hpp b/src/include/qnode.hpp index 8585220..019414e 100644 --- a/src/include/qnode.hpp +++ b/src/include/qnode.hpp @@ -4,6 +4,8 @@ #ifndef Q_MOC_RUN #include #endif +#include + #include #include @@ -17,6 +19,8 @@ #include #include +using namespace std; + class QNode : public QThread{ Q_OBJECT @@ -25,13 +29,8 @@ public: virtual ~QNode(); bool init(); void SubAndPubTopic(); - void KeyboardMove(char key); - //void myCallback_img(const sensor_msgs::ImageConstPtr& msg);//camera callback function - //QImage image; - + void KeyboardMove(char key, float speed_linear, float speed_trun); -//Q_SIGNALS: - //void loggingCamera();//发出设置相机图片信号 private: int init_argc; @@ -39,11 +38,7 @@ private: ros::Subscriber cmdVel_sub; ros::Publisher cmd_pub; - //ros::Publisher chatter_publisher; - //QStringList logging_model; - //image_transport::Subscriber image_sub; -//cv::Mat img; }; #endif diff --git a/src/main/joystick.cpp b/src/main/joystick.cpp new file mode 100644 index 0000000..8d6eb41 --- /dev/null +++ b/src/main/joystick.cpp @@ -0,0 +1,105 @@ +#include "../include/joystick.h" + +#include +JoyStick::JoyStick(QWidget* parent) : QWidget(parent) { + setPalette(QPalette(Qt::white)); + resize(parent->width(), parent->height()); + setMinimumSize(100, 100); + mouseX = width() / 2; + mouseY = height() / 2; + tim = new QTimer(this); + connect(tim, &QTimer::timeout, this, + [=] { emit keyNumchanged(getKeyNum()); }); + // connect(this,&JoyStick::keyNumchanged,this,[=](int num){ + // qDebug()<pos().x(); + mouseY = event->pos().y(); + if (r == true) { + update(); + r = false; + } else { + r = true; + } +} +void JoyStick::mouseReleaseEvent(QMouseEvent* event) { + mouseX = width() / 2; + mouseY = height() / 2; + tim->stop(); + mousePressed = false; + emit keyNumchanged(JoyStick::stop); + update(); +} +void JoyStick::mousePressEvent(QMouseEvent* event) { + mouseX = event->pos().x(); + mouseY = event->pos().y(); + tim->start(100); + mousePressed = true; + update(); +} + +double JoyStick::Pointdis(int a, int b, int x, int y) { + return sqrt((double)((x - a) * (x - a) + (y - b) * (y - b))); +} +int JoyStick::getKeyNum() { + int x, y; + int keynum; + x = (int)(JoyStickX * 3.0 / (padR * 2)); + y = (int)(JoyStickY * 3.0 / (padR * 2)); + keynum = 3 * y + x; + return keynum; +} diff --git a/src/main/main.cpp b/src/main/main.cpp index a983b77..e31bc33 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -22,3 +22,6 @@ int main(int argc, char** argv) +/* + * find . "(" -name "*.cpp" -or -name "*.h" -or -name "*.hpp" -or -name "*.qrc" ")" -print | xargs wc -l + */ diff --git a/src/main/mainwindow.cpp b/src/main/mainwindow.cpp index 46c1caa..2d32fd7 100644 --- a/src/main/mainwindow.cpp +++ b/src/main/mainwindow.cpp @@ -9,6 +9,7 @@ MainWindow::MainWindow(int argc, char **argv, QWidget *parent) : { qnode.init(); ui->setupUi(this); + initUis(); connections(); } @@ -18,63 +19,255 @@ MainWindow::~MainWindow() } +void MainWindow::initUis(){ + setBtnStyles(); + + + /* + * init + */ + + rock_widget = new JoyStick(ui->JoyStick_widget); + rock_widget->show(); + + +} + + +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(){ QPushButton *btn = qobject_cast(sender()); std::string btn_name = btn->text().toStdString(); char key = ' '; - if (btn_name == "左"){ - key = 'a'; - } - else if (btn_name == "右") { - key = 'd'; - } - else if (btn_name == "前") { - key = 'w'; - } - else if (btn_name == "后") { - key = 's'; - } - /* - else if (btn_name == "加速") { - key = 'f'; - } - */ + 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'; - qnode.KeyboardMove(key); + //速度 + 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<pushButton_W->setShortcut(Qt::Key_W); - connect(ui->pushButton_W, SIGNAL(clicked()), this, SLOT(slot_keyboard_control())); - ui->pushButton_S->setShortcut(Qt::Key_S); - connect(ui->pushButton_S, SIGNAL(clicked()), this, SLOT(slot_keyboard_control())); - ui->pushButton_A->setShortcut(Qt::Key_A); - connect(ui->pushButton_A, SIGNAL(clicked()), this, SLOT(slot_keyboard_control())); - ui->pushButton_D->setShortcut(Qt::Key_D); - connect(ui->pushButton_D, SIGNAL(clicked()), this, SLOT(slot_keyboard_control())); - connect(ui->pushButton_shift, SIGNAL(clicked()), this, SLOT(slot_keyboard_control())); - // - //QObject::connect(&qnode, SIGNAL(loggingCamera()), this, SLOT(slot_updateCamera())); + +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; + } + } +void MainWindow::connections(){ + QObject::connect(ui->btn_main, &QPushButton::clicked, this, [=](){ + ui->stackedWidget_main->setCurrentIndex(0); + }); + QObject::connect(ui->btn_uav, &QPushButton::clicked, this, [=](){ + ui->stackedWidget_main->setCurrentIndex(1); + }); + QObject::connect(ui->btn_ugv, &QPushButton::clicked, this, [=](){ + ui->stackedWidget_main->setCurrentIndex(2); + }); + /* + * 绑定速度控制按钮 + */ + + // 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))); -/* -void MainWindow::slot_dispalyCamera(const QImage &image){ - qimage_mutex.lock(); - qimage = image.copy(); - ui->UGV_Vedio->setPixmap(QPixmap::fromImage(qimage)); - ui->UGV_Vedio->resize(ui->UGV_Vedio->pixmap()->size()); - qimage_mutex.unlock(); + //绑定slider的函数 + connect(ui->horizontalSlider_raw, SIGNAL(valueChanged(int)), this, + SLOT(Slider_raw_valueChanged(int))); + connect(ui->horizontalSlider_linear, SIGNAL(valueChanged(int)), this, + SLOT(Slider_linear_valueChanged(int))); } -void MainWindow::slot_updateCamera() -{ - slot_dispalyCamera(qnode.image); +//滑动条处理槽函数 +void MainWindow::Slider_raw_valueChanged(int v) { + ui->label_raw->setText(QString::number(v)); +} +//滑动条处理槽函数 +void MainWindow::Slider_linear_valueChanged(int v) { + ui->label_linear->setText(QString::number(v)); } -*/ diff --git a/src/main/qnode.cpp b/src/main/qnode.cpp index 35c7ed5..7afa84b 100644 --- a/src/main/qnode.cpp +++ b/src/main/qnode.cpp @@ -30,37 +30,35 @@ void QNode::SubAndPubTopic(){ cmd_pub = n.advertise("cmd_vel", 1); } -void QNode::KeyboardMove(char key){ +void QNode::KeyboardMove(char key, float speed_linear, float speed_trun){ std::map> moveBindings { - // {'key', {speed, turn}} - {'w', {1, 0}}, {'s', {-1, 0}}, {'a', {0, 1}}, {'d', {0, -1}}, - {'W', {1, 0}}, {'S', {-1, 0}}, {'A', {0, 1}}, {'D', {0, -1}} + // {'key', {x, y, z, th}} + {'7', {1, 1, 0, 1}}, {'8', {1, 0, 0, 0}}, {'9', {1, -1, 0, -1}}, + {'4', {0, 0, 0, 1}}, {'5', {0, 0, 0, 0}}, {'6', {0, 0, 0, -1}}, + {'1', {-1, 1, 0, 1}}, {'2', {-1, 0, 0, 0}}, {'3', {-1, -1, 0, -1}} }; float x = moveBindings[key][0]; - float z = moveBindings[key][1]; + float y = moveBindings[key][1]; + float z = moveBindings[key][2]; + float th = moveBindings[key][3]; + + //计算线速度和角速度 + float speed = speed_linear; + float turn = speed_trun; + + geometry_msgs::Twist twist; - twist.linear.x = x; - twist.angular.z = z; + twist.linear.x = x * speed; + twist.linear.y = y * speed; + twist.linear.z = z * speed; + + twist.angular.x = 0; + twist.angular.y = 0; + twist.angular.z = th * turn; + cmd_pub.publish(twist); ros::spinOnce(); } -/* -void QNode::myCallback_img(const sensor_msgs::ImageConstPtr &msg) -{ - try - { - cv_bridge::CvImageConstPtr cv_ptr = cv_bridge::toCvShare(msg, sensor_msgs::image_encodings::RGB8); - img = cv_ptr->image; - image = QImage(img.data,img.cols,img.rows,img.step[0],QImage::Format_RGB888);//change to QImage format - ROS_INFO("I'm setting picture in mul_t callback function!"); - Q_EMIT loggingCamera(); - } -catch (cv_bridge::Exception& e) - { - ROS_ERROR("Could not convert from '%s' to 'bgr8'.", msg->encoding.c_str()); - } -} -*/ diff --git a/src/resources/images.qrc b/src/resources/images.qrc new file mode 100644 index 0000000..5b4cff0 --- /dev/null +++ b/src/resources/images.qrc @@ -0,0 +1,20 @@ + + + images/down.png + images/down_2.png + images/down_left.png + images/down_left_2.png + images/down_right.png + images/down_right_2.png + images/left.png + images/left_2.png + images/right.png + images/right_2.png + images/up.png + images/up_2.png + images/up_left.png + images/up_left_2.png + images/up_right.png + images/up_right_2.png + + diff --git a/src/resources/images/down.png b/src/resources/images/down.png new file mode 100644 index 0000000..1fdba49 Binary files /dev/null and b/src/resources/images/down.png differ diff --git a/src/resources/images/down_2.png b/src/resources/images/down_2.png new file mode 100644 index 0000000..b0f2433 Binary files /dev/null and b/src/resources/images/down_2.png differ diff --git a/src/resources/images/down_left.png b/src/resources/images/down_left.png new file mode 100644 index 0000000..d29e9dc Binary files /dev/null and b/src/resources/images/down_left.png differ diff --git a/src/resources/images/down_left_2.png b/src/resources/images/down_left_2.png new file mode 100644 index 0000000..dd21fc2 Binary files /dev/null and b/src/resources/images/down_left_2.png differ diff --git a/src/resources/images/down_right.png b/src/resources/images/down_right.png new file mode 100644 index 0000000..f65187d Binary files /dev/null and b/src/resources/images/down_right.png differ diff --git a/src/resources/images/down_right_2.png b/src/resources/images/down_right_2.png new file mode 100644 index 0000000..408b905 Binary files /dev/null and b/src/resources/images/down_right_2.png differ diff --git a/src/resources/images/left.png b/src/resources/images/left.png new file mode 100644 index 0000000..2b60f08 Binary files /dev/null and b/src/resources/images/left.png differ diff --git a/src/resources/images/left_2.png b/src/resources/images/left_2.png new file mode 100644 index 0000000..26ea2cc Binary files /dev/null and b/src/resources/images/left_2.png differ diff --git a/src/resources/images/right.png b/src/resources/images/right.png new file mode 100644 index 0000000..0a6ca1d Binary files /dev/null and b/src/resources/images/right.png differ diff --git a/src/resources/images/right_2.png b/src/resources/images/right_2.png new file mode 100644 index 0000000..581bbe8 Binary files /dev/null and b/src/resources/images/right_2.png differ diff --git a/src/resources/images/up.png b/src/resources/images/up.png new file mode 100644 index 0000000..5a5717f Binary files /dev/null and b/src/resources/images/up.png differ diff --git a/src/resources/images/up_2.png b/src/resources/images/up_2.png new file mode 100644 index 0000000..200be6e Binary files /dev/null and b/src/resources/images/up_2.png differ diff --git a/src/resources/images/up_left.png b/src/resources/images/up_left.png new file mode 100644 index 0000000..53d47cb Binary files /dev/null and b/src/resources/images/up_left.png differ diff --git a/src/resources/images/up_left_2.png b/src/resources/images/up_left_2.png new file mode 100644 index 0000000..b8824ba Binary files /dev/null and b/src/resources/images/up_left_2.png differ diff --git a/src/resources/images/up_right.png b/src/resources/images/up_right.png new file mode 100644 index 0000000..21c37f5 Binary files /dev/null and b/src/resources/images/up_right.png differ diff --git a/src/resources/images/up_right_2.png b/src/resources/images/up_right_2.png new file mode 100644 index 0000000..1fa93ac Binary files /dev/null and b/src/resources/images/up_right_2.png differ diff --git a/src/ui/Triplet/1.txt b/src/ui/Triplet/1.txt new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/src/ui/Triplet/1.txt @@ -0,0 +1 @@ +test diff --git a/src/ui/mainwindow.hpp b/src/ui/mainwindow.hpp index 3254020..99e7f4f 100644 --- a/src/ui/mainwindow.hpp +++ b/src/ui/mainwindow.hpp @@ -6,6 +6,7 @@ #include #include "ui_mainwindow.h" +#include "../include/joystick.h" #include "../include/qnode.hpp" namespace Ui { @@ -19,18 +20,39 @@ class MainWindow : public QMainWindow public: explicit MainWindow(int argc, char **argv, QWidget *parent = 0); ~MainWindow(); + enum { + upleft = 0, + up, + upright, + left, + stop, + right, + downleft, + down, + downright + }; + + public slots: void slot_keyboard_control(); - //void slot_updateCamera(); - //void slot_dispalyCamera(const QImage& image); + //void slot_command_control(int linear, int angular); + void slot_rockKeyChange(int); + void Slider_raw_valueChanged(int v); + void Slider_linear_valueChanged(int v); + + private: Ui::MainWindow *ui; - void connections(); QNode qnode; - //QImage qimage; - //mutable QMutex qimage_mutex; + JoyStick *rock_widget; + + void initUis(); + void setBtnStyles(); + void connections(); + + }; diff --git a/src/ui/mainwindow.ui b/src/ui/mainwindow.ui index a3c59f5..7cc172a 100644 --- a/src/ui/mainwindow.ui +++ b/src/ui/mainwindow.ui @@ -6,243 +6,797 @@ 0 0 - 1600 - 900 + 1440 + 810 MainWindow + + + - - - - 1160 - 240 - 314 - 164 - - - - - - - - 100 - 50 - - - - - 100 - 50 - - - - - 15 - - - - - - - - - - - - 100 - 50 - - - - - 100 - 50 - - - - - 15 - - - - - - - - - - - - 100 - 50 - - - - - 100 - 50 - - - - - 15 - - - - - + + + + + 2 + + + + + + 780 + 200 + 311 + 151 + + + + Main Widget + + - - - - - - 100 - 50 - - - - - 100 - 50 - - - - - 15 - - - - - + + + + + 830 + 280 + 271 + 121 + + + + UAV Widget + + - - - - - - 100 - 50 - - - - - 100 - 50 - - - - - 15 - - - - 加速 - + + + + + 1000 + 30 + 407 + 680 + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 20 + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + 15 + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + 15 + + + + QPushButton{border-image: url(://images/up.png);} + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + 15 + + + + + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + 15 + + + + + + + + + + + + 90 + 64 + + + + + 90 + 64 + + + + 全向模式(k) + + + K + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + 15 + + + + + + + + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + 15 + + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + 15 + + + + QPushButton{border-image: url(://images/down.png);} +QPushButton{border:none;} +QPushButton:pressed{border-image: url(://images/down_2.png);} + + + + + + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + 15 + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 30 + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + 线速度(cm/s): + + + + + + + 100 + + + 1 + + + 50 + + + Qt::Horizontal + + + + + + + 50 + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + 角速度(cm/s): + + + + + + + 100 + + + 100 + + + Qt::Horizontal + + + + + + + 100 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 30 + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + + 200 + 200 + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 385 + 21 + + + + + + + + + + + + + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + 0 + 45 + + + + system + + + + + + + + 0 + 45 + + + + keyboard + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + - - - - - - - 610 - 60 - 321 - 211 - - - - TextLabel - - - - - - 60 - 30 - 502 - 654 - - - - - - - - 500 - 300 - - - - - 500 - 300 - - - - false - - - - - - UAV_VEDIO - - - false - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 500 - 300 - - - - - 500 - 300 - - - - PATH - - - - - - - - - - 0 - 0 - 1600 - 22 - - + + + + + + 0 + + + + + + 0 + 60 + + + + + + + + + + + 32 + 32 + + + + + + + + + 0 + 60 + + + + + + + + + + + 32 + 32 + + + + + + + + + 0 + 60 + + + + ArrowCursor + + + + + + + + + + ../../../../../catkin_ws/src/Ros_Qt5_Gui_App/ui../../../../../catkin_ws/src/Ros_Qt5_Gui_App/ui + + + + 32 + 32 + + + + + + + + + 0 + 60 + + + + PointingHandCursor + + + 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; +} + + + + + + + ../../../../../catkin_ws/src/Ros_Qt5_Gui_App/ui../../../../../catkin_ws/src/Ros_Qt5_Gui_App/ui + + + + 32 + 32 + + + + + + + + + 0 + 60 + + + + PointingHandCursor + + + 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; +} + + + + + + + ../../../../../catkin_ws/src/Ros_Qt5_Gui_App/ui../../../../../catkin_ws/src/Ros_Qt5_Gui_App/ui + + + + 32 + 32 + + + + + + + -