Commit 90bae687 authored by Chanelle Lee's avatar Chanelle Lee
Browse files

Changed up so we read testparameters from a file now

parent b8f68d9a
......@@ -7,3 +7,4 @@
*.avi
*.sublime*
/Videos/*
!testParams.csv
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
......@@ -4,6 +4,7 @@ import vrep
import time
import numpy as np
import sys
import pandas as pd
from ePucks import EPuckSim
from myThreads import ControllerThread
......@@ -20,13 +21,10 @@ def main(numSims=10):
else:
logger.critical('Could not connect to streaming server')
time.sleep(5)
simNum = 0
paramNum = 0
params = {1: (0.18, 0.25), 2: (0.35, 0.37), 3: (0.53, 0.411),
4: (0.7, 0.43)}
for key, values in params.items():
paramNum = key
testParams = pd.read_csv('testParams.csv', index_col='id')
for paramNum in set(testParams_DF.index.values):
logger.info('Param num: {}'.format(paramNum))
simNum = 0
for i in range(0, numSims):
simNum += 1
logger.info('Sim num: {}'.format(simNum))
......@@ -36,7 +34,9 @@ def main(numSims=10):
logger.critical('Simulation not started! {}'.format(sretCode))
sys.exit('Could not start simulation {}'.format(sretCode))
time.sleep(5)
controllerJobs = start(paramNum, simNum, *values)
controllerJobs = start(paramNum, simNum,
testParams.iloc[paramNum]['sigma'],
testParams.iloc[paramNum]['alpha'])
try:
while any([p.isAlive() for p in controllerJobs]):
time.sleep(1)
......
......@@ -26,10 +26,12 @@ class StoppableThread(threading.Thread):
class ControllerThread(threading.Thread):
def __init__(self, name, ePuck):
def __init__(self, name, ePuck, paramNum, simNum):
super(ControllerThread, self).__init__()
self.daemon = True
self.ePuck = ePuck
self.paramNum = paramNum
self.simNum = simNum
self._stop_event = threading.Event()
self.setName(name)
......@@ -50,6 +52,11 @@ class ControllerThread(threading.Thread):
timestep = 0
try:
while not self.stopped() and retFlag is False:
if timestep > 2500:
retFlag = True
logger.warning('Forced stop for params {0} sim {1}'
''.format(self.paramNum, self.simNum))
break
retFlag = self.ePuck.controller()
self.ePuck.move()
if (timestep % 10) == 0:
......
id,sigma,alpha,note
1,0.37037046296296294,0.3751673855040233,Prob_q2
2,0.28028037467467465,0.33706893213176836,Prob_q2
3,0.18518528148148147,0.26225924792573907,Prob_q2
4,0.09509519319319319,0.1076178764617531,Prob_q2
5,0.37037046296296294,0.22721601881269943,mean
6,0.28028037467467465,0.17178190793707013,mean
7,0.18518528148148147,0.09934474874734342,mean
8,0.09509519319319319,0.028578442773621412,mean
9,0.7007007866866867,0.4332167551695548,Prob_q2
10,0.5255256150150149,0.4112799010849124,Prob_q2
11,0.35035044334334337,0.36829189775018634,Prob_q2
12,0.17517527167167168,0.25054960515517927,Prob_q2
13,0.7007007866866867,0.3397470481420163,mean
14,0.5255256150150149,0.29339455784636115,mean
15,0.35035044334334337,0.2161307268727058,mean
16,0.17517527167167168,0.09128004679371902,mean
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment