Skip to content
This repository has been archived by the owner on Feb 21, 2021. It is now read-only.

Commit

Permalink
[issue #707] Added Logo and JderobotComm to basic_component_py
Browse files Browse the repository at this point in the history
  • Loading branch information
aitormf committed Mar 10, 2017
1 parent 7f41977 commit 9ea238d
Show file tree
Hide file tree
Showing 11 changed files with 216 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/python2
# -*- coding: utf-8 -*-
#
# Copyright (C) 1997-2016 JdeRobot Developers Team
Expand All @@ -21,8 +21,7 @@

import sys

from parallelIce.cameraClient import CameraClient
from parallelIce.motors import Motors
import jderobotComm as comm
from gui.threadGUI import ThreadGUI
from gui.GUI import MainWindow
from PyQt5.QtWidgets import QApplication
Expand All @@ -34,8 +33,13 @@

if __name__ == '__main__':
ic = EasyIce.initialize(sys.argv)
camera = CameraClient(ic,"basic_component.Camera",True)
motors = Motors(ic,"basic_component.Motors")

#starting comm
ic, node = comm.init(ic)


camera = comm.getCameraClient(ic,"basic_component.Camera")
motors = comm.getMotorsClient(ic,"basic_component.Motors")

app = QApplication(sys.argv)
frame = MainWindow()
Expand Down
18 changes: 13 additions & 5 deletions src/tools/basic_component_py/basic_component_py.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
basic_component.Camera.Proxy=cam_turtlebot_right:default -h localhost -p 8994
basic_component.Camera.Format=RGB8

############ Motors #######################
# 0 -> Deactivate, 1 -> Ice , 2 -> ROS
basic_component.Motors.Server=1
basic_component.Motors.Proxy=Motors:default -h localhost -p 8999
basic_component.Motors.Topic=/cmd_vel_mux/input/teleop
basic_component.Motors.Name=FolowLineMotors

#basic_component.Motors.maxV = 5
#basic_component.Motors.maxW = 0.5

############ Camera #######################
# 0 -> Deactivate, 1 -> Ice , 2 -> ROS
basic_component.Camera.Server=1
basic_component.Camera.Proxy=cam_turtlebot_right:default -h localhost -p 8994
basic_component.Camera.Format=RGB8
basic_component.Camera.Topic=/camera/rgb/image_raw
basic_component.Camera.Name=basic_component_pyCamera

9 changes: 9 additions & 0 deletions src/tools/basic_component_py/generateGUI
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
cd resources
pyrcc5 resources.qrc -o resources_rc.py
mv resources_rc.py ..

cd ../gui
pyuic5 ui_gui.ui > ui_gui.py
cd ..

27 changes: 18 additions & 9 deletions src/tools/basic_component_py/gui/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@

from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QMainWindow
from gui.ui_gui import Ui_MainWindow
from gui.teleopWidget import TeleopWidget
from gui.cameraWidget import CameraWidget
from gui.communicator import Communicator
from .ui_gui import Ui_MainWindow
from .teleopWidget import TeleopWidget
from .cameraWidget import CameraWidget
from .communicator import Communicator
from .logoWidget import LogoWidget

from jderobotTypes import CMDVel


class MainWindow(QMainWindow, Ui_MainWindow):
Expand All @@ -38,6 +41,10 @@ def __init__(self, parent=None):
self.tlLayout.addWidget(self.teleop)
self.teleop.setVisible(True)

self.logo = LogoWidget(self, self.logoLayout.parent().width(), self.logoLayout.parent().height())
self.logoLayout.addWidget(self.logo)
self.logo.setVisible(True)

self.updGUI.connect(self.updateGUI)

self.cameraWidget = CameraWidget(self)
Expand All @@ -64,9 +71,11 @@ def updateGUI(self):
def setXYValues(self, newX, newY):
self.XValue.setText(str(newX))
self.YValue.setText(str(newY))
myW=-newX*self.motors.getMaxW()
myV=-newY*self.motors.getMaxV()
self.motors.setV(myV)
self.motors.setW(myW)
self.motors.sendVelocities()
if (self.motors):
vel = CMDVel()
myW=-newX*self.motors.getMaxW()
myV=-newY*self.motors.getMaxV()
vel.vx = myV
vel.az = myW
self.motors.sendVelocities(vel)

19 changes: 10 additions & 9 deletions src/tools/basic_component_py/gui/cameraWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ def initUI(self):

def updateImage(self):

img = self.winParent.getCamera().getImage()
if img is not None:
image = QImage(img.data, img.shape[1], img.shape[0],
img.shape[1] * img.shape[2], QImage.Format_RGB888)

size = QtCore.QSize(img.shape[1], img.shape[0])
self.resize(size)
self.imgLabel.resize(size)
self.imgLabel.setPixmap(QPixmap.fromImage(image))
if (self.winParent.getCamera()):
img = self.winParent.getCamera().getImage().data
if img is not None:
image = QImage(img.data, img.shape[1], img.shape[0],
img.shape[1] * img.shape[2], QImage.Format_RGB888)

size = QtCore.QSize(img.shape[1], img.shape[0])
self.resize(size)
self.imgLabel.resize(size)
self.imgLabel.setPixmap(QPixmap.fromImage(image))
44 changes: 44 additions & 0 deletions src/tools/basic_component_py/gui/logoWidget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#
# Copyright (C) 1997-2015 JDE Developers Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
# Authors :
# Alberto Martin Florido <almartinflorido@gmail.com>
#
import resources_rc
from PyQt5 import QtGui
from PyQt5.QtCore import pyqtSignal, QPointF, Qt, QPoint
from PyQt5.QtWidgets import QWidget, QGridLayout

class LogoWidget(QWidget):

def __init__(self,winParent, width=0, height=0):
super(LogoWidget, self).__init__()
self.winParent=winParent
qimage=QtGui.QImage()
qimage.load(':images/jderobot.svg')
if (width != 0 and height != 0):
self.qimage = qimage.scaled(0.8*width, 0.8*height, Qt.KeepAspectRatio)
#self.qimage = qimage.scaled(0.8*width, 0.8*height)
self.resize(width, height)
else:
self.qimage = qimage


def paintEvent(self, e):

painter=QtGui.QPainter(self)
painter.drawImage(self.width()/2-self.qimage.width()/2, self.height()/2-self.qimage.height()/2, self.qimage)


12 changes: 9 additions & 3 deletions src/tools/basic_component_py/gui/ui_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(400, 370)
MainWindow.setMinimumSize(QtCore.QSize(400, 370))
MainWindow.setMaximumSize(QtCore.QSize(400, 370))
MainWindow.resize(430, 400)
MainWindow.setMinimumSize(QtCore.QSize(430, 400))
MainWindow.setMaximumSize(QtCore.QSize(800, 800))
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
Expand All @@ -35,6 +35,12 @@ def setupUi(self, MainWindow):
self.YValue.setGeometry(QtCore.QRect(150, 340, 41, 21))
self.YValue.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.YValue.setObjectName("YValue")
self.verticalLayoutWidget_2 = QtWidgets.QWidget(self.centralwidget)
self.verticalLayoutWidget_2.setGeometry(QtCore.QRect(350, 320, 80, 80))
self.verticalLayoutWidget_2.setObjectName("verticalLayoutWidget_2")
self.logoLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_2)
self.logoLayout.setSpacing(0)
self.logoLayout.setObjectName("logoLayout")
MainWindow.setCentralWidget(self.centralwidget)

self.retranslateUi(MainWindow)
Expand Down
31 changes: 23 additions & 8 deletions src/tools/basic_component_py/gui/ui_gui.ui
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>370</height>
<width>430</width>
<height>400</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>370</height>
<width>430</width>
<height>400</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>370</height>
<width>800</width>
<height>800</height>
</size>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -95,6 +95,21 @@
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget_2">
<property name="geometry">
<rect>
<x>350</x>
<y>320</y>
<width>80</width>
<height>80</height>
</rect>
</property>
<layout class="QVBoxLayout" name="logoLayout">
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget>
</widget>
</widget>
<resources>
Expand Down
11 changes: 11 additions & 0 deletions src/tools/basic_component_py/resources/jderobot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/tools/basic_component_py/resources/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="images">
<file>ball.png</file>
<file>jderobot.svg</file>
</qresource>
</RCC>
70 changes: 69 additions & 1 deletion src/tools/basic_component_py/resources_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,69 @@
\xfe\xf9\x5d\xdf\x48\xad\x86\x91\x5a\xed\x0b\x75\x88\xa3\xd5\x51\
\x8c\x56\x47\xff\xe7\xff\x7f\x03\x97\x54\x18\xa6\xd8\x35\x20\x89\
\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x03\xc6\
\x3c\
\x3f\x78\x6d\x6c\x20\x76\x65\x72\x73\x69\x6f\x6e\x3d\x22\x31\x2e\
\x30\x22\x20\x65\x6e\x63\x6f\x64\x69\x6e\x67\x3d\x22\x55\x54\x46\
\x2d\x38\x22\x20\x73\x74\x61\x6e\x64\x61\x6c\x6f\x6e\x65\x3d\x22\
\x6e\x6f\x22\x3f\x3e\x0a\x3c\x21\x44\x4f\x43\x54\x59\x50\x45\x20\
\x73\x76\x67\x20\x50\x55\x42\x4c\x49\x43\x20\x22\x2d\x2f\x2f\x57\
\x33\x43\x2f\x2f\x44\x54\x44\x20\x53\x56\x47\x20\x31\x2e\x30\x2f\
\x2f\x45\x4e\x22\x20\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\
\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x54\x52\x2f\x32\x30\x30\x31\x2f\
\x50\x52\x2d\x53\x56\x47\x2d\x32\x30\x30\x31\x30\x37\x31\x39\x2f\
\x44\x54\x44\x2f\x73\x76\x67\x31\x30\x2e\x64\x74\x64\x22\x3e\x0a\
\x3c\x73\x76\x67\x20\x77\x69\x64\x74\x68\x3d\x22\x31\x33\x63\x6d\
\x22\x20\x68\x65\x69\x67\x68\x74\x3d\x22\x31\x35\x63\x6d\x22\x20\
\x76\x69\x65\x77\x42\x6f\x78\x3d\x22\x37\x39\x20\x37\x39\x20\x32\
\x34\x33\x20\x32\x39\x35\x22\x20\x78\x6d\x6c\x6e\x73\x3d\x22\x68\
\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\
\x2f\x32\x30\x30\x30\x2f\x73\x76\x67\x22\x20\x78\x6d\x6c\x6e\x73\
\x3a\x78\x6c\x69\x6e\x6b\x3d\x22\x68\x74\x74\x70\x3a\x2f\x2f\x77\
\x77\x77\x2e\x77\x33\x2e\x6f\x72\x67\x2f\x31\x39\x39\x39\x2f\x78\
\x6c\x69\x6e\x6b\x22\x3e\x0a\x20\x20\x3c\x65\x6c\x6c\x69\x70\x73\
\x65\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\x3a\x20\x6e\
\x6f\x6e\x65\x3b\x20\x66\x69\x6c\x6c\x2d\x6f\x70\x61\x63\x69\x74\
\x79\x3a\x30\x3b\x20\x73\x74\x72\x6f\x6b\x65\x2d\x77\x69\x64\x74\
\x68\x3a\x20\x38\x3b\x20\x73\x74\x72\x6f\x6b\x65\x3a\x20\x23\x66\
\x66\x61\x35\x30\x30\x22\x20\x63\x78\x3d\x22\x31\x38\x34\x22\x20\
\x63\x79\x3d\x22\x32\x31\x38\x22\x20\x72\x78\x3d\x22\x38\x37\x22\
\x20\x72\x79\x3d\x22\x38\x34\x22\x2f\x3e\x0a\x20\x20\x3c\x65\x6c\
\x6c\x69\x70\x73\x65\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\
\x6c\x3a\x20\x6e\x6f\x6e\x65\x3b\x20\x66\x69\x6c\x6c\x2d\x6f\x70\
\x61\x63\x69\x74\x79\x3a\x30\x3b\x20\x73\x74\x72\x6f\x6b\x65\x2d\
\x77\x69\x64\x74\x68\x3a\x20\x38\x3b\x20\x73\x74\x72\x6f\x6b\x65\
\x3a\x20\x23\x30\x38\x39\x31\x66\x38\x22\x20\x63\x78\x3d\x22\x31\
\x36\x35\x22\x20\x63\x79\x3d\x22\x32\x33\x33\x22\x20\x72\x78\x3d\
\x22\x35\x34\x22\x20\x72\x79\x3d\x22\x35\x34\x22\x2f\x3e\x0a\x20\
\x20\x3c\x65\x6c\x6c\x69\x70\x73\x65\x20\x73\x74\x79\x6c\x65\x3d\
\x22\x66\x69\x6c\x6c\x3a\x20\x6e\x6f\x6e\x65\x3b\x20\x66\x69\x6c\
\x6c\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\x30\x3b\x20\x73\x74\x72\
\x6f\x6b\x65\x2d\x77\x69\x64\x74\x68\x3a\x20\x38\x3b\x20\x73\x74\
\x72\x6f\x6b\x65\x3a\x20\x23\x66\x66\x30\x30\x30\x30\x22\x20\x63\
\x78\x3d\x22\x32\x30\x31\x22\x20\x63\x79\x3d\x22\x32\x30\x31\x22\
\x20\x72\x78\x3d\x22\x31\x31\x37\x22\x20\x72\x79\x3d\x22\x31\x31\
\x37\x22\x2f\x3e\x0a\x20\x20\x3c\x65\x6c\x6c\x69\x70\x73\x65\x20\
\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\x3a\x20\x6e\x6f\x6e\
\x65\x3b\x20\x66\x69\x6c\x6c\x2d\x6f\x70\x61\x63\x69\x74\x79\x3a\
\x30\x3b\x20\x73\x74\x72\x6f\x6b\x65\x2d\x77\x69\x64\x74\x68\x3a\
\x20\x38\x3b\x20\x73\x74\x72\x6f\x6b\x65\x3a\x20\x23\x30\x62\x62\
\x64\x30\x62\x22\x20\x63\x78\x3d\x22\x31\x35\x32\x22\x20\x63\x79\
\x3d\x22\x32\x34\x35\x22\x20\x72\x78\x3d\x22\x32\x39\x22\x20\x72\
\x79\x3d\x22\x32\x39\x22\x2f\x3e\x0a\x20\x20\x3c\x74\x65\x78\x74\
\x20\x66\x6f\x6e\x74\x2d\x73\x69\x7a\x65\x3d\x22\x33\x39\x2e\x34\
\x39\x39\x38\x22\x20\x73\x74\x79\x6c\x65\x3d\x22\x66\x69\x6c\x6c\
\x3a\x20\x23\x30\x37\x32\x35\x39\x33\x3b\x74\x65\x78\x74\x2d\x61\
\x6e\x63\x68\x6f\x72\x3a\x6d\x69\x64\x64\x6c\x65\x3b\x66\x6f\x6e\
\x74\x2d\x66\x61\x6d\x69\x6c\x79\x3a\x73\x61\x6e\x73\x2d\x73\x65\
\x72\x69\x66\x3b\x66\x6f\x6e\x74\x2d\x73\x74\x79\x6c\x65\x3a\x6e\
\x6f\x72\x6d\x61\x6c\x3b\x66\x6f\x6e\x74\x2d\x77\x65\x69\x67\x68\
\x74\x3a\x37\x30\x30\x22\x20\x78\x3d\x22\x32\x30\x35\x22\x20\x79\
\x3d\x22\x33\x36\x35\x22\x3e\x0a\x20\x20\x20\x20\x3c\x74\x73\x70\
\x61\x6e\x20\x78\x3d\x22\x32\x30\x35\x22\x20\x79\x3d\x22\x33\x36\
\x35\x22\x3e\x4a\x64\x65\x52\x6f\x62\x6f\x74\x3c\x2f\x74\x73\x70\
\x61\x6e\x3e\x0a\x20\x20\x3c\x2f\x74\x65\x78\x74\x3e\x0a\x3c\x2f\
\x73\x76\x67\x3e\x0a\
"

qt_resource_name = b"\
Expand All @@ -139,11 +202,16 @@
\x08\x2f\x5a\x47\
\x00\x62\
\x00\x61\x00\x6c\x00\x6c\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0c\
\x07\x72\xc8\x67\
\x00\x6a\
\x00\x64\x00\x65\x00\x72\x00\x6f\x00\x62\x00\x6f\x00\x74\x00\x2e\x00\x73\x00\x76\x00\x67\
"

qt_resource_struct = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x02\x00\x00\x00\x02\
\x00\x00\x00\x28\x00\x00\x00\x00\x00\x01\x00\x00\x07\x51\
\x00\x00\x00\x12\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
"

Expand Down

0 comments on commit 9ea238d

Please sign in to comment.