Skip to content

Commit

Permalink
#262. WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Raa37 committed Mar 23, 2023
1 parent c184ffa commit 40a53a6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 13 deletions.
49 changes: 39 additions & 10 deletions Connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def __init__(self):
) for i in range(1, len(self.getActiveRealDotbots())+1)
])

self.maxLength = 7

def getActiveRealDotbots(self):
# Set the base URL for the API
base_url = "http://localhost:8000"
Expand All @@ -38,11 +40,31 @@ def getActiveRealDotbots(self):
return response.json()

def computeRealCoordinates(self, virtualX, virtualY):
return ((virtualX)/self.scale, (virtualY)/self.scale)

# compute realX
if virtualX <= 1:
realX = 0
elif virtualX >= (self.maxLength-1):
realX = 1
else:
realX = virtualX/(self.maxLength-1)

# compute realY
if virtualY <= 1:
realY = 0
elif virtualY >= (self.maxLength-1):
realY = 1
else:
realY = virtualY/(self.maxLength-1)

print('virtual coordinates', virtualX, virtualY, '-> real coordinates', realX, realY)
return (realX, realY)

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

(virtualX, virtualY) = (realX*(self.maxLength-1), realY*(self.maxLength-1))
print('real coordinates', realX, realY, '-> virtual coordinates', virtualX, virtualY)
return (virtualX, virtualY)

def getRealPositions(self):
dotBots = self.getActiveRealDotbots()
Expand All @@ -59,11 +81,16 @@ def moveRawRealDotbot(self, address, x, y):
endpoint = '/controller/dotbots/{address}/0/waypoints'.format(address = address)

# Set the data for the new user
data = [{
"x": x,
"y": y,
"z": 0,
}]
data = {
"threshold": 40,
"waypoints": [
{
"x": x,
"y": y,
"z": 0
}
]
}

try:
# Make the POST request to the endpoint
Expand All @@ -75,6 +102,7 @@ def moveRawRealDotbot(self, address, x, y):
print(response.json())
else:
print("An error occurred:", response.status_code)
print('***')
except:
pass

Expand Down Expand Up @@ -116,8 +144,9 @@ def setNextRealDotBotMovement(self, dotBotId):
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):
break

if (nextX-0.1 <= realX<= nextX+0.1) and (nextY-0.1 <= realY <= nextY+0.1):
print('DotBot arrived')
break

Expand Down
6 changes: 3 additions & 3 deletions configs/razanne.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[atlas]
numRobots = 10
floorplan = "office_small" # filename in floorplans
numRobots = 1
floorplan = "square" # filename in floorplans
navigationAlgorithm = "Atlas" # options: Atlas, Ballistic
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 = 'off' # on if connector to real DotBots in watnted, else off
connector = 'on' # on if connector to real DotBots in watnted, else off

7 changes: 7 additions & 0 deletions floorplans/square.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#######
#.....#
#..s..#
#.....#
#.....#
#.....#
#######

0 comments on commit 40a53a6

Please sign in to comment.