Skip to content
This repository was archived by the owner on Jan 28, 2023. It is now read-only.

Commit b50bcf3

Browse files
authored
Merge pull request #60 from SSL-Roots/consai2r2_gameviewer
Add gameviewer package.
2 parents 72eeff9 + 8a12f73 commit b50bcf3

8 files changed

Lines changed: 210 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(consai2r2_gameviewer)
3+
4+
# Load ament and all dependencies required for this package
5+
find_package(ament_cmake REQUIRED)
6+
find_package(ament_cmake_python REQUIRED)
7+
8+
ament_python_install_package(${PROJECT_NAME}
9+
PACKAGE_DIR src/${PROJECT_NAME})
10+
11+
install(FILES plugin.xml
12+
DESTINATION share/${PROJECT_NAME}
13+
)
14+
15+
install(DIRECTORY resource
16+
DESTINATION share/${PROJECT_NAME}
17+
)
18+
19+
install(PROGRAMS scripts/consai2r2_gameviewer
20+
DESTINATION lib/${PROJECT_NAME}
21+
)
22+
23+
ament_package()

consai2r2_gameviewer/package.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>consai2r2_gameviewer</name>
5+
<version>0.0.0</version>
6+
<description>consai2r2_gameviewer provides a GUI plugin for displaying vision and referee messages.</description>
7+
<maintainer email="macakasit@gmail.com">akshota</maintainer>
8+
<license>MIT</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
12+
<exec_depend>ament_index_python</exec_depend>
13+
<exec_depend version_gte="0.2.19">python_qt_binding</exec_depend>
14+
<exec_depend>rclpy</exec_depend>
15+
<exec_depend>rqt_gui</exec_depend>
16+
<exec_depend>rqt_gui_py</exec_depend>
17+
<exec_depend>rqt_py_common</exec_depend>
18+
19+
<export>
20+
<!-- <architecture_independent/> -->
21+
<rqt_gui plugin="${prefix}/plugin.xml"/>
22+
<build_type>ament_cmake</build_type>
23+
</export>
24+
</package>

consai2r2_gameviewer/plugin.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<library path="src">
2+
<class name="GameViewer" type="consai2r2_gameviewer.gameviewer.GameViewer" base_class_type="rqt_gui_py::Plugin">
3+
<description>
4+
A Python GUI plugin for displaying vision and referee messages.
5+
</description>
6+
<qtgui>
7+
<group>
8+
<label>Visualization</label>
9+
<icon type="theme">folder</icon>
10+
<statustip>Plugins related to visualization.</statustip>
11+
</group>
12+
<label>CON-SAI2 R2 GameViewer</label>
13+
<icon type="theme">image-x-generic</icon>
14+
<statustip>A Python GUI plugin for displaying vision and referee messages.</statustip>
15+
</qtgui>
16+
</class>
17+
</library>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>GameViewerWidget</class>
4+
<widget class="QWidget" name="GameViewerWidget">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>400</width>
10+
<height>300</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>GameViewer</string>
15+
</property>
16+
</widget>
17+
<resources/>
18+
<connections/>
19+
</ui>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
5+
from rqt_gui.main import Main
6+
7+
main = Main()
8+
sys.exit(main.main(sys.argv, standalone='consai2r2_gameviewer.gameviewer.GameViewer'))

consai2r2_gameviewer/src/consai2r2_gameviewer/__init__.py

Whitespace-only changes.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright (c) 2019 SSL-Roots
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to deal
5+
# in the Software without restriction, including without limitation the rights
6+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
# copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
# THE SOFTWARE.
20+
21+
from qt_gui.plugin import Plugin
22+
from python_qt_binding.QtCore import QTimer
23+
24+
from consai2r2_gameviewer.gameviewer_widget import GameViewerWidget
25+
26+
27+
class GameViewer(Plugin):
28+
29+
"""
30+
consai2r2_gameviwer plugin's main class.
31+
"""
32+
33+
def __init__(self, context):
34+
"""
35+
:param context: plugin context hook to enable adding widgets as a ROS_GUI pane,
36+
''PluginContext''
37+
"""
38+
super(GameViewer, self).__init__(context)
39+
self.setObjectName('GameViewer')
40+
41+
self._context = context
42+
43+
self._widget = GameViewerWidget()
44+
if context.serial_number() > 1:
45+
self._widget.setWindowTitle(
46+
self._widget.windowTitle() + (' (%d)' % context.serial_number()))
47+
context.add_widget(self._widget)
48+
49+
self._timer = QTimer()
50+
self._timer.timeout.connect(self._widget.update)
51+
self._timer.start(16) # the argument is msec interval
52+
53+
def shutdown_plugin(self):
54+
self._timer.stop()
55+
pass
56+
57+
def save_settings(self, plugin_settings, instance_settings):
58+
pass
59+
60+
def restore_settings(self, plugin_settings, instance_settings):
61+
pass
62+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright (c) 2019 SSL-Roots
2+
#
3+
# Permission is hereby granted, free of charge, to any person obtaining a copy
4+
# of this software and associated documentation files (the "Software"), to deal
5+
# in the Software without restriction, including without limitation the rights
6+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
# copies of the Software, and to permit persons to whom the Software is
8+
# furnished to do so, subject to the following conditions:
9+
#
10+
# The above copyright notice and this permission notice shall be included in
11+
# all copies or substantial portions of the Software.
12+
#
13+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
# THE SOFTWARE.
20+
21+
import os
22+
23+
from ament_index_python.resources import get_resource
24+
25+
from python_qt_binding import loadUi
26+
from python_qt_binding.QtWidgets import QWidget
27+
from python_qt_binding.QtGui import QPainter
28+
from python_qt_binding.QtCore import Qt
29+
30+
class GameViewerWidget(QWidget):
31+
32+
"""
33+
Primary widget for the consai2r2_gameviewer plugin.
34+
"""
35+
36+
def __init__(self):
37+
super(GameViewerWidget, self).__init__()
38+
39+
pkg_name = 'consai2r2_gameviewer'
40+
_, package_path = get_resource('packages', pkg_name)
41+
ui_file = os.path.join(
42+
package_path, 'share', pkg_name, 'resource', 'gameviewer_widget.ui')
43+
loadUi(ui_file, self)
44+
45+
self.setObjectName('GameViewerWidget')
46+
47+
48+
def paintEvent(self, event):
49+
painter = QPainter(self)
50+
51+
# Hello world
52+
painter.setBrush(Qt.green)
53+
painter.setPen(Qt.black)
54+
painter.drawRect(self.rect())
55+
56+
painter.drawText(self.rect().width()*0.5, self.rect().height()*0.5, "Hello world!")
57+

0 commit comments

Comments
 (0)