Beispiel #1
0
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 )
Beispiel #2
0
    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.")
Beispiel #3
0
  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." )
Beispiel #4
0
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 )
Beispiel #5
0
def systemShutdownActions():
  global myMessenger
  global extProcCall

  PyREEM.say( 'I am going off line. Goodbye.' )

  myMessenger.checkout()
  extProcCall.fini()
Beispiel #6
0
  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 )
Beispiel #7
0
    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)
Beispiel #8
0
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 )
Beispiel #9
0
  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!" )
Beispiel #10
0
    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!")
Beispiel #11
0
  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." )
Beispiel #12
0
    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.")
Beispiel #13
0
 def stopDataRecording( self ):
   if self.recording:
     self.killProc( self.recording )
     self.recording = None
     PyREEM.say( "Stopped data recording!" )
Beispiel #14
0
def userLogoff( name ):
  PyREEM.say( '%s has logged off.' % name )
  tinstate.updateStatus( constants.USER_PRESENT, len(PyREEM.listCurrentUsers()) == 0)
Beispiel #15
0
def userLogon( name ):
  PyREEM.say( '%s has logged on.' % name )
  tinstate.updateStatus( constants.USER_PRESENT, False )
Beispiel #16
0
 def stopDataRecording(self):
     if self.recording:
         self.killProc(self.recording)
         self.recording = None
         PyREEM.say("Stopped data recording!")