From 4cc1d21c74f9e841b1f581f9968bd27f5ebbfe02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E8=80=B3=E5=88=AE=E5=AD=90?= <2433069615@qq.com> Date: Sat, 21 May 2022 07:56:30 +0800 Subject: [PATCH 1/2] add --- src/include/Air_Ground_CEC/login.h | 32 ------------------- src/include/Air_Ground_CEC/loginui.h | 40 +++++++++++++++++++++++ src/main/{login.cpp => loginui.cpp} | 47 ++++++++++++++++++++++------ src/main/main.cpp | 4 +-- src/ui/{login.ui => loginui.ui} | 18 +++++------ 5 files changed, 88 insertions(+), 53 deletions(-) delete mode 100644 src/include/Air_Ground_CEC/login.h create mode 100644 src/include/Air_Ground_CEC/loginui.h rename src/main/{login.cpp => loginui.cpp} (66%) rename src/ui/{login.ui => loginui.ui} (96%) diff --git a/src/include/Air_Ground_CEC/login.h b/src/include/Air_Ground_CEC/login.h deleted file mode 100644 index f7c85d2..0000000 --- a/src/include/Air_Ground_CEC/login.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef LOGIN_H -#define LOGIN_H - -#include -#include "ui_login.h" - -namespace Ui { -class Login; -} - -class Login : public QMainWindow -{ - Q_OBJECT - -public: - explicit Login(QWidget *parent = nullptr); - ~Login(); - -private: - Ui::Login *ui; - bool isPressedWidget; - QPoint m_lastPos; - - void initWindow(); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void setWindowState(); - void setBtnAndLabelState(); -}; - -#endif // LOGIN_H diff --git a/src/include/Air_Ground_CEC/loginui.h b/src/include/Air_Ground_CEC/loginui.h new file mode 100644 index 0000000..3debf72 --- /dev/null +++ b/src/include/Air_Ground_CEC/loginui.h @@ -0,0 +1,40 @@ +#ifndef LOGINUI_H +#define LOGINUI_H + +#include +#include "ui_loginui.h" +#include +#include + +using namespace std; + +namespace Ui { +class LoginUi; +} + +class LoginUi : public QMainWindow +{ + Q_OBJECT + +public: + explicit LoginUi(QWidget *parent = nullptr); + ~LoginUi(); + +private: + Ui::LoginUi *ui; + bool isPressedWidget; + QPoint m_lastPos; + + void initWindow(); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void setWindowState(); + void setBtnAndLabelState(); + + bool verifyAccount(string usr, string pwd); + void changetoMainwindow(); + +}; + +#endif // LOGINUI_H diff --git a/src/main/login.cpp b/src/main/loginui.cpp similarity index 66% rename from src/main/login.cpp rename to src/main/loginui.cpp index d189ad3..ac7e539 100644 --- a/src/main/login.cpp +++ b/src/main/loginui.cpp @@ -1,35 +1,36 @@ -#include "../include/Air_Ground_CEC/login.h" +#include "../include/Air_Ground_CEC/loginui.h" +#include "../include/Air_Ground_CEC/mainwindow.hpp" #include #include #include -Login::Login(QWidget *parent) : +LoginUi::LoginUi(QWidget *parent) : QMainWindow(parent), - ui(new Ui::Login) + ui(new Ui::LoginUi) { ui->setupUi(this); initWindow(); } -Login::~Login() +LoginUi::~LoginUi() { delete ui; } -void Login::initWindow(){ +void LoginUi::initWindow(){ setWindowState(); setBtnAndLabelState(); } -void Login::setWindowState(){ +void LoginUi::setWindowState(){ this->setAttribute(Qt::WA_TranslucentBackground); this->setWindowFlags(Qt::FramelessWindowHint);//隐藏边框 } -void Login::setBtnAndLabelState(){ +void LoginUi::setBtnAndLabelState(){ QMovie* movie = new QMovie("://images/background.gif"); ui->label_video->setMovie(movie); movie->start(); @@ -47,14 +48,18 @@ void Login::setBtnAndLabelState(){ connect(ui->btnWinClose, &QPushButton::clicked, this, [=]() { this->close(); }); connect(ui->btnWinClose_2, &QPushButton::clicked, this, [=]() { this->close(); }); + connect(ui->btnLogin, &QPushButton::clicked, this, [=]() { + changetoMainwindow();} + ); + } -void Login::mousePressEvent(QMouseEvent *event) { +void LoginUi::mousePressEvent(QMouseEvent *event) { m_lastPos = event->globalPos(); isPressedWidget = true; // 当前鼠标按下的即是QWidget而非界面上布局的其它控件 } -void Login::mouseMoveEvent(QMouseEvent *event) { +void LoginUi::mouseMoveEvent(QMouseEvent *event) { if (isPressedWidget) { this->move(this->x() + (event->globalX() - m_lastPos.x()), this->y() + (event->globalY() - m_lastPos.y())); @@ -62,8 +67,30 @@ void Login::mouseMoveEvent(QMouseEvent *event) { } } -void Login::mouseReleaseEvent(QMouseEvent *event) { +void LoginUi::mouseReleaseEvent(QMouseEvent *event) { // 其实这里的mouseReleaseEvent函数可以不用重写 m_lastPos = event->globalPos(); isPressedWidget = false; // 鼠标松开时,置为false } + +bool LoginUi::verifyAccount(string usr, string pwd){ + if (usr == "admin" && pwd == "admin"){ + return true; + } + return false; +} + +void LoginUi::changetoMainwindow(){ + this->close(); + MainWindow CEC(0,0,0); + CEC.show(); +} + + + + + + + + + diff --git a/src/main/main.cpp b/src/main/main.cpp index 1542c5a..c8a4313 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -1,5 +1,5 @@ #include "../include/Air_Ground_CEC/mainwindow.hpp" -#include "../include/Air_Ground_CEC/login.h" +#include "../include/Air_Ground_CEC/loginui.h" #include @@ -15,7 +15,7 @@ int main(int argc, char** argv) //MainWindow CEC(0,0,0); //CEC.show(); - Login a(0); + LoginUi a(0); a.show(); return app.exec(); diff --git a/src/ui/login.ui b/src/ui/loginui.ui similarity index 96% rename from src/ui/login.ui rename to src/ui/loginui.ui index 911119f..64e9aae 100755 --- a/src/ui/login.ui +++ b/src/ui/loginui.ui @@ -1,7 +1,7 @@ - Login - + LoginUi + 0 @@ -841,8 +841,8 @@ background-color:none 0 0 - 579 - 196 + 205 + 104 @@ -902,8 +902,8 @@ background-color:none 0 0 - 579 - 196 + 88 + 88 @@ -926,7 +926,7 @@ background-color:none 0 0 - 565 + 267 312 @@ -1251,8 +1251,8 @@ background-color:none 0 0 - 579 - 196 + 313 + 133 From 9304605ba9e9b9a250274fe319b677eb8585a947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E8=80=B3=E5=88=AE=E5=AD=90?= <2433069615@qq.com> Date: Sat, 21 May 2022 23:10:05 +0800 Subject: [PATCH 2/2] success test vedio --- CMakeLists.txt | 5 +---- src/main/Djitellowhite.cpp | 6 +++--- src/main/Triplet.cpp | 8 +++++--- src/main/keyboard.cpp | 2 +- src/main/main.cpp | 9 +++++---- src/main/qnode.cpp | 7 +++++-- src/main/server.cpp | 3 ++- 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 647f2c6..2308cdf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,10 +16,7 @@ find_package(catkin REQUIRED COMPONENTS ## DEPENDS: system dependencies of this project that dependent projects also need catkin_package( -# INCLUDE_DIRS include -# LIBRARIES Air_Ground_CEC -# CATKIN_DEPENDS roscpp -# DEPENDS system_lib + ) ########### diff --git a/src/main/Djitellowhite.cpp b/src/main/Djitellowhite.cpp index c8a8f52..432eef8 100644 --- a/src/main/Djitellowhite.cpp +++ b/src/main/Djitellowhite.cpp @@ -1,6 +1,6 @@ -#include"Djitellowhite.h" -#include -#include +#include "../include/Djitellowhite.h" +#include +#include #include diff --git a/src/main/Triplet.cpp b/src/main/Triplet.cpp index 9c0ef65..0343058 100644 --- a/src/main/Triplet.cpp +++ b/src/main/Triplet.cpp @@ -1,6 +1,7 @@ -#include"Djitellowhite.h" -#include"Hardwarelistener.h" -#include +#include "../include/Djitellowhite.h" +#include "../include/Hardwarelistener.h" +#include +/* using namespace std; int main(void){ Tello T("192.168.10.1"); @@ -43,3 +44,4 @@ int main(void){ listenkeyboard(T,serveraddr); return 0; } +*/ diff --git a/src/main/keyboard.cpp b/src/main/keyboard.cpp index dcf3ade..2233c48 100644 --- a/src/main/keyboard.cpp +++ b/src/main/keyboard.cpp @@ -1,6 +1,6 @@ #include #include -#include "Hardwarelistener.h" +#include "../include/Hardwarelistener.h" #include using namespace std; diff --git a/src/main/main.cpp b/src/main/main.cpp index c8a4313..a860dea 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -13,10 +13,10 @@ int main(int argc, char** argv) QApplication app(argc, argv); - //MainWindow CEC(0,0,0); - //CEC.show(); - LoginUi a(0); - a.show(); + MainWindow CEC(0,0,0); + CEC.show(); + //LoginUi a(0); + //a.show(); return app.exec(); return(0); @@ -26,6 +26,7 @@ int main(int argc, char** argv) /* * find . "(" -name "*.cpp" -or -name "*.h" -or -name "*.hpp" -or -name "*.qrc" ")" -print | xargs wc -l + * git fame --incl '\.[cht]' -twMC * rosrun rqt_graph rqt_graph * git fame */ diff --git a/src/main/qnode.cpp b/src/main/qnode.cpp index 2ba92dc..016c879 100644 --- a/src/main/qnode.cpp +++ b/src/main/qnode.cpp @@ -1,6 +1,8 @@ #include "../include/Air_Ground_CEC/qnode.hpp" #include "sensor_msgs/image_encodings.h" +#include "sensor_msgs/CompressedImage.h" + #include QNode::QNode(int argc, char **argv) : init_argc(argc), init_argv(argv){ @@ -47,7 +49,8 @@ void QNode::SubAndPubTopic(){ &QNode::batteryCallback, this); image_transport::ImageTransport it(n); - image_sub = it.subscribe("camera/rgb/image_raw", 100, &QNode::imageCallback, this); + //camera/rgb/image_raw + image_sub = it.subscribe("raspicam_node/image", 10, &QNode::imageCallback, this); //image_sub0 = n.subscribe("camera/rgb/image_raw",100,&QNode::imageCallback,this) @@ -172,12 +175,12 @@ void QNode::speedCallback(const nav_msgs::Odometry::ConstPtr& msg) { emit speed_x(msg->twist.twist.linear.x); emit speed_th(msg->twist.twist.angular.z); - } void QNode::imageCallback(const sensor_msgs::ImageConstPtr &msg) { + ROS_INFO("i am ok"); try { cv_bridge::CvImageConstPtr cv_ptr = diff --git a/src/main/server.cpp b/src/main/server.cpp index 581b3e7..6d4cffc 100644 --- a/src/main/server.cpp +++ b/src/main/server.cpp @@ -40,7 +40,7 @@ void udp_server(int sockfd) close(sockfd); } - +/* int main(int argc, char **argv) { int sockfd; @@ -54,5 +54,6 @@ int main(int argc, char **argv) exit(0); } +*/