예제 #1
0
def collectData():

   UserEmails=[]
   username=raw_input("What is your username? ")
   password=raw_input("What is your password? ")

   try:
      savePath="/home/root/PlayersInfo"
      accountLocation= os.path.join(savePath, username+".txt")
      account=open(accountLocation, "r")
   except IOError:
      print "No Account like %s \nPlease run the program again with a correct username."% username
   else:
      if password in account.readline():
         NameOfPlayer=username.split("_")[0]+" "+username.split("_")[1]
         print("Welcome User of "+NameOfPlayer)
         UserEmails=account.next()
         UserEmails=UserEmails.split(":")
         del UserEmails[0]

         SETTINGS_FILE = "RTIMULib"

         s = RTIMU.Settings(SETTINGS_FILE)
         imu = RTIMU.RTIMU(s)

         if (not imu.IMUInit()):
             sys.exit(1)

         # this is a good time to set any fusion parameters

         imu.setSlerpPower(0.02)
         imu.setGyroEnable(True)
         imu.setAccelEnable(True)
         imu.setCompassEnable(True)

         poll_interval = imu.IMUGetPollInterval()

         print("Starting Data Collection, in 2 seconds")
         time.sleep(2)

         while True:
            if imu.IMURead():                                        
               data = imu.getIMUData()                               
               accel = data["accel"]                                
               force = math.sqrt(accel[0]**2+accel[1]**2+accel[2]**2)
               force=round(force,2)
               if force>10:                                          
                  print("Force: %f" % force)                         
                  notify(UserEmails,NameOfPlayer,force)                
               time.sleep(poll_interval*1.0/1000.0)                
예제 #2
0
    print("IMU Init Succeeded")

# this is a good time to set any fusion parameters

imu.setSlerpPower(0.02)
imu.setGyroEnable(True)
imu.setAccelEnable(True)
imu.setCompassEnable(True)

poll_interval = imu.IMUGetPollInterval()
print("Recommended Poll Interval: %dmS\n" % poll_interval)

answer="Y"
users=[]
playerName=raw_input("What is your player's name? ")

while answer=="Y":
   newUser=raw_input("Enter the email of the user: "******"Do you want to add another user? (Y/N):")
while True:
   if imu.IMURead():                                        
      data = imu.getIMUData()                               
      accel = data["accel"]                                
      force = math.sqrt(accel[0]**2+accel[1]**2+accel[2]**2)
      if force>10:                                          
         print("Force: %f" % force)                         
         notify(users,playerName,force)                
      time.sleep(poll_interval*1.0/1000.0)