mirror of
https://gitlab.com/yikestone/qt_pi.git
synced 2025-08-03 05:34:13 +05:30
synchronized and blinking recording
This commit is contained in:
parent
0203f78a65
commit
68803740dc
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
|||||||
/scripts/qt_pi/*.pyc
|
*.pyc
|
||||||
.ccls-cache
|
.ccls-cache
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
|
@ -5,6 +5,13 @@
|
|||||||
<maintainer email="rishabh_kundu@rediffmail.com">Rishabh Kundu</maintainer>
|
<maintainer email="rishabh_kundu@rediffmail.com">Rishabh Kundu</maintainer>
|
||||||
<license>MIT</license>
|
<license>MIT</license>
|
||||||
<buildtool_depend>catkin</buildtool_depend>
|
<buildtool_depend>catkin</buildtool_depend>
|
||||||
|
<exec_depend>gmapping</exec_depend>
|
||||||
|
<exec_depend>amcl</exec_depend>
|
||||||
|
<exec_depend>move_base</exec_depend>
|
||||||
|
<exec_depend>depthimage_to_laserscan</exec_depend>
|
||||||
|
<exec_depend>map_server</exec_depend>
|
||||||
|
<exec_depend>static_transform_publisher</exec_depend>
|
||||||
|
<exec_depend>teleop_twist_keyboard</exec_depend>
|
||||||
<export>
|
<export>
|
||||||
</export>
|
</export>
|
||||||
</package>
|
</package>
|
||||||
|
@ -1,62 +1,62 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.3)
|
cmake_minimum_required(VERSION 2.8.3)
|
||||||
project(qt_pi)
|
project(qt_pi)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "-fpermissive -std=c++0x")
|
set(CMAKE_CXX_FLAGS "-std=c++0x")
|
||||||
|
#-fpermissive
|
||||||
|
#ros setup
|
||||||
find_package(catkin REQUIRED COMPONENTS
|
find_package(catkin REQUIRED COMPONENTS
|
||||||
qt_build
|
qt_build
|
||||||
roscpp
|
roscpp
|
||||||
roslib
|
roslib
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(Qt5 REQUIRED COMPONENTS Core Gui OpenGL)
|
|
||||||
|
|
||||||
|
|
||||||
#set(FORMS ui/speller.ui)
|
|
||||||
set(MOC include/mapview/mapview.h)
|
|
||||||
set(HPP include/speller/speller.h include/mapview/vertex.h)
|
|
||||||
set(SRCS src/speller.cpp src/mapview.cpp )
|
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
||||||
|
|
||||||
#qt5_wrap_ui(FORMS_HPP ${FORMS})
|
|
||||||
qt5_wrap_cpp(MOC_HPP ${MOC})
|
|
||||||
qt5_add_resources(RCC resources/resources.qrc)
|
|
||||||
|
|
||||||
catkin_python_setup()
|
catkin_python_setup()
|
||||||
catkin_package(DEPENDS)
|
catkin_package(DEPENDS)
|
||||||
|
|
||||||
|
#Qt setup and MOC generation
|
||||||
|
find_package(Qt5 REQUIRED COMPONENTS Core Gui OpenGL)
|
||||||
|
set(MOC include/speller/speller.h include/mapview/mapview.h)
|
||||||
|
set(HPP include/mapview/vertex.h)
|
||||||
|
set(SRCS src/speller.cpp src/mapview.cpp )
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
qt5_wrap_cpp(MOC_HPP ${MOC})
|
||||||
|
qt5_add_resources(RCC resources/resources.qrc)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#Mcrypt library includes
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
find_path(Mcrypt_INCLUDE_DIR mcrypt.h PATHS /usr/include)
|
||||||
find_path(Mcrypt_INCLUDE_DIR mcrypt.h PATHS
|
|
||||||
/usr/include
|
|
||||||
)
|
|
||||||
|
|
||||||
set(Mcrypt_LIB_PATHS /usr/lib)
|
set(Mcrypt_LIB_PATHS /usr/lib)
|
||||||
find_library(Mcrypt_LIBS NAMES mcrypt rtfilter PATHS ${Mcrypt_LIB_PATHS})
|
find_library(Mcrypt_LIBS NAMES mcrypt rtfilter PATHS ${Mcrypt_LIB_PATHS})
|
||||||
|
include_directories(${Mcrypt_INCLUDE_DIRS})
|
||||||
|
link_directories(${Mcrypt_LIBS})
|
||||||
|
|
||||||
include_directories(include
|
#Gattlib includes
|
||||||
${catkin_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
pkg_search_module(GATTLIB REQUIRED gattlib)
|
pkg_search_module(GATTLIB REQUIRED gattlib)
|
||||||
pkg_search_module(GLIB REQUIRED glib-2.0)
|
pkg_search_module(GLIB REQUIRED glib-2.0)
|
||||||
include_directories(${GLIB_INCLUDE_DIRS})
|
include_directories(${GLIB_INCLUDE_DIRS})
|
||||||
|
|
||||||
include_directories(${Mcrypt_INCLUDE_DIRS})
|
|
||||||
link_directories(${Mcrypt_LIBS})
|
|
||||||
|
|
||||||
|
include_directories(include
|
||||||
|
${catkin_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
#ble_connect library generation
|
||||||
add_library(ble_connect include/ble_connect/ble_connect.h src/ble_connect.c)
|
add_library(ble_connect include/ble_connect/ble_connect.h src/ble_connect.c)
|
||||||
|
|
||||||
target_link_libraries(ble_connect ${GATTLIB_LIBRARIES} ${GATTLIB_LDFLAGS} ${GLIB_LDFLAGS} pthread ${Mcrypt_LIBS})
|
target_link_libraries(ble_connect ${GATTLIB_LIBRARIES} ${GATTLIB_LDFLAGS} ${GLIB_LDFLAGS} pthread ${Mcrypt_LIBS})
|
||||||
|
|
||||||
|
#ble_connect_test executable generation
|
||||||
add_executable(ble_connect_test tests/ble_test.cpp)
|
add_executable(ble_connect_test tests/ble_test.cpp)
|
||||||
target_link_libraries(ble_connect_test ble_connect)
|
target_link_libraries(ble_connect_test ble_connect)
|
||||||
|
|
||||||
|
|
||||||
|
#speller library generation
|
||||||
add_library(speller ${SRCS} ${FORMS_HPP} ${MOC_HPP} ${RCC} ${HPP})
|
add_library(speller ${SRCS} ${FORMS_HPP} ${MOC_HPP} ${RCC} ${HPP})
|
||||||
target_link_libraries(speller Qt5::Widgets Qt5::Core Qt5::OpenGL Qt5::Gui ${catkin_LIBRARIES})
|
target_link_libraries(speller Qt5::Widgets Qt5::Core Qt5::OpenGL Qt5::Gui ${catkin_LIBRARIES} ble_connect)
|
||||||
|
|
||||||
|
#main executable generation
|
||||||
add_executable(speller_ui src/main.cpp)
|
add_executable(speller_ui src/main.cpp)
|
||||||
target_link_libraries(speller_ui speller)
|
target_link_libraries(speller_ui speller)
|
||||||
|
@ -14,7 +14,7 @@ enum Channels { AF3 = 0, T7 = 1, Pz = 2, T8 = 3, AF4 = 4 };
|
|||||||
struct insight_data {
|
struct insight_data {
|
||||||
double uV[5];
|
double uV[5];
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
} insight_data;
|
};
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,29 +21,38 @@ class MapView : public QOpenGLWindow, protected QOpenGLFunctions_3_1 {
|
|||||||
public:
|
public:
|
||||||
explicit MapView(QWidget *parent = 0);
|
explicit MapView(QWidget *parent = 0);
|
||||||
~MapView();
|
~MapView();
|
||||||
|
|
||||||
void start_blinking();
|
void start_blinking();
|
||||||
void stop_blinking();
|
void stop_blinking();
|
||||||
volatile int sleep_control = 1;
|
void toggle_blinking();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GLsizei count;
|
GLsizei count;
|
||||||
GLint startingElements[4] = {0, 4, 8, 12};
|
GLint startingElements[4] = {0, 4, 8, 12};
|
||||||
GLsizei counts[4] = {4, 4, 4, 4};
|
GLsizei counts[4] = {4, 4, 4, 4};
|
||||||
|
|
||||||
void initializeGL() override;
|
void initializeGL() override;
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
void resizeGL(int, int) override;
|
void resizeGL(int, int) override;
|
||||||
void teardownGL();
|
void teardownGL();
|
||||||
void printContextInformation();
|
void printContextInformation();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void update_GUI();
|
void update_GUI();
|
||||||
|
void keyPress(QKeyEvent *key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QOpenGLBuffer m_vertex;
|
QOpenGLBuffer m_vertex;
|
||||||
QOpenGLVertexArrayObject m_object;
|
QOpenGLVertexArrayObject m_object;
|
||||||
QOpenGLShaderProgram *m_program;
|
QOpenGLShaderProgram *m_program;
|
||||||
void run();
|
|
||||||
|
volatile int sleep_control = 1;
|
||||||
|
volatile int blinking;
|
||||||
|
|
||||||
std::thread *t;
|
std::thread *t;
|
||||||
int blinking;
|
|
||||||
|
void run();
|
||||||
|
void keyPressEvent(QKeyEvent *key) override;
|
||||||
// QTimer *t1;
|
// QTimer *t1;
|
||||||
// QTimer *t2;
|
// QTimer *t2;
|
||||||
// QTimer *t3;
|
// QTimer *t3;
|
||||||
|
@ -1,18 +1,34 @@
|
|||||||
#ifndef SPELLER
|
#ifndef SPELLER
|
||||||
#define SPELLER
|
#define SPELLER
|
||||||
|
|
||||||
#include <mapview/mapview.h>
|
#include "ble_connect/ble_connect.h"
|
||||||
|
#include "mapview/mapview.h"
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QThread>
|
||||||
|
#include <geometry_msgs/Point.h>
|
||||||
|
#include <geometry_msgs/Pose.h>
|
||||||
|
#include <geometry_msgs/PoseStamped.h>
|
||||||
|
#include <geometry_msgs/Quaternion.h>
|
||||||
|
#include <map>
|
||||||
#include <ros/ros.h>
|
#include <ros/ros.h>
|
||||||
|
|
||||||
class Speller {
|
class Speller : public QThread {
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Speller(ros::NodeHandle _nh);
|
explicit Speller(int argc, char **argv);
|
||||||
~Speller();
|
~Speller();
|
||||||
|
const std::map<float, int> frequency = {
|
||||||
|
{4.286f, 14}, {5.0f, 12}, {6.0f, 10}, {7.5f, 8}};
|
||||||
MapView *window;
|
MapView *window;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ros::NodeHandle nh;
|
int argc;
|
||||||
|
char **argv;
|
||||||
|
void run() override;
|
||||||
|
private slots:
|
||||||
|
void keyEvent(QKeyEvent *key);
|
||||||
|
|
||||||
|
private:
|
||||||
|
volatile int spelling;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
<build_depend>roslib</build_depend>
|
<build_depend>roslib</build_depend>
|
||||||
|
|
||||||
<exec_depend>rospy</exec_depend>
|
<exec_depend>rospy</exec_depend>
|
||||||
<exec_depend>std_msgs</exec_depend>
|
|
||||||
<exec_depend>geometry_msgs</exec_depend>
|
<exec_depend>geometry_msgs</exec_depend>
|
||||||
<exec_depend>nav_msgs</exec_depend>
|
<exec_depend>nav_msgs</exec_depend>
|
||||||
<exec_depend>tf</exec_depend>
|
<exec_depend>tf</exec_depend>
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
#include <QSurfaceFormat>
|
#include <QSurfaceFormat>
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
QGuiApplication app(argc, argv);
|
QGuiApplication app(argc, argv);
|
||||||
ros::init(argc, argv, "speller");
|
|
||||||
ros::NodeHandle nh;
|
|
||||||
QSurfaceFormat format;
|
QSurfaceFormat format;
|
||||||
format.setSwapInterval(1);
|
format.setSwapInterval(1);
|
||||||
format.setRenderableType(QSurfaceFormat::OpenGL);
|
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||||
@ -13,11 +13,10 @@ int main(int argc, char *argv[]) {
|
|||||||
format.setVersion(3, 3);
|
format.setVersion(3, 3);
|
||||||
|
|
||||||
// Set the window up
|
// Set the window up
|
||||||
Speller spell(nh);
|
Speller spell(argc, argv);
|
||||||
|
|
||||||
spell.window->setFormat(format);
|
spell.window->setFormat(format);
|
||||||
// spell.window->resize(QSize(800, 600));
|
|
||||||
spell.window->show();
|
spell.window->show();
|
||||||
|
// spell.start();
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
MapView::MapView(QWidget *parent) {
|
MapView::MapView(QWidget *parent) {
|
||||||
connect(this, SIGNAL(update_GUI()), this, SLOT(update()));
|
connect(this, SIGNAL(update_GUI()), this, SLOT(update()));
|
||||||
|
|
||||||
blinking = 0;
|
blinking = 0;
|
||||||
count = 4;
|
count = 4;
|
||||||
}
|
}
|
||||||
@ -22,6 +23,13 @@ void MapView::stop_blinking() {
|
|||||||
free(t);
|
free(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::toggle_blinking() {
|
||||||
|
if (blinking)
|
||||||
|
stop_blinking();
|
||||||
|
else
|
||||||
|
start_blinking();
|
||||||
|
}
|
||||||
|
|
||||||
void MapView::start_blinking() {
|
void MapView::start_blinking() {
|
||||||
if (blinking)
|
if (blinking)
|
||||||
return;
|
return;
|
||||||
@ -64,17 +72,6 @@ void MapView::run() {
|
|||||||
std::chrono::high_resolution_clock::now() - time)
|
std::chrono::high_resolution_clock::now() - time)
|
||||||
.count());
|
.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
// while (blinking) {
|
|
||||||
// emit(update_GUI());
|
|
||||||
// printf("WOah\n");
|
|
||||||
//
|
|
||||||
// count = 4;
|
|
||||||
// sleep(1);
|
|
||||||
// emit(update_GUI());
|
|
||||||
// count = 0;
|
|
||||||
// sleep(1);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Vertex sg_vertexes[] = {
|
static const Vertex sg_vertexes[] = {
|
||||||
@ -98,25 +95,6 @@ static const Vertex sg_vertexes[] = {
|
|||||||
Vertex(QVector3D(0.45f, -0.45f, 1.0f), QVector3D(0.75f, 0.75f, 0.75f)),
|
Vertex(QVector3D(0.45f, -0.45f, 1.0f), QVector3D(0.75f, 0.75f, 0.75f)),
|
||||||
Vertex(QVector3D(0.55f, -0.45f, 1.0f), QVector3D(0.75f, 0.75f, 0.75f)),
|
Vertex(QVector3D(0.55f, -0.45f, 1.0f), QVector3D(0.75f, 0.75f, 0.75f)),
|
||||||
|
|
||||||
// Vertex(QVector3D(-0.75f, 0.75f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(-0.25f, 0.75f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(-0.25f, 0.25f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(-0.75f, 0.25f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
//
|
|
||||||
// Vertex(QVector3D(-0.75f, -0.75f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(-0.25f, -0.75f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(-0.25f, -0.25f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(-0.75f, -0.25f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
//
|
|
||||||
// Vertex(QVector3D(0.75f, 0.75f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(0.25f, 0.75f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(0.25f, 0.25f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(0.75f, 0.25f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
//
|
|
||||||
// Vertex(QVector3D(0.75f, -0.75f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(0.25f, -0.75f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(0.25f, -0.25f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f)),
|
|
||||||
// Vertex(QVector3D(0.75f, -0.25f, 1.0f), QVector3D(0.0f, 0.0f, 0.0f))
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void MapView::initializeGL() {
|
void MapView::initializeGL() {
|
||||||
@ -208,3 +186,5 @@ void MapView::teardownGL() {
|
|||||||
m_vertex.destroy();
|
m_vertex.destroy();
|
||||||
delete m_program;
|
delete m_program;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::keyPressEvent(QKeyEvent *key) { emit(keyPress(key)); }
|
||||||
|
@ -1,5 +1,73 @@
|
|||||||
#include "speller/speller.h"
|
#include "speller/speller.h"
|
||||||
|
|
||||||
Speller::Speller(ros::NodeHandle _nh) : nh(_nh) { window = new MapView(); }
|
Speller::Speller(int ar, char **av) {
|
||||||
|
argc = ar;
|
||||||
|
argv = av;
|
||||||
|
spelling = 0;
|
||||||
|
window = new MapView();
|
||||||
|
connect(window, SIGNAL(keyPress(QKeyEvent *)), this,
|
||||||
|
SLOT(keyEvent(QKeyEvent *)));
|
||||||
|
|
||||||
Speller::~Speller() {}
|
const char *a = "EF:BD:39:4E:08:49";
|
||||||
|
const char *b = "81072f41-9f3d-11e3-a9dc-0002a5d5c51b";
|
||||||
|
insight_init(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
Speller::~Speller() {
|
||||||
|
insight_stop_notif();
|
||||||
|
insight_destroy();
|
||||||
|
this->terminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Speller::run() {
|
||||||
|
|
||||||
|
const std::string node_name = "speller";
|
||||||
|
|
||||||
|
ros::init(argc, argv, node_name);
|
||||||
|
ros::NodeHandle nh;
|
||||||
|
ros::Publisher pub =
|
||||||
|
nh.advertise<geometry_msgs::PoseStamped>("/move_base_simple/goal", 1);
|
||||||
|
geometry_msgs::PoseStamped msg;
|
||||||
|
geometry_msgs::Pose pose;
|
||||||
|
geometry_msgs::Point point;
|
||||||
|
geometry_msgs::Quaternion quat;
|
||||||
|
pose.position = point;
|
||||||
|
pose.orientation = quat;
|
||||||
|
msg.pose = pose;
|
||||||
|
point.x = 0;
|
||||||
|
point.y = 0;
|
||||||
|
point.z = 0;
|
||||||
|
quat.w = 1;
|
||||||
|
quat.x = 0;
|
||||||
|
quat.y = 0;
|
||||||
|
quat.z = 0;
|
||||||
|
|
||||||
|
while (ros::ok()) {
|
||||||
|
while (spelling) {
|
||||||
|
int len = 1000;
|
||||||
|
struct insight_data *buf =
|
||||||
|
(struct insight_data *)malloc(sizeof(struct insight_data) * len);
|
||||||
|
|
||||||
|
window->start_blinking();
|
||||||
|
insight_write_to_buffer(len, buf);
|
||||||
|
|
||||||
|
while (insight_buffer_status() == 1)
|
||||||
|
sleep(0);
|
||||||
|
|
||||||
|
window->stop_blinking();
|
||||||
|
|
||||||
|
// TODO-Send data for classification
|
||||||
|
// int a; if((a = classify(len, buf))) window->zoom(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Speller::keyEvent(QKeyEvent *e) {
|
||||||
|
if (e->key() == Qt::Key_Space) {
|
||||||
|
if (!spelling)
|
||||||
|
insight_start_notif();
|
||||||
|
else
|
||||||
|
insight_stop_notif();
|
||||||
|
spelling = !spelling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user