Language selection via ros parameters work. Default language is english

This commit is contained in:
Olek Bojda 2018-11-26 19:52:40 +01:00
parent 7b35eaf9f8
commit accc17fc68
6 changed files with 76 additions and 14 deletions

View File

@ -4,4 +4,12 @@
name="$(anon user_plugin)"
args="--standalone safety_user_plugin"
/>
<arg name="lang" default="eng"/>
<param
name="lang"
type="string"
value="$(arg lang)"
/>
</launch>

View File

@ -48,6 +48,18 @@ class EnglishTexts(LanguageTexts):
connection_to_master_lost_text = 'Connection lost with masterSTOP. Ask the teacher to run it'
# Description labels
linear_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Linear velocity</span></p></body></html>'
angular_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Angular velocity</span></p></body></html>'
id_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Robot ID</span></p></body></html>'
battery_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Battery state</span></p></body></html>'
masterstop_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Master Stop</span></p></body></html>'
obstacle_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Obstacle Stop</span></p></body></html>'
robot_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Robot state</span></p></body></html>'
restrictions_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Restrictions</span></p></body></html>'
history_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Message history</span></p></body></html>'
def __init__(self):
pass

View File

@ -44,5 +44,18 @@ class LanguageTexts:
connection_to_master_lost_text = "Text not reimplemented!"
# Description labels
angular_text = "Text not reimplemented!"
linear_text = "Text not reimplemented!"
id_text = "Text not reimplemented!"
battery_text = "Text not reimplemented!"
masterstop_text = "Text not reimplemented!"
obstacle_text = "Text not reimplemented!"
robot_text = "Text not reimplemented!"
restrictions_text = "Text not reimplemented!"
history_text = "Text not reimplemented!"
def __init__(self):
pass

View File

@ -38,7 +38,7 @@ class PolishTexts(LanguageTexts):
obstacle_detected_text = 'Przeszkoda wykryta. Zatrzymuję robota'
obstacle_removed_text = 'Przeszkoda usunięta'
# Logger error/problem messages
selection_error_text = 'Najpierw wybierz PIONIERA z listy robotów'
cannot_start_masterstop_text = 'Nie można wystartować robota. MasterSTOP wciśnięty!'
@ -48,6 +48,16 @@ class PolishTexts(LanguageTexts):
connection_to_master_lost_text = 'Utrata połączenia z masterstopem. Poproś prowadzącego o jego uruchomienie'
# Description labels
linear_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Prędkość liniowa</span></p></body></html>'
angular_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Prędkość obrotowa</span></p></body></html>'
id_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">ID robota</span></p></body></html>'
battery_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Stan baterii</span></p></body></html>'
masterstop_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Stop mastera</span></p></body></html>'
obstacle_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Stop przeszkody</span></p></body></html>'
robot_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Stan robota</span></p></body></html>'
restrictions_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Ograniczenia</span></p></body></html>'
history_text = '<html><head/><body><p align="center"><span style=" font-weight:600;">Historia komunikatów</span></p></body></html>'
def __init__(self):
pass

View File

@ -24,7 +24,16 @@ class QtWrapper:
self.widget = widget
self.displayed_robots_id_list = []
self.language = ET
lang = rospy.get_param('lang')
if lang == 'eng':
self.language = ET
self.log_info('Started english version of plugin')
elif lang == 'pol':
self.language = PT
self.log_info('Polska wersja pluginu uruchomiona')
else:
raise ValueError('language parameter has value different than "eng" or "pol"')
self.clear_robot_info()
@ -67,6 +76,7 @@ class QtWrapper:
else:
method_with_argument = 'self.{0}({1})'.format(method_name,argument[0])
exec(method_with_argument)
def handle_stopButton_clicked(self):
if self.robot_state == SS.RUNNING:
@ -300,7 +310,6 @@ class QtWrapper:
scrollbar = self.widget.logsBrowser.verticalScrollBar()
scrollbar.setValue(scrollbar.maximum())
def clear_robot_info(self):
self.widget.idLabel.setText('-')
self.widget.batteryLabel.setText('-')
@ -317,3 +326,13 @@ class QtWrapper:
self.widget.clutchButton.setText('-')
self.widget.clutchButton.setStyleSheet("")
self.widget.angularText.setText(self.language.angular_text)
self.widget.batteryText.setText(self.language.battery_text)
self.widget.idText.setText(self.language.id_text)
self.widget.linearText.setText(self.language.linear_text)
self.widget.masterStopText.setText(self.language.masterstop_text)
self.widget.obstacleText.setText(self.language.obstacle_text)
self.widget.robotText.setText(self.language.robot_text)
self.widget.historyLabel.setText(self.language.history_text)
self.widget.restrictionsLabel.setText(self.language.restrictions_text)

View File

@ -80,49 +80,49 @@
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="idText">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;ID robota&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<widget class="QLabel" name="batteryText">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Stan baterii&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<widget class="QLabel" name="linearText">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Predkosc liniowa&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_8">
<widget class="QLabel" name="angularText">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Predkosc obrotowa&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<widget class="QLabel" name="robotText">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Stan robota&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_10">
<widget class="QLabel" name="masterStopText">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Stop mastera&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="obstacleText">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Stop przeszkody&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
@ -258,7 +258,7 @@
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLabel" name="label_12">
<widget class="QLabel" name="restrictionsLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Ograniczenia&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
@ -338,7 +338,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Zatrzymaj robota</string>
<string>-</string>
</property>
</widget>
</item>
@ -351,7 +351,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Sprzeglo ON</string>
<string>-</string>
</property>
</widget>
</item>
@ -371,7 +371,7 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="historyLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Histora komunikatów&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>