Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[sumo-user] Using TraCI to add a new vehicle into the simulation with included Person

Hi everyone,

SUMO Version: eclipse-sumo==1.15.0

I am trying to include a new vClass=bus into the simulation with some pedestrians already onboard. Thus far, I have been able to add new bus vehicles as well as new pedestrians into the simulation separately and have the new pedestrians enter the new bus to exit the simulation.

Below are the snippets of code used
For new bus:
traci.vehicle.add(vehID=f"specialBus_{vehBatchNumber}",routeID="Coach_3", typeID="v_2")
For new pedestrians:
traci.person.add(personID=f"bp_{passengerBatchNo}_{i}",edgeID="E0",pos="0", typeID="v_7")
traci.person.appendWalkingStage(personID=f"bp_{passengerBatchNo}_{i}",edges=random.choice(combinedRouteList), stopID="bs_1", arrivalPos=str(busstopID))
traci.person.appendDrivingStage(personID=f"bp_{passengerBatchNo}_{i}", toEdge="E71", lines=f"specialBus_{passengerBatchNo}")

The passengers would spawn at the specified edge, walk on several edges before going to the bus stop to take the newly added bus to exit the simulation. The typeID, routeID and stopID have all been previously defined in the corresponding config files. (rou.xml demand file and additionals file)

However, the issue I have been facing now is when attempting to spawn a new bus vehicle with pedestrians already inside the bus, I am unable to do so. The pedestrians spawned will stay on the originating edge and not move instead of spawning inside the new bus vehicle.

Below are the edited snippets of code used
For new bus:
traci.vehicle.add(vehID=f"specialBus_{vehBatchNumber}",routeID="Coach_3", typeID="v_2")
For new pedestrians:
traci.person.add(personID=f"bp_{passengerBatchNo}_{i}",edgeID="E0",pos="0", typeID="v_7")
traci.person.appendDrivingStage(personID=f"bp_{passengerBatchNo}_{i}", toEdge="E35", lines=f"specialBus_{passengerBatchNo}", stopID="bs_0")
traci.person.appendWalkingStage(personID=f"bp_{passengerBatchNo}_{i}",edges=random.choice(combinedRouteList), stopID="bs_1", arrivalPos=str(busstopID))
traci.person.appendDrivingStage(personID=f"bp_{passengerBatchNo}_{i}", toEdge="E71", lines=f"specialBus_{passengerBatchNo}")

The only change I made to the snippet is including the driving stage with the specific bus to take. I am also aware that for traci.vehicle.add(), there is another parameter that can be added called "personNumber". Would this perhaps be the correct way to go about solving this issue?


I am currently able to spawn in new bus vehicles with the included pedestrians through the rou.xml method, however, if I would like the buses to continuously spawn with pedestrians inside the buses it would seem that I would unlikely be able to do so through this method. It is mentioned within the documentation for Persons that the only way to spawn pedestrians into the vehicle is by specifying the exact busID into the personFlow for the pedestrians to spawn into. If one is utilising flow to spawn the buses then the error of "unknown vehicle in triggered departure for person would occur", which was the reason why I thought of utilising TraCI to solve this issue.

Below are the snippets of my attempt utilising the demand xml to solve this issue
<flow id="bus" type="v_2" route="Coach_3" begin="0.00"  end="10000.00" line="bus_route" period="exp(0.0277)" color="blue">
    </flow>

    <personFlow id="p4" type="v_6" begin="triggered" number="25">
        <ride busStop="bs_0" lines="bus"/>
        <walk to="E107" />
        <walk busStop="bs_1" />
        <ride from="E41.86" to="E71" lines="bus_route"/>
    </personFlow>


image.png


I thank you all for the help in advance.

Best Regards,
Nick Tan



Back to the top