Skip to content

Commit dfc8718

Browse files
committed
ros and qt
0 parents  commit dfc8718

File tree

354 files changed

+26585
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

354 files changed

+26585
-0
lines changed

code02-msg/CMakeLists.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
##############################################################################
2+
# CMake
3+
##############################################################################
4+
5+
cmake_minimum_required(VERSION 2.8.0)
6+
project(msg)
7+
8+
##############################################################################
9+
# Catkin
10+
##############################################################################
11+
12+
# qt_build provides the qt cmake glue, roscpp the comms for a default talker
13+
find_package(catkin REQUIRED COMPONENTS qt_build roscpp)
14+
include_directories(${catkin_INCLUDE_DIRS})
15+
# Use this to define what the package will export (e.g. libs, headers).
16+
# Since the default here is to produce only a binary, we don't worry about
17+
# exporting anything.
18+
catkin_package()
19+
20+
##############################################################################
21+
# Qt Environment
22+
##############################################################################
23+
24+
# this comes from qt_build's qt-ros.cmake which is automatically
25+
# included via the dependency call in package.xml
26+
rosbuild_prepare_qt4(QtCore QtGui) # Add the appropriate components to the component list here
27+
28+
##############################################################################
29+
# Sections
30+
##############################################################################
31+
32+
file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
33+
file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
34+
file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS include/msg/*.hpp)
35+
36+
QT4_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
37+
QT4_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
38+
QT4_WRAP_CPP(QT_MOC_HPP ${QT_MOC})
39+
40+
##############################################################################
41+
# Sources
42+
##############################################################################
43+
44+
file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS src/*.cpp)
45+
46+
##############################################################################
47+
# Binaries
48+
##############################################################################
49+
50+
add_executable(msg ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
51+
target_link_libraries(msg ${QT_LIBRARIES} ${catkin_LIBRARIES})
52+
install(TARGETS msg RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
53+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* @file /include/msg/main_window.hpp
3+
*
4+
* @brief Qt based gui for msg.
5+
*
6+
* @date November 2010
7+
**/
8+
#ifndef msg_MAIN_WINDOW_H
9+
#define msg_MAIN_WINDOW_H
10+
11+
/*****************************************************************************
12+
** Includes
13+
*****************************************************************************/
14+
15+
#include <QtGui/QMainWindow>
16+
#include "ui_main_window.h"
17+
#include "qnode.hpp"
18+
19+
/*****************************************************************************
20+
** Namespace
21+
*****************************************************************************/
22+
23+
namespace msg {
24+
25+
/*****************************************************************************
26+
** Interface [MainWindow]
27+
*****************************************************************************/
28+
/**
29+
* @brief Qt central, all operations relating to the view part here.
30+
*/
31+
class MainWindow : public QMainWindow {
32+
Q_OBJECT
33+
34+
public:
35+
MainWindow(int argc, char** argv, QWidget *parent = 0);
36+
~MainWindow();
37+
38+
void ReadSettings(); // Load up qt program settings at startup
39+
void WriteSettings(); // Save qt program settings when closing
40+
41+
void closeEvent(QCloseEvent *event); // Overloaded function
42+
void showNoMasterMessage();
43+
44+
public Q_SLOTS:
45+
/******************************************
46+
** Auto-connections (connectSlotsByName())
47+
*******************************************/
48+
void on_actionAbout_triggered();
49+
void on_button_connect_clicked(bool check );
50+
void on_checkbox_use_environment_stateChanged(int state);
51+
52+
/******************************************
53+
** Manual connections
54+
*******************************************/
55+
void updateLoggingView(); // no idea why this can't connect automatically
56+
void updateLoggingView_sub(); //add
57+
58+
private:
59+
Ui::MainWindowDesign ui;
60+
QNode qnode;
61+
};
62+
63+
} // namespace msg
64+
65+
#endif // msg_MAIN_WINDOW_H

code02-msg/include/msg/qnode.hpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* @file /include/msg/qnode.hpp
3+
*
4+
* @brief Communications central!
5+
*
6+
* @date February 2011
7+
**/
8+
/*****************************************************************************
9+
** Ifdefs
10+
*****************************************************************************/
11+
12+
#ifndef msg_QNODE_HPP_
13+
#define msg_QNODE_HPP_
14+
15+
/*****************************************************************************
16+
** Includes
17+
*****************************************************************************/
18+
19+
// To workaround boost/qt4 problems that won't be bugfixed. Refer to
20+
// https://bugreports.qt.io/browse/QTBUG-22829
21+
#ifndef Q_MOC_RUN
22+
#include <ros/ros.h>
23+
#endif
24+
#include <string>
25+
#include <QThread>
26+
#include <QStringListModel>
27+
#include <std_msgs/String.h> //add
28+
29+
/*****************************************************************************
30+
** Namespaces
31+
*****************************************************************************/
32+
33+
namespace msg {
34+
35+
/*****************************************************************************
36+
** Class
37+
*****************************************************************************/
38+
39+
class QNode : public QThread {
40+
Q_OBJECT
41+
public:
42+
QNode(int argc, char** argv );
43+
virtual ~QNode();
44+
bool init();
45+
bool init(const std::string &master_url, const std::string &host_url);
46+
void run();
47+
48+
/*********************
49+
** Logging
50+
**********************/
51+
enum LogLevel {
52+
Debug,
53+
Info,
54+
Warn,
55+
Error,
56+
Fatal
57+
};
58+
59+
QStringListModel* loggingModel() { return &logging_model; }
60+
void log( const LogLevel &level, const std::string &msg);
61+
QStringListModel* loggingModel_sub() { return &logging_model_sub; } //add
62+
void log_sub( const LogLevel &level, const std::string &msg); //add
63+
void Callback(const std_msgs::StringConstPtr &submsg); //add
64+
65+
Q_SIGNALS:
66+
void loggingUpdated();
67+
void rosShutdown();
68+
void loggingUpdated_sub(); //add
69+
70+
private:
71+
int init_argc;
72+
char** init_argv;
73+
ros::Publisher chatter_publisher;
74+
QStringListModel logging_model;
75+
ros::Subscriber chatter_subscriber; //add
76+
QStringListModel logging_model_sub; //add
77+
};
78+
79+
} // namespace msg
80+
81+
#endif /* msg_QNODE_HPP_ */

code02-msg/mainpage.dox

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
\mainpage
3+
\htmlinclude manifest.html
4+
5+
\b msg is ...
6+
7+
<!--
8+
Provide an overview of your package.
9+
-->
10+
11+
12+
\section codeapi Code API
13+
14+
<!--
15+
Provide links to specific auto-generated API documentation within your
16+
package that is of particular interest to a reader. Doxygen will
17+
document pretty much every part of your code, so do your best here to
18+
point the reader to the actual API.
19+
20+
If your codebase is fairly large or has different sets of APIs, you
21+
should use the doxygen 'group' tag to keep these APIs together. For
22+
example, the roscpp documentation has 'libros' group.
23+
-->
24+
25+
26+
*/

code02-msg/package.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<package>
3+
<name>msg</name>
4+
<version>0.1.0</version>
5+
<description>
6+
7+
msg
8+
9+
</description>
10+
<maintainer email="[email protected]">dwy</maintainer>
11+
<author>dwy</author>
12+
<license>BSD</license>
13+
<!-- <url type="bugtracker">https://github.com/stonier/qt_ros/issues</url> -->
14+
<!-- <url type="repository">https://github.com/stonier/qt_ros</url> -->
15+
16+
<buildtool_depend>catkin</buildtool_depend>
17+
<build_depend>qt_build</build_depend>
18+
<build_depend>roscpp</build_depend>
19+
<build_depend>libqt4-dev</build_depend>
20+
<run_depend>qt_build</run_depend>
21+
<run_depend>roscpp</run_depend>
22+
<run_depend>libqt4-dev</run_depend>
23+
24+
25+
</package>

code02-msg/resources/images.qrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<RCC>
2+
<qresource prefix="/" >
3+
<file>images/icon.png</file>
4+
</qresource>
5+
</RCC>

code02-msg/resources/images/icon.png

36.3 KB
Loading

code02-msg/src/main.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @file /src/main.cpp
3+
*
4+
* @brief Qt based gui.
5+
*
6+
* @date November 2010
7+
**/
8+
/*****************************************************************************
9+
** Includes
10+
*****************************************************************************/
11+
12+
#include <QtGui>
13+
#include <QApplication>
14+
#include "../include/msg/main_window.hpp"
15+
16+
/*****************************************************************************
17+
** Main
18+
*****************************************************************************/
19+
20+
int main(int argc, char **argv) {
21+
22+
/*********************
23+
** Qt
24+
**********************/
25+
QApplication app(argc, argv);
26+
msg::MainWindow w(argc,argv);
27+
w.show();
28+
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
29+
int result = app.exec();
30+
31+
return result;
32+
}

0 commit comments

Comments
 (0)