def main(): global myMessenger, msgTryTimer global extProcCall, iksResolver global ipkSpawner extProcCall = extprocall.ProcConduit() iksResolver = iksresolver.IKSResolver() ipkSpawner = ipkspawner.IPKSpawner() PyREEM.onUserLogOn = userLogon PyREEM.onUserLogOff = userLogoff PyREEM.onTimer = timerActions PyREEM.onTimerLapsed = timerLapsedActions PyREEM.onRemoteCommand = remoteCommandActions PyREEM.onSystemShutdown = systemShutdownActions PyREEM.onPowerPluggedChange = powerPlugChangeActions PyREEM.onBatteryChargeChange = batteryChargeChangeActions PyREEM.onNodeStatusUpdate = nodeStatusUpdate myMessenger = messenger.Messenger() if not myMessenger.checkin(): msgTryTimer = PyREEM.addTimer( 10*60, -1, 10*60 ) PyREEM.say( constants.INTRO_TEXT ) PyREEM.setLowPowerThreshold( 20 )
def purgearchive(self): if len(self.archive) == 0: PyREEM.say("No archived message to be deleted.") return self.archive = [] tinstate.updateStatus(constants.ARCHIVE_MESSAGES, True) PyREEM.say("All archived message have been deleted.")
def purgearchive( self ): if len(self.archive) == 0: PyREEM.say( "No archived message to be deleted." ) return self.archive = [] tinstate.updateStatus( constants.ARCHIVE_MESSAGES, True ) PyREEM.say( "All archived message have been deleted." )
def batteryChargeChangeActions( batpc, isplugged, time_remain ): global myMessenger if batpc < 20 and not isplugged: PyREEM.say( "I'm low on battery, please put me back on main power." ) if myMessenger: myMessenger.updatestatus( "I have only %d percent battery power left!" % batpc )
def systemShutdownActions(): global myMessenger global extProcCall PyREEM.say( 'I am going off line. Goodbye.' ) myMessenger.checkout() extProcCall.fini()
def play( self ): if not self.action_finishes: print "still playing action '%s'" % self.name return if self.text: self.action_finishes = False PyREEM.say( text )
def play(self): if not self.action_finishes: print "still playing action '%s'" % self.name return if self.text: self.action_finishes = False PyREEM.say(text)
def powerPlugChangeActions( isplugged ): global myMessenger text = "" if isplugged: text = "I'm on main power." else: text = "I'm on battery power." PyREEM.say( text ) if myMessenger: myMessenger.updatestatus( text )
def startDataRecording( self, mode, filename = "" ): cmd = 'rosbag record -b 1024 ' str = '' if mode & constants.REC_CAM: #cmd = cmd + '-e "/(.*)_stereo/(left|right)/image_rect_color" ' cmd = cmd + '-e "/stereo/left/image" ' # record only one camera data str = '_cam' #if mode & constants.REC_KINECT: #cmd = cmd + '"/camera/rgb/image_rect_color" "/camera/depth_registered/image_rect" ' #str = '_kinect' if mode & constants.REC_SCAN: cmd = cmd + '-e "/scan$" -e "/hokuyo/LAS_01" ' str = str + '_laser' if mode & constants.REC_IMU: #temp disable for now. cmd = cmd + '"/mobile_base_controller/odom" ' str = str + '_imu' if mode & constants.REC_JOINTS: cmd = cmd + '"/joint_states" ' str = str + '_joint' if mode & constants.REC_TF: cmd = cmd + '"/tf" ' str = str + '_tf' if mode & constants.REC_SONAR: cmd = cmd + '"/sonar_torso" "/sonar_base" ' str = str + '_sonar' if mode & constants.REC_IR: cmd = cmd + '"/ir_base" ' str = str + '_ir' if filename == "": cmd = cmd + '--duration=1m --split -O %s/%s%s_data.bag' % \ (RECORDED_DATA_DIR, time.strftime( "%Y%m%d_%H%M", time.localtime()), str) else: cmd = cmd + '--duration=1m --split -O %s/%s.bag' % \ (RECORDED_DATA_DIR, filename) if self.recording: self.killProc( self.recording ) self.recording = self.spawnProc( cmd ) PyREEM.say( "Start data recording!" )
def startDataRecording(self, mode, filename=""): cmd = 'rosbag record -b 1024 ' str = '' if mode & constants.REC_CAM: #cmd = cmd + '-e "/(.*)_stereo/(left|right)/image_rect_color" ' cmd = cmd + '-e "/stereo/left/image" ' # record only one camera data str = '_cam' #if mode & constants.REC_KINECT: #cmd = cmd + '"/camera/rgb/image_rect_color" "/camera/depth_registered/image_rect" ' #str = '_kinect' if mode & constants.REC_SCAN: cmd = cmd + '-e "/scan$" -e "/hokuyo/LAS_01" ' str = str + '_laser' if mode & constants.REC_IMU: #temp disable for now. cmd = cmd + '"/mobile_base_controller/odom" ' str = str + '_imu' if mode & constants.REC_JOINTS: cmd = cmd + '"/joint_states" ' str = str + '_joint' if mode & constants.REC_TF: cmd = cmd + '"/tf" ' str = str + '_tf' if mode & constants.REC_SONAR: cmd = cmd + '"/sonar_torso" "/sonar_base" ' str = str + '_sonar' if mode & constants.REC_IR: cmd = cmd + '"/ir_base" ' str = str + '_ir' if filename == "": cmd = cmd + '--duration=1m --split -O %s/%s%s_data.bag' % \ (RECORDED_DATA_DIR, time.strftime( "%Y%m%d_%H%M", time.localtime()), str) else: cmd = cmd + '--duration=1m --split -O %s/%s.bag' % \ (RECORDED_DATA_DIR, filename) if self.recording: self.killProc(self.recording) self.recording = self.spawnProc(cmd) PyREEM.say("Start data recording!")
def announcemsg( self, mesgs ): if len( mesgs ) == 0: PyREEM.say( "There is no message to be announced" ) return curTime = time.localtime() for i in mesgs: if i.created_at.tm_yday == curTime.tm_yday: sayTime = time.strftime( "Message received at %H hour %M minute", i.created_at ) else: sayTime = time.strftime( "Message received at %H hour %M minute on %A %B %d", i.created_at ) if i.sender in self.useraliases: frmWho = "From %s," % self.useraliases[ i.sender ] else: frmWho = "From %s," % i.sender PyREEM.say( "%s %s %s" % (sayTime, frmWho, i.text) ) PyREEM.say( "Message announcement is complete." )
def announcemsg(self, mesgs): if len(mesgs) == 0: PyREEM.say("There is no message to be announced") return curTime = time.localtime() for i in mesgs: if i.created_at.tm_yday == curTime.tm_yday: sayTime = time.strftime( "Message received at %H hour %M minute", i.created_at) else: sayTime = time.strftime( "Message received at %H hour %M minute on %A %B %d", i.created_at) if i.sender in self.useraliases: frmWho = "From %s," % self.useraliases[i.sender] else: frmWho = "From %s," % i.sender PyREEM.say("%s %s %s" % (sayTime, frmWho, i.text)) PyREEM.say("Message announcement is complete.")
def stopDataRecording( self ): if self.recording: self.killProc( self.recording ) self.recording = None PyREEM.say( "Stopped data recording!" )
def userLogoff( name ): PyREEM.say( '%s has logged off.' % name ) tinstate.updateStatus( constants.USER_PRESENT, len(PyREEM.listCurrentUsers()) == 0)
def userLogon( name ): PyREEM.say( '%s has logged on.' % name ) tinstate.updateStatus( constants.USER_PRESENT, False )
def stopDataRecording(self): if self.recording: self.killProc(self.recording) self.recording = None PyREEM.say("Stopped data recording!")