Skip to content

Commit

Permalink
Merge pull request #15 from NUIG-ROCSAFE/cleanupDirectoryStructure
Browse files Browse the repository at this point in the history
updated file path in bastch scripts and routes generation codde
  • Loading branch information
David Smyth authored Sep 24, 2018
2 parents e7caa11 + 49f28e1 commit 874b3b5
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 925 deletions.
6 changes: 3 additions & 3 deletions BatchScripts/one_drone.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cd ..
set base_dir=%cd%

cd ./PythonCode/PythonClientGPSMapping/GPSMappings/Images/Images1/Camera1
del *.png
cd ./RAVCollectedData/PNGImages/
del /F /S *.png

cd %base_dir%

cd ./PythonCode/PythonGridMapping/AirSimPythonClient
cd ./PythonCode/Routing/AirSimPythonClient/RAVExecuteRoutes
start python rav_zero_mapper.py
42 changes: 20 additions & 22 deletions Config/config.ini
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
[JAVA]
JavaBinLoc = /JavaRuntime/jre1.8.0_171/bin/
JavaCodeLoc = /JavaCode/
JavaMissionDesignerJar = MissionPlanner.jar
JavaBinLoc = /JavaRuntime/jre1.8.0_171/bin
JavaCodeLoc = /JavaCode
JavaMissionDesignerJar = /MissionPlanner.jar

[BLOG]
BlogBinLoc = /BlogRuntime/bin/
BlogCodeLoc = /BlogScripts/
BlogProgName = ChemicalProbablisticReasoning.blog
BlogBinLoc = /BlogRuntime/bin
BlogCodeLoc = /BlogScripts
BlogProgName = /ChemicalProbablisticReasoning.blog

[PYTHON]
PythonDocRetrievalCodeLoc = /SOPRanking/RocsafeCode/Demo-IR/
PythonRAVRouteExecutionDir = /PythonCode/Routing/AirSimPythonClient/RAVExecuteRoutes/
PythonElasticMain = elasticMain.py
PythonGenerateRouteDir = /PythonCode/Routing/RouteGeneration/
PythonGenerateRoutesFileLoc = generateRoutesForUnreal.py
PythonDocRetrievalCodeLoc = /SOPRanking/RocsafeCode/Demo-IR
PythonRAVRouteExecutionDir = /PythonCode/Routing/AirSimPythonClient/RAVExecuteRoutes
PythonElasticMain = /elasticMain.py
PythonGenerateRouteDir = /PythonCode/Routing/RouteGeneration
PythonGenerateRoutesFileLoc = /generateRoutesForUnreal.py

[BATCHSCRIPTS]
BatchScriptsLoc = /BatchScripts/
BatchScriptsLoc = /BatchScripts

[DATA]
RAVGPSRoutesDir = /RCode/ShinyApp/Data/
CollectedPNGImagesDir = /RAVCollectedData/PNGImages/
RAVRecordedGPSWaypoints = /RAVCollectedData/GPSCoords/
RAVPlannedWaypointsFile = gridPoints.csv
UIImagesDir = RCode/ShinyApp/Data/Images/
MostRecentProcessImageFileLoc = mostRecentImageProcessed.jpg
MostRecentImageRawFileLoc = mostRecentImageProcessed.jpg
PlannedAgentRoutesDir = /RAVPlannedRoutes/


RAVGPSRoutesDir = /RCode/ShinyApp/Data
CollectedPNGImagesDir = /RAVCollectedData/PNGImages
RAVRecordedGPSWaypoints = /RAVCollectedData/GPSCoords
RAVPlannedWaypointsFile = /gridPoints.csv
UIImagesDir = /RCode/ShinyApp/Data/Images
MostRecentProcessImageFileLoc = /mostRecentImageProcessed.jpg
MostRecentImageRawFileLoc = /mostRecentImageProcessed.jpg
PlannedAgentRoutesDir = /RAVPlannedRoutes
4 changes: 2 additions & 2 deletions PythonCode/Routing/AirSimPythonClient/AirSimClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import re

sys.path.append("./GPSMappings")
from GPSMappings.GPSCoordinate import GPSCoordinate
from GPSMappings.GPS import GPSToUnreal
from GPS.GPSCoordinate import GPSCoordinate
from GPS.GPSToUnreal import GPSToUnreal


class MsgpackMixin:
Expand Down
2 changes: 1 addition & 1 deletion PythonCode/Routing/AirSimPythonClient/GPS/GPSToUnreal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from GPSCoordinate import GPSCoordinate
from .GPSCoordinate import GPSCoordinate

class GPSToUnreal:
# this is taken as origin (0,0)
Expand Down
1 change: 0 additions & 1 deletion PythonCode/Routing/AirSimPythonClient/GPS/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
from GPSCoordinate import GPSCoordinate
__all__ = ['RAVGPSMapper', 'GPSCoordinate']
1,153 changes: 264 additions & 889 deletions PythonCode/Routing/AirSimPythonClient/RAVExecuteRoutes/rav_zero_mapper.py

Large diffs are not rendered by default.

32 changes: 25 additions & 7 deletions PythonCode/Routing/RouteGeneration/generateRoutesForUnreal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
def get_config() -> configparser.ConfigParser:
config = configparser.ConfigParser()
#read the global default config
config.read(os.getcwd().replace("\\", "/") + '/../../../Config/config.ini')
config.read(os.getcwd().replace("\\", "/") + '/../../../../Config/config.ini')
print("Read config file from here: {}".format(os.getcwd().replace("\\", "/") + '/../../../../Config/config.ini'))
return config

def create_folders_if_dont_exist():
'''If default folders don't exist, create them'''
pass


def main(no_ravs, no_cameras = 1, rav_velocity = 4, rav_altitude = 35, RAV_route_execution_dir = "", RAV_recorded_GPS_waypoints="", saved_images_dir=""):
Expand All @@ -17,7 +22,7 @@ def main(no_ravs, no_cameras = 1, rav_velocity = 4, rav_altitude = 35, RAV_route
print("Generating routes for ", no_ravs, " ravs")
base_dir = os.path.abspath(__file__).split('PythonCode')[0].replace('\\', '/')
#READ DEFAULTS
RAVGPSRoutesDir = base_dir + config["DATA"]["RAVGPSRoutesDir"]
RAVGPSRoutesDir = base_dir + config["DATA"]["PlannedAgentRoutesDir"]
if saved_images_dir == "":
#saved_images_dir = base_dir + "/PythonCode/PythonClientGPSMapping/GPSMappings/Images"
saved_images_dir = base_dir + config["DATA"]["CollectedPNGImagesDir"]
Expand All @@ -40,15 +45,28 @@ def main(no_ravs, no_cameras = 1, rav_velocity = 4, rav_altitude = 35, RAV_route
print('Directory {} does not exist, creating in default location'.format(saved_images_dir))
os.makedirs(RAV_recorded_GPS_waypoints)

if not os.path.exists(RAV_recorded_GPS_waypoints):
if not os.path.isdir(RAV_recorded_GPS_waypoints):
print('Directory {} does not exist, creating in default location'.format(RAV_recorded_GPS_waypoints))
os.makedirs(RAV_recorded_GPS_waypoints)

#create images directory
for rav_no in range(int(no_ravs)):
if not os.path.isdir(saved_images_dir + '/ImagesRAV%d' % (rav_no + 1)):
os.makedirs(saved_images_dir + '/ImagesRAV%d' % (rav_no + 1))
for camera_no in range(int(no_cameras)):
if not os.path.isdir(saved_images_dir + '/ImagesRAV%d' % (rav_no + 1) + '/Camera{}'.format(camera_no+1)):
print('Directory {} does not exist, creating in default location'.format(saved_images_dir + '/ImagesRAV%d' % (rav_no + 1) + '/Camera{}'.format(camera_no+1)))
os.makedirs(saved_images_dir + '/ImagesRAV%d' % (rav_no + 1) + '/Camera{}'.format(camera_no+1))

for rav_no in range(int(no_ravs)):
if not os.path.exists(saved_images_dir + 'ImagesRAV%d/' % (rav_no + 1)):
os.makedirs(saved_images_dir + '/ImagesRAV%d/' % (rav_no + 1))
#set default directories if not provided. Assume that directory layout is that specified in IJCAIDemoCode
python_code = generate_route_text(rav_no+1, open(RAVGPSRoutesDir+"Agent{}.csv".format(rav_no+1)).read()[15:], RAV_recorded_GPS_waypoints, saved_images_dir, no_cameras, rav_velocity=rav_velocity, rav_altitude = rav_altitude, images=True, sleep_time = 2, gps_locations=True)

#set default directories if not provided. Assume that directory layout is that specified in IJCAIDemoCode
#[15:] due to lat, long, alt header
assert ''.join(open(RAVGPSRoutesDir+"/Agent{}.csv".format(rav_no+1)).readlines()[1:]) == open(RAVGPSRoutesDir+"/Agent{}.csv".format(rav_no+1)).read()[15:]
#drone_number, gps_coords, gps_coords_file_dir, saved_images_dir, no_cameras = 1, rav_velocity = 5, rav_altitude = 35, sleep_time = 0.5, images: #bool = True, gps_locations: bool=True
python_code = generate_route_text(rav_no+1, ''.join(open(RAVGPSRoutesDir+"/Agent{}.csv".format(rav_no+1)).readlines()[1:]), RAV_recorded_GPS_waypoints,saved_images_dir, no_cameras, rav_velocity = rav_velocity, rav_altitude=rav_altitude, sleep_time=2, images=True, gps_locations=True)

#python_code = generate_route_text(rav_no+1, open(RAVGPSRoutesDir+"/Agent{}.csv".format(rav_no+1)).read()[15:], RAV_recorded_GPS_waypoints, saved_images_dir, no_cameras, #rav_velocity, rav_altitude, images=True, sleep_time = 2, gps_locations=True)
#assume that directory layout is that specified in IJCAIDemoCode
rav_no_dict={1:'zero', 2:'one', 3: 'two', 4: 'three'}
save_python_to_file(python_code, RAV_route_execution_dir + "/rav_{}_mapper.py".format(rav_no_dict[rav_no+1]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def generate_route_text(drone_number, gps_coords, gps_coords_file_dir, saved_ima
return_txt = '''import io
import time
import os
import sys
#append folder level up to import AirSimClient
sys.path.append('..')
sys.path.append('../GPSMappings')
from PIL import Image
from AirSimClient import *
'''
Expand Down

0 comments on commit 874b3b5

Please sign in to comment.