I want to set up the problem properly and then highlight the issue I am having.
I have a series of people that need to be picked up by a busroute, and I see numerous capabilities to handle bus routes that I am not using as of yet. What I am doing now is I am visiting a RoadId or route segment near the person and when the vehicle arrives
the person will board and then the bus will change its Target to a new destination target to the next customer in the route.
at times this fails because the person is on a road segment that does Not allow vehicles to travel down, like local road/rural road/private road. I have gotten around this by writing a radius alternative algorithm using your api too discover a nearby road
that does allow vehicles. This works fine.
Occasionally when the vehicle arrives to a person's nearby location, the route ends on a dead-end route. In this case changeTarget does not turn the vehicle around, instead what may be an available destination is failed, as well as I am sure the original problem
which some of the edges are not allowing vehicle's may also be failing.
Simply, I have tried moveToXY as a way to re orient the vehicle at angle -= 180 degrees. This would seem to be needed a prerequisite to calling changeTarget. This is my current thinking and strategy. But somehow, I am calling movetoXY in manner that does
not work. It must be in lane_index, edge_id, angle, xv, yv values. I need to turn this vehicle around so a change Target can take it to the next customer.
Lastly, is there a way to check if an edge allows vehicle or not, and potentially can that be changed.
tmp = traci.simulation.convertRoad( XcnvTry, YcnvTry )
destEdgeId = tmp[0]
lane_index = tmp[2]
nptabu = np.array(tabu)
stateNotTabu = StateNotInTabu([destEdgeId], nptabu)
if stateNotTabu:
tabu.append([destEdgeId])
print('Size of Tabu List:', len(tabu))
try:
traci.vehicle.changeTarget(prid, destEdgeId )
#done = True
headingToX = XcnvTry
headingToY = YcnvTry
initialChampionFound = True
dtry = distEuclid( XcnvTry, YcnvTry, XCustcnv, YCustcnv )
if dtry < chDfrmOrig:
chEdgeId = destEdgeId
chDfrmOrig = dtry
chXtry = XcnvTry
chYtry = YcnvTry
print( "NEW CHAMPION - Base Radius stRadius:", stRadius ," cnt:", cnt, " ch:", chDfrmOrig, chXtry , chYtry )
if circularMove:
break
except:
pass
return chEdgeId, chXtry, chYtry, cnt
Could not make Bold work:
# route_id = traci.vehicle.getRouteID(prid)
# edge_id = traci.vehicle.getRoadID(prid)
# lane_index = traci.vehicle.getLaneIndex(prid)
# position = traci.vehicle.getPosition(prid)
# xv = tuple(position)[0]
# yv = tuple(position)[1]
# angle = traci.vehicle.getAngle(prid)
# angle -= 180.0
#
# fndMinus = edge_id.find('-')
# if fndMinus >= 0:
# edge_id = edge_id[1:]
# else:
# edge_id = '-' + edge_id
#
# traci.vehicle.moveToXY(prid, edge_id, lane_index, xv + 50, yv + 50, angle, keepRoute=2)
# try:
# traci.vehicle.changeTarget(prid, destEdgeId)
# # done = True
# headingToX = XcnvTry
# headingToY = YcnvTry
# initialChampionFound = True
# dtry = distEuclid(XcnvTry, YcnvTry, XCustcnv, YCustcnv)
# if dtry < chDfrmOrig:
# chEdgeId = destEdgeId
|