Created
March 11, 2020 07:10
-
-
Save AhsanSN/354630cab64e1ad0b25295006dcfcc5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json, os | |
from threading import Timer | |
currentBookingInfo = ""; | |
currentLocation = [1,1]; | |
def getNextBookingDetails(currentBookingId): | |
URL = "http://ventoms.com/anomoz/swift/post/read_new_booking.php?currentBookingId="+str(currentBookingId) | |
r = requests.get(url = URL) | |
# extracting data in json format | |
data = r.json() | |
info = (data[0]) | |
return info | |
def markBookingAsEnded(currentBookingId): | |
URL = "http://ventoms.com/anomoz/swift/post/mark_booking_as_ended.php?currentBookingId="+str(currentBookingId) | |
r = requests.get(url = URL) | |
return True | |
def getPickupLocation(currentBookingInfo): | |
print("getPickupLocation set: ", [currentBookingInfo["fromLocation_lat"], currentBookingInfo["fromLocation_lng"]]) | |
return([currentBookingInfo["fromLocation_lat"], currentBookingInfo["fromLocation_lng"]]) | |
def getFinalLocation(currentBookingInfo): | |
print("getFinalLocation set: ", [currentBookingInfo["toLocation_lat"], currentBookingInfo["toLocation_lng"]]) | |
return([currentBookingInfo["toLocation_lat"], currentBookingInfo["toLocation_lng"]]) | |
def startNavigator(currentLocation, destination): | |
programCommand = "rosrun simple_navigation_goals simple_navigation_goals _param_x:="+str(destination[0])+" _param_y:="+str(destination[1]) | |
if os.system(programCommand) == 0: | |
print("program finished successfully") | |
else: | |
print("launch failed") | |
def generateExe(): | |
if os.system("g++ -g foo.cpp -o foo") == 0: | |
print ("exe compiled") | |
else: | |
print ("exe compiling Failed") | |
def runSingleCycle(): | |
currentBookingInfo = getNextBookingDetails(0) | |
#currentBookingInfo = {'bookingId': '187', 'timeAdded': '1573634449', 'fromLocation': 'Auditorium', 'toLocation': 'Auditorium', 'fromPerson': 'Dr. taj', 'toPerson': 'Dddx', 'status': 'waiting', 'fromLocation_lat': '-9.656250', 'fromLocation_lng': '5.750000', 'toLocation_lat': '-9.656250', 'toLocation_lng': '5.750000'} | |
print("currentBookingInfo updated: ", currentBookingInfo) | |
#go to pickup location | |
pickupLocation = getPickupLocation(currentBookingInfo) | |
startNavigator(currentLocation, pickupLocation) #program stops until | |
#open lock for pickup | |
#to to destination | |
dropoffLocation = getFinalLocation(currentBookingInfo) | |
startNavigator(currentLocation, dropoffLocation) | |
#openlock for dropoff | |
#mark booking | |
markBookingAsEnded(currentBookingInfo['bookingId']) | |
return | |
def twoArgs(arg1,arg2): | |
print (arg1) | |
print ("") | |
def main(): | |
r = Timer(1.0, twoArgs, ("Ahsan Ahmed","arg2")) | |
r.start() | |
return 0 | |
#generateExe() | |
#runSingleCycle() | |
#get next booking Status | |
main() | |
Author
AhsanSN
commented
Mar 11, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment