Skip to content

Commit

Permalink
Add dropdown for selecting fidget set to send to Tega
Browse files Browse the repository at this point in the history
  • Loading branch information
jakory committed Jul 29, 2017
1 parent 61b9a84 commit 96b85fa
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 4 deletions.
65 changes: 65 additions & 0 deletions src/tega_fidget_ui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Jacqueline Kory Westlund
# July 2017
#
# The MIT License (MIT)
#
# Copyright (c) 2016 Personal Robots Group
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from PySide import QtGui # Basic GUI stuff.
from tega_teleop_ros import tega_teleop_ros
# Get fidget constants from TegaAction ROS msgs.
from r1d1_msgs.msg import TegaAction

class tega_fidget_ui(QtGui.QWidget):

fidget_sets = {
"no fidgets": TegaAction.FIDGETS_EMPTY,
"speech fidgets": TegaAction.FIDGETS_SPEECH,
"physical fidgets": TegaAction.FIDGETS_PHYSICAL
}

def __init__(self, ros_node):
""" Make buttons to tell robot to look different directions """
super(tega_fidget_ui, self).__init__()
# Get reference to ros node so we can do callbacks to publish messages.
self.ros_node = ros_node

# Put buttons in a box.
self.fidget_box = QtGui.QGroupBox(self)
self.fidget_layout = QtGui.QGridLayout(self.fidget_box)
self.fidget_box.setTitle("Fidgets")

# Create fidget buttons and add to layout.
self.label = QtGui.QLabel(self.fidget_box)
self.label.setText("Choose fidget set: ")
self.fidget_layout.addWidget(self.label, 0, 0)

self.fidget_set_box = QtGui.QComboBox(self)
fidget_set_list = self.fidget_sets.keys()
self.fidget_set_box.addItems(fidget_set_list)
self.fidget_set_box.activated['QString'].connect(self.on_fidget_set_selected)
self.fidget_layout.addWidget(self.fidget_set_box, 0, 1, 1, 2)

def on_fidget_set_selected(self, fidget_set):
""" When the fidget set is changed in the combo box, send a message
to the robot to tell it what set should now be in use.
"""
self.ros_node.send_fidget_message(self.fidget_sets[fidget_set])
9 changes: 7 additions & 2 deletions src/tega_teleop.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from tega_lookat_ui import tega_lookat_ui
from tega_speech_ui import tega_speech_ui
from opal_tablet_ui import opal_tablet_ui
from tega_fidget_ui import tega_fidget_ui
from tega_teleop_flags import tega_teleop_flags

class tega_teleop(QtGui.QMainWindow):
Expand Down Expand Up @@ -80,20 +81,24 @@ def __init__(self, use_entrainer):

# add animation buttons
anim_ui = tega_animation_ui(self.ros_teleop)
self.central_layout.addWidget(anim_ui, 0, 0, 3, 7)
self.central_layout.addWidget(anim_ui, 0, 0, 2, 7)

# add lookat buttons
lookat_ui = tega_lookat_ui(self.ros_teleop)
self.central_layout.addWidget(lookat_ui, 2, 3, 2, 3)

# Add fidget control buttons.
fidget_ui = tega_fidget_ui(self.ros_teleop)
self.central_layout.addWidget(fidget_ui, 3, 3, 1, 3)

# add tablet controls
opal_ui = opal_tablet_ui(self.ros_teleop)
self.central_layout.addWidget(opal_ui, 2, 0, 2, 3)

# add robot script playback buttons (mostly speech, but the scripts
# can also list animations to play before or after an audio file)
speech_ui = tega_speech_ui(self.ros_teleop, self.flags, use_entrainer)
self.central_layout.addWidget(speech_ui, 4, 0, 3, 7)
self.central_layout.addWidget(speech_ui, 5, 0, 3, 7)

if __name__ == '__main__':

Expand Down
12 changes: 10 additions & 2 deletions src/tega_teleop_ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def send_motion_message(self, motion):
if self.tega_pub is not None:
print 'sending motion message: %s' % motion
msg = TegaAction()
msg.do_motion = True
msg.motion = motion
self.tega_pub.publish(msg)
rospy.loginfo(msg)
Expand All @@ -108,11 +107,20 @@ def send_speech_message(self, speech):
if self.tega_pub is not None:
print '\nsending speech message: %s' % speech
msg = TegaAction()
msg.do_sound_playback = True
msg.wav_filename = speech
self.tega_pub.publish(msg)
rospy.loginfo(msg)

def send_fidget_message(self, fidget):
""" Publish TegaAction message setting the fidget set in use. """
if self.tega_pub is not None:
print '\nsending fidget message: %s' % fidget
msg = TegaAction()
msg.fidgets = fidget
self.tega_pub.publish(msg)
rospy.loginfo(msg)


def send_entrain_audio_message(self, speech, visemes, age, entrain):
""" Publish EntrainAudio message. """
if self.entrain_pub is not None:
Expand Down

0 comments on commit 96b85fa

Please sign in to comment.