https://github.com/mjlee111/qtros
https://github.com/mjlee111/qtros
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mjlee111/qtros
- Owner: mjlee111
- Created: 2023-02-20T01:32:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-21T10:39:58.000Z (about 2 years ago)
- Last Synced: 2024-12-28T19:46:05.054Z (5 months ago)
- Language: CMake
- Homepage:
- Size: 169 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# qtros
## This package is for arm processor PC like Jetson Nano.
#### I have been working on ARM based PC's like Jetson Nano. I need UI based ROS package but qt_ros_plugin doesn't supports arm64(aarch64). So I made a qt_ros template to solve this out. I've tested UDP communication package, cv based camera ui package and so on. This template will allow you to have GUI expereance with ROS melodic.
This package will allow you to make QT based UI package without installing qt-ros-plugin which is not available to install on ARM PC's.
You can clone this package and use.### To make this possible, I used ~~_MultiThread_~~. I used different thread for ROS, and UI.
### I couldn't find any other solutions. If you have any other solution, let me know.
### Because this git repository contains qtros named package, you have to edit all the names if you want to create another package. So to make it easier please use my repo over here -> https://github.com/mjlee111/qt_create# Codes
## 1. src
#### mainwindow.cpp
```cpp
#include "../include/qtros/mainwindow.h"
#include "ui_mainwindow.h"using namespace std;
using namespace Qt;MainWindow::MainWindow(int argc, char** argv, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowIcon(QIcon(":/images/icon.jpg"));
ros::init(init_argc,init_argv,"qtros");
if ( ! ros::master::check() ) {
return;
}
ros::start(); // explicitly needed since our nodehandle is going out of scope.
ros::NodeHandle n;th=std::thread(&MainWindow::run,this);
return;
}MainWindow::~MainWindow()
{
if(ros::isStarted()) {
ROS_INFO("exiting");
ros::shutdown(); // explicitly needed since we use ros::start();
}
th.join();
delete ui;
}void MainWindow::run(){
ros::Rate loop_rate(33);
while ( ros::ok() ) {
ros::spinOnce();
loop_rate.sleep();
}
}
```#### main.cpp
```cpp
#include "../include/qtros/mainwindow.h"
#includeint main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w(argc, argv);
w.show();return a.exec();
}
```## 2. headers
#### mainwindow.h
```h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include
#ifndef Q_MOC_RUN
#include
#include
#include
#include
#include
#include
#include
#include
#endifnamespace Ui {
using namespace std;
using namespace Qt;
class MainWindow;
}class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
MainWindow(int argc, char** argv, QWidget *parent = 0);
virtual ~MainWindow();
bool init();
void run();Q_SIGNALS:
void rosShutdown();private:
Ui::MainWindow *ui;
int init_argc;
char** init_argv;
std::thread th;
};#endif // MAINWINDOW_H
```