Skip to content

Commit

Permalink
#262 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Raa37 committed Mar 9, 2023
1 parent e328358 commit a18e541
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 311 deletions.
403 changes: 113 additions & 290 deletions AtlasAnalysis.ipynb

Large diffs are not rendered by default.

39 changes: 27 additions & 12 deletions Connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class Connector():

def __init__(self):

self.scale = 3

self.realDotBotsView = dict([
(
i,
Expand All @@ -24,8 +26,6 @@ def __init__(self):
) for i in range(1, len(self.getActiveRealDotbots())+1)
])

print(self.realDotBotsView)

def getActiveRealDotbots(self):
# Set the base URL for the API
base_url = "http://localhost:8000"
Expand All @@ -37,16 +37,16 @@ def getActiveRealDotbots(self):

return response.json()

def getRealCoordinates(self, virtualX, virtualY):
return ((0.2*virtualX)/0.5, (0.2*virtualY)/0.5)
def computeRealCoordinates(self, virtualX, virtualY):
return ((virtualX)/self.scale, (virtualY)/self.scale)

def getVirtualCoordinates(self, realX, realY):
return ((0.5*realX)/0.2, (0.5*realY)/0.2)
def computeVirtualCoordinates(self, realX, realY):
print('real coordinates',realX, realY)
return (realX*self.scale, realY*self.scale)

def getRealInitialPositions(self):
def getRealPositions(self):
dotBots = self.getActiveRealDotbots()
print(dotBots)
return [self.getVirtualCoordinates(dotBot['position_history'][-1]['x'], dotBot['position_history'][-1]['y']) for dotBot in dotBots]
return [self.computeVirtualCoordinates(dotBot['position_history'][-1]['x'], dotBot['position_history'][-1]['y']) for dotBot in dotBots]


def moveRawRealDotbot(self, address, x, y):
Expand Down Expand Up @@ -105,8 +105,23 @@ def setNextRealDotBotMovement(self, dotBotId):
if dotBotToBumpDistance < dotBotToTargetDistance:
(nextX, nextY) = (self.realDotBotsView[dotBotId]['nextBumpX'], self.realDotBotsView[dotBotId]['nextBumpY'])


# scale positions
(scaledX, scaledY) = self.getRealCoordinates(nextX, nextY)
(scaledNextX, scaledNextY) = self.computeRealCoordinates(nextX, nextY)

print('target',nextX, nextY, 'scaled to reality is:', scaledNextX, scaledNextY)

#send API
while True:
self.moveRawRealDotbot(self.realDotBotsView[dotBotId]['address'], scaledNextX, scaledNextY)
(realX, realY) = self.getRealPositions()[dotBotId-1]
print(realX, realY, nextX, nextY)
print('here')
if (nextX-0.2 <= realX<= nextX+0.2) and (nextY-0.2 <= realY <= nextY+0.2):
print('DotBot arrived')
break





# send API
self.moveRawRealDotbot(self.realDotBotsView[dotBotId]['address'], scaledX, scaledY)
3 changes: 2 additions & 1 deletion DotBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def receive(self, frame):
self.nextBumpTime = self.simEngine.currentTime() + timetobump
log.debug(f'Dotbot {self.dotBotId} next bump at ({bumpX}, {bumpY}) at {self.nextBumpTime}')

if self.connector == 'on':
if self.connector:
print(self.dotBotId, self.nextBumpX , self.nextBumpY)
self.connector.updateNextBumpCoordinates(self.dotBotId, self.nextBumpX , self.nextBumpY)

if stopTime < self.nextBumpTime:
Expand Down
6 changes: 4 additions & 2 deletions Orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ def __init__(self, numRobots, orchX, orchY, initialPositions, relayAlgorithm="Re
self.dotBotsView[dotBotId]['heading'] = 360*random.random()
self.dotBotsView[dotBotId]['speed'] = 1
self.dotBotsView[dotBotId]['movementTimeout'] = 0.5
(nextX, nextY) = u.computeCurrentPosition(self.initialPositions[0][0], self.dotBotsView[dotBotId]['heading'],self.initialPositions[0][1], 1, 0.5)

if self.connector:
(nextX, nextY) = u.computeCurrentPosition(self.initialPositions[0][0], self.initialPositions[0][1],
self.dotBotsView[dotBotId]['heading'] , 1, 0.5)
self.connector.updateTargetCoordinates(dotBotId, (nextX, nextY))
#======================== public ==========================================

Expand Down Expand Up @@ -221,7 +223,7 @@ def _updateMovements(self):

log.debug('heading & movementTimeout for {} are {} {}'.format(dotBotId, heading, movementTimeout))

if self.connector == 'on':
if self.connector:
self.connector.updateTargetCoordinates(dotBotId, targetCell)

dotBot['targetCell'] = targetCell
Expand Down
4 changes: 2 additions & 2 deletions RunOneSim.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def runOneSim(simSetting, atlasUI=None):
# set initialPositions
if simSetting['connector'] == 'on':
connector = Connector.Connector()
initialPositions = connector.getRealInitialPositions()
print(initialPositions)
initialPositions = connector.getRealPositions()
print('initial positions in virtual values', initialPositions)
else:
initialPositions = [(orchX, orchY)]*simSetting['numRobots']

Expand Down
8 changes: 4 additions & 4 deletions configs/razanne.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[atlas]
numRobots = 1
floorplan = "tiny" # filename in floorplans
numRobots = 10
floorplan = "office_small" # filename in floorplans
navigationAlgorithm = "Atlas" # options: Atlas, Ballistic
relayAlgorithm = "NoRelays" # options: Recovery, SelfHealing, NoRelays
relayAlgorithm = "Recovery" # options: Recovery, SelfHealing, NoRelays
lowerPdrThreshold = 0.8 # (for Recovery) trigger relay placement if below
upperPdrThreshold = 0.9 # (for Recovery) to determine relay position
propagationModel = "PisterHack" # options: LOS, Friis, Radius, PisterHack
numberOfRuns = 1 # number of simulations runs with same simSetting
connector = 'on' # on if connector to real DotBots in watnted, else off
connector = 'off' # on if connector to real DotBots in watnted, else off

0 comments on commit a18e541

Please sign in to comment.