mirror of
https://gitlab.com/yikestone/qt_pi.git
synced 2025-08-02 21:24:12 +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
|
||||
compile_commands.json
|
||||
|
@ -5,6 +5,13 @@
|
||||
<maintainer email="rishabh_kundu@rediffmail.com">Rishabh Kundu</maintainer>
|
||||
<license>MIT</license>
|
||||
<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>
|
||||
</package>
|
||||
|
@ -1,62 +1,62 @@
|
||||
cmake_minimum_required(VERSION 2.8.3)
|
||||
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
|
||||
qt_build
|
||||
roscpp
|
||||
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_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_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)
|
||||
find_library(Mcrypt_LIBS NAMES mcrypt rtfilter PATHS ${Mcrypt_LIB_PATHS})
|
||||
include_directories(${Mcrypt_INCLUDE_DIRS})
|
||||
link_directories(${Mcrypt_LIBS})
|
||||
|
||||
include_directories(include
|
||||
${catkin_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
#Gattlib includes
|
||||
pkg_search_module(GATTLIB REQUIRED gattlib)
|
||||
pkg_search_module(GLIB REQUIRED glib-2.0)
|
||||
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)
|
||||
|
||||
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)
|
||||
target_link_libraries(ble_connect_test ble_connect)
|
||||
|
||||
|
||||
|
||||
#speller library generation
|
||||
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)
|
||||
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 {
|
||||
double uV[5];
|
||||
struct timespec ts;
|
||||
} insight_data;
|
||||
};
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -21,29 +21,38 @@ class MapView : public QOpenGLWindow, protected QOpenGLFunctions_3_1 {
|
||||
public:
|
||||
explicit MapView(QWidget *parent = 0);
|
||||
~MapView();
|
||||
|
||||
void start_blinking();
|
||||
void stop_blinking();
|
||||
volatile int sleep_control = 1;
|
||||
void toggle_blinking();
|
||||
|
||||
protected:
|
||||
GLsizei count;
|
||||
GLint startingElements[4] = {0, 4, 8, 12};
|
||||
GLsizei counts[4] = {4, 4, 4, 4};
|
||||
|
||||
void initializeGL() override;
|
||||
void paintGL() override;
|
||||
void resizeGL(int, int) override;
|
||||
void teardownGL();
|
||||
void printContextInformation();
|
||||
|
||||
signals:
|
||||
void update_GUI();
|
||||
void keyPress(QKeyEvent *key);
|
||||
|
||||
private:
|
||||
QOpenGLBuffer m_vertex;
|
||||
QOpenGLVertexArrayObject m_object;
|
||||
QOpenGLShaderProgram *m_program;
|
||||
void run();
|
||||
|
||||
volatile int sleep_control = 1;
|
||||
volatile int blinking;
|
||||
|
||||
std::thread *t;
|
||||
int blinking;
|
||||
|
||||
void run();
|
||||
void keyPressEvent(QKeyEvent *key) override;
|
||||
// QTimer *t1;
|
||||
// QTimer *t2;
|
||||
// QTimer *t3;
|
||||
|
@ -1,18 +1,34 @@
|
||||
#ifndef 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>
|
||||
|
||||
class Speller {
|
||||
|
||||
class Speller : public QThread {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Speller(ros::NodeHandle _nh);
|
||||
explicit Speller(int argc, char **argv);
|
||||
~Speller();
|
||||
|
||||
const std::map<float, int> frequency = {
|
||||
{4.286f, 14}, {5.0f, 12}, {6.0f, 10}, {7.5f, 8}};
|
||||
MapView *window;
|
||||
|
||||
private:
|
||||
ros::NodeHandle nh;
|
||||
int argc;
|
||||
char **argv;
|
||||
void run() override;
|
||||
private slots:
|
||||
void keyEvent(QKeyEvent *key);
|
||||
|
||||
private:
|
||||
volatile int spelling;
|
||||
};
|
||||
#endif
|
||||
|
@ -10,7 +10,6 @@
|
||||
<build_depend>roslib</build_depend>
|
||||
|
||||
<exec_depend>rospy</exec_depend>
|
||||
<exec_depend>std_msgs</exec_depend>
|
||||
<exec_depend>geometry_msgs</exec_depend>
|
||||
<exec_depend>nav_msgs</exec_depend>
|
||||
<exec_depend>tf</exec_depend>
|
||||
|
@ -3,9 +3,9 @@
|
||||
#include <QSurfaceFormat>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
ros::init(argc, argv, "speller");
|
||||
ros::NodeHandle nh;
|
||||
|
||||
QSurfaceFormat format;
|
||||
format.setSwapInterval(1);
|
||||
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
@ -13,11 +13,10 @@ int main(int argc, char *argv[]) {
|
||||
format.setVersion(3, 3);
|
||||
|
||||
// Set the window up
|
||||
Speller spell(nh);
|
||||
|
||||
Speller spell(argc, argv);
|
||||
spell.window->setFormat(format);
|
||||
// spell.window->resize(QSize(800, 600));
|
||||
spell.window->show();
|
||||
// spell.start();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
MapView::MapView(QWidget *parent) {
|
||||
connect(this, SIGNAL(update_GUI()), this, SLOT(update()));
|
||||
|
||||
blinking = 0;
|
||||
count = 4;
|
||||
}
|
||||
@ -22,6 +23,13 @@ void MapView::stop_blinking() {
|
||||
free(t);
|
||||
}
|
||||
|
||||
void MapView::toggle_blinking() {
|
||||
if (blinking)
|
||||
stop_blinking();
|
||||
else
|
||||
start_blinking();
|
||||
}
|
||||
|
||||
void MapView::start_blinking() {
|
||||
if (blinking)
|
||||
return;
|
||||
@ -64,17 +72,6 @@ void MapView::run() {
|
||||
std::chrono::high_resolution_clock::now() - time)
|
||||
.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[] = {
|
||||
@ -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.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() {
|
||||
@ -208,3 +186,5 @@ void MapView::teardownGL() {
|
||||
m_vertex.destroy();
|
||||
delete m_program;
|
||||
}
|
||||
|
||||
void MapView::keyPressEvent(QKeyEvent *key) { emit(keyPress(key)); }
|
||||
|
@ -1,5 +1,73 @@
|
||||
#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