Skip to content

Commit

Permalink
ros and qt
Browse files Browse the repository at this point in the history
  • Loading branch information
ncnynl committed Apr 30, 2019
0 parents commit dfc8718
Show file tree
Hide file tree
Showing 354 changed files with 26,585 additions and 0 deletions.
53 changes: 53 additions & 0 deletions code02-msg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
##############################################################################
# CMake
##############################################################################

cmake_minimum_required(VERSION 2.8.0)
project(msg)

##############################################################################
# Catkin
##############################################################################

# qt_build provides the qt cmake glue, roscpp the comms for a default talker
find_package(catkin REQUIRED COMPONENTS qt_build roscpp)
include_directories(${catkin_INCLUDE_DIRS})
# Use this to define what the package will export (e.g. libs, headers).
# Since the default here is to produce only a binary, we don't worry about
# exporting anything.
catkin_package()

##############################################################################
# Qt Environment
##############################################################################

# this comes from qt_build's qt-ros.cmake which is automatically
# included via the dependency call in package.xml
rosbuild_prepare_qt4(QtCore QtGui) # Add the appropriate components to the component list here

##############################################################################
# Sections
##############################################################################

file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/msg/*.hpp)

QT4_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
QT4_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
QT4_WRAP_CPP(QT_MOC_HPP ${QT_MOC})

##############################################################################
# Sources
##############################################################################

file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)

##############################################################################
# Binaries
##############################################################################

add_executable(msg ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
target_link_libraries(msg ${QT_LIBRARIES} ${catkin_LIBRARIES})
install(TARGETS msg RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

65 changes: 65 additions & 0 deletions code02-msg/include/msg/main_window.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* @file /include/msg/main_window.hpp
*
* @brief Qt based gui for msg.
*
* @date November 2010
**/
#ifndef msg_MAIN_WINDOW_H
#define msg_MAIN_WINDOW_H

/*****************************************************************************
** Includes
*****************************************************************************/

#include <QtGui/QMainWindow>
#include "ui_main_window.h"
#include "qnode.hpp"

/*****************************************************************************
** Namespace
*****************************************************************************/

namespace msg {

/*****************************************************************************
** Interface [MainWindow]
*****************************************************************************/
/**
* @brief Qt central, all operations relating to the view part here.
*/
class MainWindow : public QMainWindow {
Q_OBJECT

public:
MainWindow(int argc, char** argv, QWidget *parent = 0);
~MainWindow();

void ReadSettings(); // Load up qt program settings at startup
void WriteSettings(); // Save qt program settings when closing

void closeEvent(QCloseEvent *event); // Overloaded function
void showNoMasterMessage();

public Q_SLOTS:
/******************************************
** Auto-connections (connectSlotsByName())
*******************************************/
void on_actionAbout_triggered();
void on_button_connect_clicked(bool check );
void on_checkbox_use_environment_stateChanged(int state);

/******************************************
** Manual connections
*******************************************/
void updateLoggingView(); // no idea why this can't connect automatically
void updateLoggingView_sub(); //add

private:
Ui::MainWindowDesign ui;
QNode qnode;
};

} // namespace msg

#endif // msg_MAIN_WINDOW_H
81 changes: 81 additions & 0 deletions code02-msg/include/msg/qnode.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* @file /include/msg/qnode.hpp
*
* @brief Communications central!
*
* @date February 2011
**/
/*****************************************************************************
** Ifdefs
*****************************************************************************/

#ifndef msg_QNODE_HPP_
#define msg_QNODE_HPP_

/*****************************************************************************
** Includes
*****************************************************************************/

// To workaround boost/qt4 problems that won't be bugfixed. Refer to
// https://bugreports.qt.io/browse/QTBUG-22829
#ifndef Q_MOC_RUN
#include <ros/ros.h>
#endif
#include <string>
#include <QThread>
#include <QStringListModel>
#include <std_msgs/String.h> //add

/*****************************************************************************
** Namespaces
*****************************************************************************/

namespace msg {

/*****************************************************************************
** Class
*****************************************************************************/

class QNode : public QThread {
Q_OBJECT
public:
QNode(int argc, char** argv );
virtual ~QNode();
bool init();
bool init(const std::string &master_url, const std::string &host_url);
void run();

/*********************
** Logging
**********************/
enum LogLevel {
Debug,
Info,
Warn,
Error,
Fatal
};

QStringListModel* loggingModel() { return &logging_model; }
void log( const LogLevel &level, const std::string &msg);
QStringListModel* loggingModel_sub() { return &logging_model_sub; } //add
void log_sub( const LogLevel &level, const std::string &msg); //add
void Callback(const std_msgs::StringConstPtr &submsg); //add

Q_SIGNALS:
void loggingUpdated();
void rosShutdown();
void loggingUpdated_sub(); //add

private:
int init_argc;
char** init_argv;
ros::Publisher chatter_publisher;
QStringListModel logging_model;
ros::Subscriber chatter_subscriber; //add
QStringListModel logging_model_sub; //add
};

} // namespace msg

#endif /* msg_QNODE_HPP_ */
26 changes: 26 additions & 0 deletions code02-msg/mainpage.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
\mainpage
\htmlinclude manifest.html

\b msg is ...

<!--
Provide an overview of your package.
-->


\section codeapi Code API

<!--
Provide links to specific auto-generated API documentation within your
package that is of particular interest to a reader. Doxygen will
document pretty much every part of your code, so do your best here to
point the reader to the actual API.

If your codebase is fairly large or has different sets of APIs, you
should use the doxygen 'group' tag to keep these APIs together. For
example, the roscpp documentation has 'libros' group.
-->


*/
25 changes: 25 additions & 0 deletions code02-msg/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<package>
<name>msg</name>
<version>0.1.0</version>
<description>

msg

</description>
<maintainer email="[email protected]">dwy</maintainer>
<author>dwy</author>
<license>BSD</license>
<!-- <url type="bugtracker">https://github.com/stonier/qt_ros/issues</url> -->
<!-- <url type="repository">https://github.com/stonier/qt_ros</url> -->

<buildtool_depend>catkin</buildtool_depend>
<build_depend>qt_build</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>libqt4-dev</build_depend>
<run_depend>qt_build</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>libqt4-dev</run_depend>


</package>
5 changes: 5 additions & 0 deletions code02-msg/resources/images.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/" >
<file>images/icon.png</file>
</qresource>
</RCC>
Binary file added code02-msg/resources/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions code02-msg/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @file /src/main.cpp
*
* @brief Qt based gui.
*
* @date November 2010
**/
/*****************************************************************************
** Includes
*****************************************************************************/

#include <QtGui>
#include <QApplication>
#include "../include/msg/main_window.hpp"

/*****************************************************************************
** Main
*****************************************************************************/

int main(int argc, char **argv) {

/*********************
** Qt
**********************/
QApplication app(argc, argv);
msg::MainWindow w(argc,argv);
w.show();
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
int result = app.exec();

return result;
}
Loading

0 comments on commit dfc8718

Please sign in to comment.