Hello,
I have been trying to change the destination of an onboarded person in the taxi which was using the dispatchTaxi() but unable to do so and got the warning of teleporting the person. I am appending the code below of changing the person's destination written by me. Please review the code and help me to solve the issue.
Thanks,
Jay
def change_person_destination(person_id, new_lane):
try:
stage = traci.person.getStage(person_id)
if stage.type != traci.constants.STAGE_DRIVING:
print(f"[Skip] Person {person_id} is not in a driving stage.")
return
vehicle_id = traci.person.getVehicle(person_id)
current_edge = traci.person.getRoadID(person_id)
if not current_edge:
print(f"[Error] Could not get current road for {person_id}")
return
traci.person.removeStages(person_id)
traci.person.appendDrivingStage(person_id, new_lane, "taxi")
print(f"[Updated] Person {person_id}'s destination changed to lane {new_lane}")
except Exception as e:
print(f"[Error] Failed to change destination for {person_id}: {e}")