本文整理汇总了Python中dialogueModule.Dialogue类的典型用法代码示例。如果您正苦于以下问题:Python Dialogue类的具体用法?Python Dialogue怎么用?Python Dialogue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dialogue类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.emote_parameters = {"weight": 0, "time": 0, "space": 0, "flow": 0}
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setVariables()
#QtCore.QObject.connect(self.ui.weightSlider, QtCore.SIGNAL("valueChanged(int)"), self.weightChange)
#QtCore.QObject.connect(self.ui.timeSlider, QtCore.SIGNAL("valueChanged(int)"), self.timeChange)
#QtCore.QObject.connect(self.ui.spaceSlider, QtCore.SIGNAL("valueChanged(int)"), self.spaceChange)
#QtCore.QObject.connect(self.ui.flowSlider, QtCore.SIGNAL("valueChanged(int)"), self.flowChange)
#QtCore.QObject.connect(self.ui.expEdit, QtCore.SIGNAL("returnPressed()"), self.evaluateExp)
#QtCore.QObject.connect(self.ui.expButton, QtCore.SIGNAL("released()"), self.applyWaveshape)
# === Apply action to the self.ui.runbutton
QtCore.QObject.connect(self.ui.runbutton, QtCore.SIGNAL("released()"), self.runData)
QtCore.QObject.connect(self.ui.run, QtCore.SIGNAL("triggered()"), self.runData)
self.connect(self.ui.exit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueClear, QtCore.SIGNAL("clicked()"), self.ui.lineEditUserDialogue, QtCore.SLOT("clear()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueOK, QtCore.SIGNAL("clicked()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.lineEditUserDialogue, QtCore.SIGNAL("returnPressed()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.pushButtonMotion, QtCore.SIGNAL("clicked()"), self.runMotion)
self.loadData()
self.dialogue = Dialogue()
self.dialogueInit = True
self.dialogueContext = {"action": "", "topic": "", "username": "", "botname": "", "it": "", "usermood": "", "personality": ""}
self.populateMotionBox()
示例2: setVariables
def setVariables(self):
# Containers...
self.motionPath = [] # list of path to .csv files loaded using glob
self.motionSignalPath = {} # dictionary of path to .csv files indexed by file name
self.CURRENT_MOTION_DATA = [] # container for current loaded motion data from file
self.CURRENT_INTERP_MOTION_DATA = [] # container for current interpolated motion data
self.OUTPUT_DATA = []
# Parameters...
self.interpParameters = {'tension': 0, 'bias': 0, 'continuity': 0} # interpolation parameters
self.affectProcessing = False
# Constants...
self.defaultMotionPath = "/home/msunardi/Documents/thesis-stuff/KHR-1-motions/"
self.khr1Device = "/dev/ttyUSB0"
# Class instances...
self.ms = MotionSynthesizer()
try:
self.dialogue = Dialogue()
except:
print "No dialogue this time..."
try:
self.lcontext = locoContext()
except:
print "No lococontext this time..."
示例3: __init__
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.emote_parameters = {"weight": 0, "time": 0, "space": 0, "flow": 0}
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setVariables()
""" === These assignments are moved to function "applyGainSignalSlot" because the interface
has to be reloaded when loading a different motion file
"""
#QtCore.QObject.connect(self.ui.weightSlider, QtCore.SIGNAL("valueChanged(int)"), self.weightChange)
#QtCore.QObject.connect(self.ui.timeSlider, QtCore.SIGNAL("valueChanged(int)"), self.timeChange)
#QtCore.QObject.connect(self.ui.spaceSlider, QtCore.SIGNAL("valueChanged(int)"), self.spaceChange)
#QtCore.QObject.connect(self.ui.flowSlider, QtCore.SIGNAL("valueChanged(int)"), self.flowChange)
#QtCore.QObject.connect(self.ui.expEdit, QtCore.SIGNAL("returnPressed()"), self.evaluateExp)
#QtCore.QObject.connect(self.ui.expButton, QtCore.SIGNAL("released()"), self.applyWaveshape)
# === Apply action to the self.ui.runbutton
QtCore.QObject.connect(self.ui.runbutton, QtCore.SIGNAL("released()"), self.runData)
QtCore.QObject.connect(self.ui.run, QtCore.SIGNAL("triggered()"), self.runData)
self.connect(self.ui.exit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueClear, QtCore.SIGNAL("clicked()"), self.ui.lineEditUserDialogue, QtCore.SLOT("clear()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueOK, QtCore.SIGNAL("clicked()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.lineEditUserDialogue, QtCore.SIGNAL("returnPressed()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.pushButtonMotion, QtCore.SIGNAL("clicked()"), self.runMotion)
# === List of Motion options
self.motionFilePath = ["/home/msunardi/Documents/thesis-stuff/KHR-1-motions/better_fwd_walk_data.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/push_ups_data.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/sweetescape_bird.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/sweetescape_surf_left.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/sweetescape_surf_right.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/backflip.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/backward_roll.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/Extrm_CH1.csv"]
# === Select a motion
self.currentMotion = self.motionFilePath[1]
# === Load the motion data
self.loadData(self.currentMotion)
QtCore.QObject.connect(self.ui.pointSelector, QtCore.SIGNAL("currentIndexChanged(int)"), self.setPointSlider)
QtCore.QObject.connect(self.ui.pointSlider, QtCore.SIGNAL("valueChanged(int)"), self.pointChange)
QtCore.QObject.connect(self.ui.pointSlider, QtCore.SIGNAL("valueChanged(int)"), self.pointLineEditChange)
QtCore.QObject.connect(self.ui.pointButton, QtCore.SIGNAL("released()"), self.applyWaveshape2)
try:
self.dialogue = Dialogue()
except:
print "No dialogue this time..."
self.dialogueInit = True
self.dialogueContext = {"action": "", "topic": "", "username": "", "botname": "", "it": "", "usermood": "", "personality": ""}
self.populateMotionBox()
self.timer = QtCore.QBasicTimer() # <<< CREATE QBasicTimer object
self.timer.start(self.heartrate, self.ui.ecg) # <<< START QBasicTimer(interval (ms), QObject)
示例4: __init__
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.emote_parameters = {"weight": 0, "time": 0, "space": 0, "flow": 0}
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setVariables()
#QtCore.QObject.connect(self.ui.weightSlider, QtCore.SIGNAL("valueChanged(int)"), self.weightChange)
#QtCore.QObject.connect(self.ui.timeSlider, QtCore.SIGNAL("valueChanged(int)"), self.timeChange)
#QtCore.QObject.connect(self.ui.spaceSlider, QtCore.SIGNAL("valueChanged(int)"), self.spaceChange)
#QtCore.QObject.connect(self.ui.flowSlider, QtCore.SIGNAL("valueChanged(int)"), self.flowChange)
#QtCore.QObject.connect(self.ui.expEdit, QtCore.SIGNAL("returnPressed()"), self.evaluateExp)
#QtCore.QObject.connect(self.ui.expButton, QtCore.SIGNAL("released()"), self.applyWaveshape)
# === Apply action to the self.ui.runbutton
QtCore.QObject.connect(self.ui.runbutton, QtCore.SIGNAL("released()"), self.runData)
QtCore.QObject.connect(self.ui.run, QtCore.SIGNAL("triggered()"), self.runData)
self.connect(self.ui.exit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueClear, QtCore.SIGNAL("clicked()"), self.ui.lineEditUserDialogue, QtCore.SLOT("clear()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueOK, QtCore.SIGNAL("clicked()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.lineEditUserDialogue, QtCore.SIGNAL("returnPressed()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.pushButtonMotion, QtCore.SIGNAL("clicked()"), self.runMotion)
self.dialogue = Dialogue()
self.dialogueInit = True
self.dialogueContext = {"action": "", "topic": "", "username": "", "botname": "", "it": "", "usermood": "", "personality": ""}
self.populateMotionBox()
# === List of Motion options
self.motionFilePath = ["/home/msunardi/Documents/thesis-stuff/KHR-1-motions/better_fwd_walk_data.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/push_ups_data.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/sweetescape_bird.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/sweetescape_surf_left.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/sweetescape_surf_right.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/backflip.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/backward_roll.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/Extrm_CH1.csv"]
# === Select a motion
self.currentMotion = self.motionFilePath[0]
# === Load the motion data
self.loadData(self.currentMotion)
示例5: MyForm
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setVariables()
self.ui.populateChannelList()
self.setActions()
self.motionPath = self.loadMotionFiles()
self.formatMotionList(self.motionPath)
self.ui.populateKhr1MotionBox()
#self.ui.populateMotionBox(self.formatMotionList(self.motionSignalPath))
self.ui.populateMotionBox([k for k,v in self.motionSignalPath.items()])
#self.loadData(self.motionSignalPath[self.ui.motionComboBox.currentIndex()])
print self.ui.motionComboBox.currentText()
#self.loadData(self.motionSignalPath[self.ui.motionComboBox.currentText()])
self.loadData(dataIndex=self.ui.motionComboBox.currentText())
def setVariables(self):
# Containers...
self.motionPath = [] # list of path to .csv files loaded using glob
self.motionSignalPath = {} # dictionary of path to .csv files indexed by file name
self.CURRENT_MOTION_DATA = [] # container for current loaded motion data from file
self.CURRENT_INTERP_MOTION_DATA = [] # container for current interpolated motion data
self.OUTPUT_DATA = []
self.SCRIPT = []
self.chatoptions = {}
# Parameters...
self.interpParameters = {'tension': 0, 'bias': 0, 'continuity': 0} # interpolation parameters
self.affectProcessing = False
self.dialogueInit = True
# Constants...
self.defaultMotionPath = "/home/msunardi/Documents/thesis-stuff/KHR-1-motions/"
self.khr1Device = "/dev/ttyUSB0"
scriptpath = 'scripts/script1.csv'
# Class instances...
self.ms = MotionSynthesizer()
try:
self.dialogue = Dialogue()
except:
print "No dialogue this time..."
try:
self.lcontext = locoContext()
except:
print "No lococontext this time..."
try:
rs = readScript()
self.SCRIPT = rs.read(scriptpath)
print "Script: %s is loaded." % scriptpath
self.scriptindex=0
except:
print "Failed loading Script."
def setActions(self):
print "setActions"
self.setActionsChannelsCheckBox()
self.setActionsAffectProcessingCheckBox()
self.setActionsMotionControls()
self.setActionsMotionFile()
self.setTabActions()
self.setToolbarActions()
self.setActionsRobotState()
self.setActionsChatUI()
def setActionsChatUI(self):
QtCore.QObject.connect(self.ui.chatInputClearButton, QtCore.SIGNAL("clicked()"), self.ui.chatInput, QtCore.SLOT("clear()"))
QtCore.QObject.connect(self.ui.chatInputEnterButton, QtCore.SIGNAL("clicked()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.chatInput, QtCore.SIGNAL("returnPressed()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.chatContextCheckbox, QtCore.SIGNAL("stateChanged(int)"), self.toggleChatContextVisible)
def setActionsRobotState(self):
QtCore.QObject.connect(self.ui.stateShowCheckBox, QtCore.SIGNAL("stateChanged(int)"), self.toggleStateVisible)
def setToolbarActions(self):
self.connect(self.ui.exit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()"))
def setTabActions(self):
self.resetParameters()
self.setActionsInterpolation()
self.setActionsResampling()
self.setActionsMultiresfiltering()
def setActionsGainSliders(self):
print "setting actions for gain sliders and line edits...",
for gs in self.ui.gainSliders:
QtCore.QObject.connect(gs, QtCore.SIGNAL("valueChanged(int)"), self.adjustGain)
#.........这里部分代码省略.........
示例6: __init__
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
###CB1.1 --- Build the UI
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
###CB1.2 --- Create class variables (e.g. lists, etc.)
self.setVariables()
###CB1.3 --- Assign SIGNAL & SLOTS
###CB1.3.1 --- Effort Sliders & Waveshaping function. These 6 assignments are moved to function "applyGainSignalSlot" because the interface has to be reloaded when loading a different motion file (*REMOVED per 4/19 - pyLocoRobo_06.py*)
###CB1.3.5 --- Assign action to the self.ui.runbutton
QtCore.QObject.connect(self.ui.runbutton, QtCore.SIGNAL("released()"), self.runData)
###CB1.3.6 --- Assign action to the Toolbar Run button
QtCore.QObject.connect(self.ui.run, QtCore.SIGNAL("triggered()"), self.runData)
###CB1.3.7 --- Assign action to the Toolbar Exit button
self.connect(self.ui.exit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()"))
###CB1.3.8 --- Assign action to Clear Dialogue button
QtCore.QObject.connect(self.ui.pushButtonDialogueClear, QtCore.SIGNAL("clicked()"), self.ui.lineEditUserDialogue, QtCore.SLOT("clear()"))
###CB1.3.9 --- Assign action to OK Dialogue button
QtCore.QObject.connect(self.ui.pushButtonDialogueOK, QtCore.SIGNAL("clicked()"), self.talkToRobot)
###CB1.3.10 --- Assign action to User Input Field/Line
QtCore.QObject.connect(self.ui.lineEditUserDialogue, QtCore.SIGNAL("returnPressed()"), self.talkToRobot)
###CB1.3.11 --- Assign action to Execute selected motion
QtCore.QObject.connect(self.ui.pushButtonMotion, QtCore.SIGNAL("clicked()"), self.runMotion)
QtCore.QObject.connect(self.ui.pushButtonLoadMotion, QtCore.SIGNAL("clicked()"), self.loadMotion)
###CB1.4 --- Load song list from folder
self.songs = glob.glob("/home/msunardi/Music/*.mp3")
###CB1.5 --- Load the motion data
#self.loadData(self.currentMotion)
###CB1.6 --- Try to load the Dialogue module
#### The Dialogue module may sometime not able to load because of competing soundcard usage by other OS components. Still need to figure this one out.
try:
self.dialogue = Dialogue()
#pass
except:
print "No dialogue this time..."
try:
self.lcontext = locoContext()
except:
print "No lococontext this time..."
###CB1.7 --- Populate the Motion List combobox (KHR1 memory)
self.populateMotionBox()
###CB1.8 --- Populate the Music/Song List combobox
self.populateMusicBox()
###CB1.9 --- Populate the Motion Signal combobox
#self.populateSignalBox(self.motionFilePath)
self.populateSignalBox(self.motionSignalPath)
self.loadData(self.ui.comboBoxMotionSignal.currentText()) # <<< Load the first motion data to plot
"""=== NOTE (4/16/09):
For some reason, the data must be populated first, then apply the SIGNAL-SLOT assignments for the Waveshaping2 functions afterwards for them to work.
======="""
###CB1.3.2 --- Assign action to Waveshaping2 combobox
QtCore.QObject.connect(self.ui.pointSelector, QtCore.SIGNAL("currentIndexChanged(int)"), self.setPointSlider)
###CB1.3.3a --- Assign action to Waveshaping2 sliderbar: change point value
QtCore.QObject.connect(self.ui.pointSlider, QtCore.SIGNAL("valueChanged(int)"), self.pointChange)
###CB1.3.3b --- Assign action to Waveshaping2 sliderbar: change the value showing in the lineedit
QtCore.QObject.connect(self.ui.pointSlider, QtCore.SIGNAL("valueChanged(int)"), self.pointLineEditChange)
###CB1.3.4 --- Assign action to Waveshaping2 button: apply waveshape to motion signal
QtCore.QObject.connect(self.ui.pointButton, QtCore.SIGNAL("clicked()"), self.applyWaveshape2)
###CB1.10 --- Set up the timer for HeartBeat simulator
self.timer = QtCore.QBasicTimer() # <<< CREATE QBasicTimer object
self.timer.start(self.heartrate, self.ui.ecg) # <<< START QBasicTimer(interval (ms), QObject)
self.tryData(self.motionFilePath)
示例7: MyForm
class MyForm(QtGui.QMainWindow):
##=== SECTION 1: LOAD/INITIALIZE GUI COMPONENTS (CB1 - CB11)
##CB1 --- Code Block (CB) 1: "constructor"(?)
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
###CB1.1 --- Build the UI
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
###CB1.2 --- Create class variables (e.g. lists, etc.)
self.setVariables()
###CB1.3 --- Assign SIGNAL & SLOTS
###CB1.3.1 --- Effort Sliders & Waveshaping function. These 6 assignments are moved to function "applyGainSignalSlot" because the interface has to be reloaded when loading a different motion file (*REMOVED per 4/19 - pyLocoRobo_06.py*)
###CB1.3.5 --- Assign action to the self.ui.runbutton
QtCore.QObject.connect(self.ui.runbutton, QtCore.SIGNAL("released()"), self.runData)
###CB1.3.6 --- Assign action to the Toolbar Run button
QtCore.QObject.connect(self.ui.run, QtCore.SIGNAL("triggered()"), self.runData)
###CB1.3.7 --- Assign action to the Toolbar Exit button
self.connect(self.ui.exit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()"))
###CB1.3.8 --- Assign action to Clear Dialogue button
QtCore.QObject.connect(self.ui.pushButtonDialogueClear, QtCore.SIGNAL("clicked()"), self.ui.lineEditUserDialogue, QtCore.SLOT("clear()"))
###CB1.3.9 --- Assign action to OK Dialogue button
QtCore.QObject.connect(self.ui.pushButtonDialogueOK, QtCore.SIGNAL("clicked()"), self.talkToRobot)
###CB1.3.10 --- Assign action to User Input Field/Line
QtCore.QObject.connect(self.ui.lineEditUserDialogue, QtCore.SIGNAL("returnPressed()"), self.talkToRobot)
###CB1.3.11 --- Assign action to Execute selected motion
QtCore.QObject.connect(self.ui.pushButtonMotion, QtCore.SIGNAL("clicked()"), self.runMotion)
QtCore.QObject.connect(self.ui.pushButtonLoadMotion, QtCore.SIGNAL("clicked()"), self.loadMotion)
###CB1.4 --- Load song list from folder
self.songs = glob.glob("/home/msunardi/Music/*.mp3")
###CB1.5 --- Load the motion data
#self.loadData(self.currentMotion)
###CB1.6 --- Try to load the Dialogue module
#### The Dialogue module may sometime not able to load because of competing soundcard usage by other OS components. Still need to figure this one out.
try:
self.dialogue = Dialogue()
#pass
except:
print "No dialogue this time..."
try:
self.lcontext = locoContext()
except:
print "No lococontext this time..."
###CB1.7 --- Populate the Motion List combobox (KHR1 memory)
self.populateMotionBox()
###CB1.8 --- Populate the Music/Song List combobox
self.populateMusicBox()
###CB1.9 --- Populate the Motion Signal combobox
#self.populateSignalBox(self.motionFilePath)
self.populateSignalBox(self.motionSignalPath)
self.loadData(self.ui.comboBoxMotionSignal.currentText()) # <<< Load the first motion data to plot
"""=== NOTE (4/16/09):
For some reason, the data must be populated first, then apply the SIGNAL-SLOT assignments for the Waveshaping2 functions afterwards for them to work.
======="""
###CB1.3.2 --- Assign action to Waveshaping2 combobox
QtCore.QObject.connect(self.ui.pointSelector, QtCore.SIGNAL("currentIndexChanged(int)"), self.setPointSlider)
###CB1.3.3a --- Assign action to Waveshaping2 sliderbar: change point value
QtCore.QObject.connect(self.ui.pointSlider, QtCore.SIGNAL("valueChanged(int)"), self.pointChange)
###CB1.3.3b --- Assign action to Waveshaping2 sliderbar: change the value showing in the lineedit
QtCore.QObject.connect(self.ui.pointSlider, QtCore.SIGNAL("valueChanged(int)"), self.pointLineEditChange)
###CB1.3.4 --- Assign action to Waveshaping2 button: apply waveshape to motion signal
QtCore.QObject.connect(self.ui.pointButton, QtCore.SIGNAL("clicked()"), self.applyWaveshape2)
###CB1.10 --- Set up the timer for HeartBeat simulator
self.timer = QtCore.QBasicTimer() # <<< CREATE QBasicTimer object
self.timer.start(self.heartrate, self.ui.ecg) # <<< START QBasicTimer(interval (ms), QObject)
self.tryData(self.motionFilePath)
##CB2 --- create class' global variables
def setVariables(self):
self.freqBands = [] # <<< For frequency bands
self.originalData = [] # <<< For loaded motion data
self.newData = [] # <<< For processed motion data
self.bandAdjusters = [] # <<< For values of band adjustments
self.ms = MotionSynthesizer() # <<< Create instance of MotionSynthesizer
self.heartrate = 30 # <<< Default heartrate value
#.........这里部分代码省略.........
示例8: MyForm
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.emote_parameters = {"weight": 0, "time": 0, "space": 0, "flow": 0}
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setVariables()
""" === These assignments are moved to function "applyGainSignalSlot" because the interface
has to be reloaded when loading a different motion file
"""
#QtCore.QObject.connect(self.ui.weightSlider, QtCore.SIGNAL("valueChanged(int)"), self.weightChange)
#QtCore.QObject.connect(self.ui.timeSlider, QtCore.SIGNAL("valueChanged(int)"), self.timeChange)
#QtCore.QObject.connect(self.ui.spaceSlider, QtCore.SIGNAL("valueChanged(int)"), self.spaceChange)
#QtCore.QObject.connect(self.ui.flowSlider, QtCore.SIGNAL("valueChanged(int)"), self.flowChange)
#QtCore.QObject.connect(self.ui.expEdit, QtCore.SIGNAL("returnPressed()"), self.evaluateExp)
#QtCore.QObject.connect(self.ui.expButton, QtCore.SIGNAL("released()"), self.applyWaveshape)
# === Apply action to the self.ui.runbutton
QtCore.QObject.connect(self.ui.runbutton, QtCore.SIGNAL("released()"), self.runData)
QtCore.QObject.connect(self.ui.run, QtCore.SIGNAL("triggered()"), self.runData)
self.connect(self.ui.exit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueClear, QtCore.SIGNAL("clicked()"), self.ui.lineEditUserDialogue, QtCore.SLOT("clear()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueOK, QtCore.SIGNAL("clicked()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.lineEditUserDialogue, QtCore.SIGNAL("returnPressed()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.pushButtonMotion, QtCore.SIGNAL("clicked()"), self.runMotion)
# === List Songs
self.songs = glob.glob("/home/msunardi/Music/*.mp3")
# === List of Motion options
self.motionFilePath = ["/home/msunardi/Documents/thesis-stuff/KHR-1-motions/better_fwd_walk_data.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/push_ups_data.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/sweetescape_bird.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/sweetescape_surf_left.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/sweetescape_surf_right.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/backflip.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/backward_roll.csv",
"/home/msunardi/Documents/thesis-stuff/KHR-1-motions/Extrm_CH1.csv"]
self.motionSignalPath = glob.glob("/home/msunardi/Documents/thesis-stuff/KHR-1-motions/*.csv")
# === Select a motion
self.currentMotion = self.motionFilePath[1]
# === Load the motion data
self.loadData(self.currentMotion)
QtCore.QObject.connect(self.ui.pointSelector, QtCore.SIGNAL("currentIndexChanged(int)"), self.setPointSlider)
QtCore.QObject.connect(self.ui.pointSlider, QtCore.SIGNAL("valueChanged(int)"), self.pointChange)
QtCore.QObject.connect(self.ui.pointSlider, QtCore.SIGNAL("valueChanged(int)"), self.pointLineEditChange)
QtCore.QObject.connect(self.ui.pointButton, QtCore.SIGNAL("released()"), self.applyWaveshape2)
try:
self.dialogue = Dialogue()
except:
print "No dialogue this time..."
self.dialogueInit = True
self.dialogueContext = {"action": "", "topic": "", "username": "", "botname": "", "it": "", "usermood": "", "personality": "", "robotmood": ""}
self.populateMotionBox()
self.populateMusicBox()
self.populateSignalBox(self.motionFilePath)
self.timer = QtCore.QBasicTimer() # <<< CREATE QBasicTimer object
self.timer.start(self.heartrate, self.ui.ecg) # <<< START QBasicTimer(interval (ms), QObject)
#self.x = QtGui.QTextEdit(self.ui)
#test:
#self.ui.qwtPlot.addCurve(range(0,200,1))
#self.ui.qwtPlot.addCurve(range(0,200,1))
#works!
def setVariables(self):
self.freqBands = []
self.allData = []
self.newData = []
self.bandAdjusters = []
self.ms = MotionSynthesizer()
self.heartrate = 30
#self.khr1 = khr1Interface("/dev/ttyUSB0")
def populateMotionBox(self):
molist = []
for i in range(40):
molist.append(str(i))
self.ui.comboBoxMotion.addItems(molist)
def populateMusicBox(self):
self.ui.comboBoxMusic.addItems(self.songs)
self.ui.comboBoxMusic.setCurrentIndex(0)
def populateSignalBox(self, population, defaultIndex=None):
self.ui.comboBoxMotionSignal.addItems(population)
if defaultIndex is None:
self.ui.comboBoxMotionSignal.setCurrentIndex(1)
else:
self.ui.comboBoxMotionSignal.setCurrentIndex(defaultIndex)
self.loadData(self.ui.comboBoxMotionSignal.currentText())
#.........这里部分代码省略.........
示例9: MyForm
class MyForm(QtGui.QMainWindow):
##=== SECTION 1: LOAD/INITIALIZE GUI COMPONENTS (CB1 - CB11)
##CB1 --- Code Block (CB) 1: "constructor"(?)
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
###CB1.1 --- Build the UI
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
###CB1.2 --- Create class variables (e.g. lists, etc.)
self.setVariables()
###CB1.3 --- Assign SIGNAL & SLOTS
###CB1.3.1 --- Effort Sliders & Waveshaping function. These 6 assignments are moved to function "applyGainSignalSlot" because the interface has to be reloaded when loading a different motion file
#QtCore.QObject.connect(self.ui.weightSlider, QtCore.SIGNAL("valueChanged(int)"), self.weightChange)
#QtCore.QObject.connect(self.ui.timeSlider, QtCore.SIGNAL("valueChanged(int)"), self.timeChange)
#QtCore.QObject.connect(self.ui.spaceSlider, QtCore.SIGNAL("valueChanged(int)"), self.spaceChange)
#QtCore.QObject.connect(self.ui.flowSlider, QtCore.SIGNAL("valueChanged(int)"), self.flowChange)
#QtCore.QObject.connect(self.ui.expEdit, QtCore.SIGNAL("returnPressed()"), self.evaluateExp)
#QtCore.QObject.connect(self.ui.expButton, QtCore.SIGNAL("released()"), self.applyWaveshape)
###CB1.3.2 --- Assign action to Waveshaping2 combobox
QtCore.QObject.connect(self.ui.pointSelector, QtCore.SIGNAL("currentIndexChanged(int)"), self.setPointSlider)
###CB1.3.3a --- Assign action to Waveshaping2 sliderbar: change point value
QtCore.QObject.connect(self.ui.pointSlider, QtCore.SIGNAL("valueChanged(int)"), self.pointChange)
###CB1.3.3b --- Assign action to Waveshaping2 sliderbar: change the value showing in the lineedit
QtCore.QObject.connect(self.ui.pointSlider, QtCore.SIGNAL("valueChanged(int)"), self.pointLineEditChange)
###CB1.3.4 --- Assign action to Waveshaping2 button: apply waveshape to motion signal
QtCore.QObject.connect(self.ui.pointButton, QtCore.SIGNAL("released()"), self.applyWaveshape2)
###CB1.3.5 --- Assign action to the self.ui.runbutton
QtCore.QObject.connect(self.ui.runbutton, QtCore.SIGNAL("released()"), self.runData)
###CB1.3.6 --- Assign action to the Toolbar Run button
QtCore.QObject.connect(self.ui.run, QtCore.SIGNAL("triggered()"), self.runData)
###CB1.3.7 --- Assign action to the Toolbar Exit button
self.connect(self.ui.exit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()"))
###CB1.3.8 --- Assign action to Clear Dialogue button
QtCore.QObject.connect(self.ui.pushButtonDialogueClear, QtCore.SIGNAL("clicked()"), self.ui.lineEditUserDialogue, QtCore.SLOT("clear()"))
###CB1.3.9 --- Assign action to OK Dialogue button
QtCore.QObject.connect(self.ui.pushButtonDialogueOK, QtCore.SIGNAL("clicked()"), self.talkToRobot)
###CB1.3.10 --- Assign action to User Input Field/Line
QtCore.QObject.connect(self.ui.lineEditUserDialogue, QtCore.SIGNAL("returnPressed()"), self.talkToRobot)
###CB1.3.11 --- Assign action to Execute selected motion
QtCore.QObject.connect(self.ui.pushButtonMotion, QtCore.SIGNAL("clicked()"), self.runMotion)
###CB1.4 --- Load song list from folder
self.songs = glob.glob("/home/msunardi/Music/*.mp3")
###CB1.5 --- Load the motion data
#self.loadData(self.currentMotion)
###CB1.6 --- Try to load the Dialogue module
#### The Dialogue module may sometime not able to load because of competing soundcard usage by other OS components. Still need to figure this one out.
try:
self.dialogue = Dialogue()
except:
print "No dialogue this time..."
###CB1.7 --- Populate the Motion List combobox (KHR1 memory)
self.populateMotionBox()
###CB1.8 --- Populate the Music/Song List combobox
self.populateMusicBox()
###CB1.9 --- Populate the Motion Signal combobox
self.populateSignalBox(self.motionFilePath)
self.loadData(self.ui.comboBoxMotionSignal.currentText()) # <<< Load the first motion data to plot
###CB1.10 --- Set up the timer for HeartBeat simulator
self.timer = QtCore.QBasicTimer() # <<< CREATE QBasicTimer object
self.timer.start(self.heartrate, self.ui.ecg) # <<< START QBasicTimer(interval (ms), QObject)
#self.x = QtGui.QTextEdit(self.ui)
#test:
#self.ui.qwtPlot.addCurve(range(0,200,1))
#self.ui.qwtPlot.addCurve(range(0,200,1))
#works!
##CB2 --- create class' global variables
def setVariables(self):
self.freqBands = [] # <<< For frequency bands
self.allData = [] # <<< For loaded motion data
self.newData = [] # <<< For processed motion data
self.bandAdjusters = [] # <<< For values of band adjustments
self.ms = MotionSynthesizer() # <<< Create instance of MotionSynthesizer
self.heartrate = 30 # <<< Default heartrate value
self.khr1device = "/dev/ttyUSB0" # <<< Default serial output to KHR1
self.emote_parameters = {"weight": 0,"time": 0,"space": 0,"flow": 0} # <<< For EMOTE parameters
#.........这里部分代码省略.........
示例10: MyForm
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.emote_parameters = {"weight": 0, "time": 0, "space": 0, "flow": 0}
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setVariables()
#QtCore.QObject.connect(self.ui.weightSlider, QtCore.SIGNAL("valueChanged(int)"), self.weightChange)
#QtCore.QObject.connect(self.ui.timeSlider, QtCore.SIGNAL("valueChanged(int)"), self.timeChange)
#QtCore.QObject.connect(self.ui.spaceSlider, QtCore.SIGNAL("valueChanged(int)"), self.spaceChange)
#QtCore.QObject.connect(self.ui.flowSlider, QtCore.SIGNAL("valueChanged(int)"), self.flowChange)
#QtCore.QObject.connect(self.ui.expEdit, QtCore.SIGNAL("returnPressed()"), self.evaluateExp)
#QtCore.QObject.connect(self.ui.expButton, QtCore.SIGNAL("released()"), self.applyWaveshape)
# === Apply action to the self.ui.runbutton
QtCore.QObject.connect(self.ui.runbutton, QtCore.SIGNAL("released()"), self.runData)
QtCore.QObject.connect(self.ui.run, QtCore.SIGNAL("triggered()"), self.runData)
self.connect(self.ui.exit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueClear, QtCore.SIGNAL("clicked()"), self.ui.lineEditUserDialogue, QtCore.SLOT("clear()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueOK, QtCore.SIGNAL("clicked()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.lineEditUserDialogue, QtCore.SIGNAL("returnPressed()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.pushButtonMotion, QtCore.SIGNAL("clicked()"), self.runMotion)
self.loadData()
self.dialogue = Dialogue()
self.dialogueInit = True
self.dialogueContext = {"action": "", "topic": "", "username": "", "botname": "", "it": "", "usermood": "", "personality": ""}
self.populateMotionBox()
#self.x = QtGui.QTextEdit(self.ui)
#test:
#self.ui.qwtPlot.addCurve(range(0,200,1))
#self.ui.qwtPlot.addCurve(range(0,200,1))
#works!
def setVariables(self):
self.freqBands = []
self.allData = []
self.newData = []
self.bandAdjusters = []
self.ms = MotionSynthesizer()
#self.khr1 = khr1Interface("/dev/ttyUSB0")
def populateMotionBox(self):
list = []
for i in range(40):
list.append(str(i))
self.ui.comboBoxMotion.addItems(list)
def weightChange(self, value):
self.ui.weightLineEdit.setText(str(value))
self.emote_parameters["weight"] = value
self.ui.statusbar.showMessage("Weight value changed to "+ str(self.emote_parameters["weight"]))
#self.ui.qwtPlot.changeCurve(0, range(0, 2*self.emote_parameters["weight"], 1))
length = len(self.ui.gainSliders)
index = int(len(self.ui.gainSliders)/2)
print "index = ", index
self.ui.gainSliders[index].setSliderPosition(self.ui.gainSliders[index].value() - value)
self.ui.gainSliders[length-1].setSliderPosition(self.ui.gainSliders[length-1].value() + int(value*0.7))
def timeChange(self, value):
self.ui.timeLineEdit.setText(str(value))
self.emote_parameters["time"] = value
self.ui.statusbar.showMessage("Time value changed to "+ str(self.emote_parameters["time"]))
#self.ui.qwtPlot.changeCurve(1, range(0, 2*self.emote_parameters["weight"], 1))
def spaceChange(self, value):
self.ui.spaceLineEdit.setText(str(value))
self.emote_parameters["space"] = value
self.ui.statusbar.showMessage("Space value changed to "+ str(self.emote_parameters["space"]))
#self.ui.addGainSliders(self.emote_parameters["weight"])
#print type(self.ui.gainSliders[0])
def flowChange(self, value):
self.ui.flowLineEdit.setText(str(value))
self.emote_parameters["flow"] = value
self.ui.statusbar.showMessage("Flow value changed to "+ str(self.emote_parameters["flow"]))
self.ui.gainSliders[0].setSliderPosition(self.ui.gainSliders[0].value() - int(value*1.7))
def applyGainSignalSlot(self, how_many):
self.ui.addGainSliders(how_many)
QtCore.QObject.connect(self.ui.weightSlider, QtCore.SIGNAL("valueChanged(int)"), self.weightChange)
QtCore.QObject.connect(self.ui.timeSlider, QtCore.SIGNAL("valueChanged(int)"), self.timeChange)
QtCore.QObject.connect(self.ui.spaceSlider, QtCore.SIGNAL("valueChanged(int)"), self.spaceChange)
QtCore.QObject.connect(self.ui.flowSlider, QtCore.SIGNAL("valueChanged(int)"), self.flowChange)
QtCore.QObject.connect(self.ui.expEdit, QtCore.SIGNAL("returnPressed()"), self.evaluateExp)
QtCore.QObject.connect(self.ui.expButton, QtCore.SIGNAL("released()"), self.applyWaveshape)
print "gain sliders: "+str(how_many)
# === Apply action to each self.ui.gainSliders
for gs in self.ui.gainSliders:
QtCore.QObject.connect(gs, QtCore.SIGNAL("valueChanged(int)"), self.adjustGain)
#.........这里部分代码省略.........
示例11: MyForm
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setVariables()
self.ui.populateChannelList()
self.setActions()
self.motionPath = self.loadMotionFiles()
self.formatMotionList(self.motionPath)
self.ui.populateKhr1MotionBox()
#self.ui.populateMotionBox(self.formatMotionList(self.motionSignalPath))
self.ui.populateMotionBox([k for k,v in self.motionSignalPath.items()])
#self.loadData(self.motionSignalPath[self.ui.motionComboBox.currentIndex()])
print self.ui.motionComboBox.currentText()
#self.loadData(self.motionSignalPath[self.ui.motionComboBox.currentText()])
self.loadData(dataIndex=self.ui.motionComboBox.currentText())
def setVariables(self):
# Containers...
self.motionPath = [] # list of path to .csv files loaded using glob
self.motionSignalPath = {} # dictionary of path to .csv files indexed by file name
self.CURRENT_MOTION_DATA = [] # container for current loaded motion data from file
self.CURRENT_INTERP_MOTION_DATA = [] # container for current interpolated motion data
self.OUTPUT_DATA = []
self.SCRIPT = []
self.chatoptions = {}
# Parameters...
self.interpParameters = {'tension': 0, 'bias': 0, 'continuity': 0} # interpolation parameters
self.affectProcessing = False
# Constants...
self.defaultMotionPath = "/home/msunardi/Documents/thesis-stuff/KHR-1-motions/"
self.khr1Device = "/dev/ttyUSB0"
scriptpath = 'scripts/script1.csv'
# Class instances...
self.ms = MotionSynthesizer()
try:
self.dialogue = Dialogue()
except:
print "No dialogue this time..."
try:
self.lcontext = locoContext()
except:
print "No lococontext this time..."
try:
rs = readScript()
self.SCRIPT = rs.read(scriptpath)
print "Script: %s is loaded." % scriptpath
self.scriptindex=0
except:
print "Failed loading Script."
def setActions(self):
print "setActions"
self.setActionsChannelsCheckBox()
self.setActionsAffectProcessingCheckBox()
self.setActionsMotionControls()
self.setActionsMotionFile()
self.setTabActions()
self.setToolbarActions()
self.setActionsRobotState()
self.setActionsChatUI()
def setActionsChatUI(self):
QtCore.QObject.connect(self.ui.chatInputClearButton, QtCore.SIGNAL("clicked()"), self.ui.chatInput, QtCore.SLOT("clear()"))
QtCore.QObject.connect(self.ui.chatInputEnterButton, QtCore.SIGNAL("clicked()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.chatInput, QtCore.SIGNAL("returnPressed()"), self.talkToRobot)
QtCore.QObject.connect(self.ui.chatContextCheckbox, QtCore.SIGNAL("stateChanged(int)"), self.toggleChatContextVisible)
def setActionsRobotState(self):
QtCore.QObject.connect(self.ui.stateShowCheckBox, QtCore.SIGNAL("stateChanged(int)"), self.toggleStateVisible)
def setToolbarActions(self):
self.connect(self.ui.exit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()"))
def setTabActions(self):
self.resetParameters()
self.setActionsInterpolation()
self.setActionsResampling()
self.setActionsMultiresfiltering()
def setActionsGainSliders(self):
print "setting actions for gain sliders and line edits...",
for gs in self.ui.gainSliders:
QtCore.QObject.connect(gs, QtCore.SIGNAL("valueChanged(int)"), self.adjustGain)
#.........这里部分代码省略.........
示例12: MyForm
class MyForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.emote_parameters = {"weight": 0, "time": 0, "space": 0, "flow": 0}
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setVariables()
QtCore.QObject.connect(self.ui.weightSlider, QtCore.SIGNAL("valueChanged(int)"), self.weightChange)
QtCore.QObject.connect(self.ui.timeSlider, QtCore.SIGNAL("valueChanged(int)"), self.timeChange)
QtCore.QObject.connect(self.ui.spaceSlider, QtCore.SIGNAL("valueChanged(int)"), self.spaceChange)
QtCore.QObject.connect(self.ui.flowSlider, QtCore.SIGNAL("valueChanged(int)"), self.flowChange)
QtCore.QObject.connect(self.ui.expEdit, QtCore.SIGNAL("returnPressed()"), self.evaluateExp)
QtCore.QObject.connect(self.ui.expButton, QtCore.SIGNAL("released()"), self.applyWaveshape)
# === Apply action to the self.ui.runbutton
QtCore.QObject.connect(self.ui.runbutton, QtCore.SIGNAL("released()"), self.runData)
QtCore.QObject.connect(self.ui.run, QtCore.SIGNAL("triggered()"), self.runData)
self.connect(self.ui.exit, QtCore.SIGNAL("triggered()"), QtCore.SLOT("close()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueClear, QtCore.SIGNAL("clicked()"), self.ui.lineEditUserDialogue, QtCore.SLOT("clear()"))
QtCore.QObject.connect(self.ui.pushButtonDialogueOK, QtCore.SIGNAL("clicked()"), self.talkToRobot)
self.loadData()
self.dialogue = Dialogue()
#self.x = QtGui.QTextEdit(self.ui)
#test:
#self.ui.qwtPlot.addCurve(range(0,200,1))
#self.ui.qwtPlot.addCurve(range(0,200,1))
#works!
def setVariables(self):
self.freqBands = []
self.allData = []
self.newData = []
self.bandAdjusters = []
self.ms = MotionSynthesizer()
#self.khr1 = khr1Interface("/dev/ttyUSB0")
def weightChange(self, value):
self.ui.weightLineEdit.setText(str(value))
self.emote_parameters["weight"] = value
self.ui.statusbar.showMessage("Weight value changed to "+ str(self.emote_parameters["weight"]))
#self.ui.qwtPlot.changeCurve(0, range(0, 2*self.emote_parameters["weight"], 1))
length = len(self.ui.gainSliders)
index = int(len(self.ui.gainSliders)/2)
print "index = ", index
self.ui.gainSliders[index].setSliderPosition(self.ui.gainSliders[index].value() - value)
self.ui.gainSliders[length-1].setSliderPosition(self.ui.gainSliders[length-1].value() + int(value*0.7))
def timeChange(self, value):
self.ui.timeLineEdit.setText(str(value))
self.emote_parameters["time"] = value
self.ui.statusbar.showMessage("Time value changed to "+ str(self.emote_parameters["time"]))
#self.ui.qwtPlot.changeCurve(1, range(0, 2*self.emote_parameters["weight"], 1))
def spaceChange(self, value):
self.ui.spaceLineEdit.setText(str(value))
self.emote_parameters["space"] = value
self.ui.statusbar.showMessage("Space value changed to "+ str(self.emote_parameters["space"]))
#self.ui.addGainSliders(self.emote_parameters["weight"])
#print type(self.ui.gainSliders[0])
def flowChange(self, value):
self.ui.flowLineEdit.setText(str(value))
self.emote_parameters["flow"] = value
self.ui.statusbar.showMessage("Flow value changed to "+ str(self.emote_parameters["flow"]))
self.ui.gainSliders[0].setSliderPosition(self.ui.gainSliders[0].value() - int(value*1.7))
def applyGainSignalSlot(self, how_many):
self.ui.addGainSliders(how_many)
print "gain sliders: "+str(how_many)
# === Apply action to each self.ui.gainSliders
for gs in self.ui.gainSliders:
QtCore.QObject.connect(gs, QtCore.SIGNAL("valueChanged(int)"), self.adjustGain)
for gle in self.ui.gainLineEdits:
#QtCore.QObject.connect(gle, QtCore.SIGNAL("valueChanged(double)"), self.setSliderValue) # use new_ui3_copy3 for this
QtCore.QObject.connect(gle, QtCore.SIGNAL("returnPressed()"), self.setSliderValue)
def mapGains(self, how_many):
for i in range(how_many):
self.bandAdjusters.append(self.adjustGain())
print self.bandAdjusters
#====== SIGNAL SECTION
def setSliderValue(self, value):
index = int(self.sender().accessibleName())
#self.ui.gainSliders[index].setSliderPosition(int(value))
self.ui.gainSliders[index].setSliderPosition(int(value))
def adjustGain(self, value):
#.........这里部分代码省略.........