Thank you, I understand and have successfully simulated the desired effect
for now.


On Wed, 12 Jan 2022 at 09:39, Jakob Erdmann <[email protected]> wrote:

> 1. when calling vehicle.moveTo, the vehicle may still perform normal
> movement in the same simulation step and thus the gui (which shows the end
> state) can show a different position
> 2. the to-close-to-brake error is likely due to the use of
> departSpeed="random" since vehicles need some distance for coming to a
> standstill.
> 3. with duration=10, until=20, the block will indeed last until step 20
> (since your place the ghost vehicle at the start of your simulation). If
> you were to place it in step 50 instead, the stop would last for 10 steps
> since the 'until' time is already past. The ghost vehicle will continue to
> drive to the end of it's route "r0" after finishing the stop. To remove it
> instantly, ensure that it's route ends on this edge and set arrivalPos to
> the stop position.
>
> Am Mi., 12. Jan. 2022 um 09:13 Uhr schrieb Hriday Sanghvi via sumo-user <
> [email protected]>:
>
>> Hello again,
>>
>> Thank you for the response, and for confirming that the 'ghost' vehicle
>> approach is the right way to proceed for the 'blocked part of the lane'
>> solution. I am now using the moveTo() command since it is easier to define
>> the position in terms of position in the lane. However, the problem lies in
>> the accuracy of the position as determined by SUMO on lane:
>>
>> traci.vehicle.moveTo(vehID='ghost', laneID='1f2_0', pos=50.0)
>>>
>>
>> while in the GUI, the parameter of the 'ghost' vehicle is seen as 50.16 m
>> instead. This leads to a TraCI exception as follows:
>>
>> stop for vehicle 'ghost' on lane '1f2_0' is too close to brake
>>
>>
>>
>> So I decided to modify the vehicle.add() statement in the beginning to
>> set the position on the lane and that was more accurate in setting it at
>> exactly 50m.
>>
>> TraCI code:
>>
>> step = 0
>>>
>>> traci.vehicle.add(vehID='ghost', routeID='r0', typeID='veh', depart=0,
>>> departLane=0, departPos=50, departSpeed='random', arrivalLane='current')
>>> traci.vehicle.setColor(vehID='ghost',color=(0,255,0))
>>> traci.vehicle.setLength(vehID='ghost',length=20)
>>>
>>> traci.vehicle.setStop(vehID='ghost', edgeID='1f2', pos=50, duration=10,
>>> until=20)
>>>
>>> while step < 1000:
>>>     traci.simulationStep()
>>>     if step % 10 == 0:
>>>         print('Adding vehicle agent_{}...'.format(step))
>>>         traci.vehicle.add(vehID='agent_{}'.format(step), routeID='r0',
>>> typeID='veh', depart='now', departLane='random', departSpeed='random',
>>> arrivalLane='random')
>>>
>>>     if step == 200:
>>>         traci.vehicle.remove(vehID='ghost')
>>>     step+=1
>>>
>>> traci.close()
>>>
>>
>> From what I understand, the *duration* is the "minimum duration" for
>> stopping and *until* is what will control to what exact SUMO timestep
>> the stop would last. This seems to simulate a temporary block in the lane
>> for 20 SUMO steps. Is this the correct way to remove the 'ghost' vehicle
>> acting as the block from the simulation at the end of the *until *
>> parameter?
>>
>> Thanks again.
>>
>> Sincerely,
>> Hriday
>>
>> On Mon, 10 Jan 2022 at 14:48, Jakob Erdmann <[email protected]>
>> wrote:
>>
>>> 1. The 'ghost'-vehicle approach is still the recommended way to block
>>> part of a lane
>>> 2. moveToXY when sent only once should not stop the vehicle
>>> indefinitely. Your code looks as if you re-issue the command every step,
>>> though.
>>> 4. setStop should only be called once. For the meaning of flags, see
>>> https://sumo.dlr.de/pydoc/traci._vehicle.html#VehicleDomain-getStops,
>>> for all other attributes, see
>>> https://sumo.dlr.de/docs/Definition_of_Vehicles%2C_Vehicle_Types%2C_and_Routes.html#stops
>>> (parameter 'pos' corresponds to 'endPos' in the xml input)
>>> 3. you can check whether the vehicle is in the 'stopped' state (from
>>> setStop) by right-clicking it in the gui and selecting 'show route'. Unless
>>> the gui annotates it as 'stopped' it will not trigger strategic lane
>>> changing (though it may still trigger tactical changing).
>>>
>>> Am Mo., 10. Jan. 2022 um 12:51 Uhr schrieb Hriday Sanghvi via sumo-user <
>>> [email protected]>:
>>>
>>>> Hello,
>>>>
>>>> I recently found out that the only way to simulate a blockage in
>>>> a temporary part of the lane, (maybe due to construction activities) is by
>>>> stopping a 'ghost' vehicle and setting its length to the intended area of
>>>> effect. Source:
>>>> https://gitanswer.com/has-sumo-a-method-to-block-part-of-the-lane-1007148310
>>>> . Please correct me if that is not the case.
>>>>
>>>> How would I go about allowing the other vehicles to lane change around
>>>> this 'ghost' vehicle to reach the end of a single edge with 3 lanes? Edge
>>>> file:
>>>>
>>>> <edges>
>>>>
>>>> <edge id="1f2" from="1" to="2" speed="30" numLanes="3"
>>>>> spreadType="center"/>
>>>>
>>>> </edges>
>>>>>
>>>>
>>>> Route file:
>>>>
>>>> <routes>
>>>>
>>>> <vType id="veh" length="5" maxSpeed="30" lcStrategic="0"
>>>>> lcCooperative="0" lcSpeedGain="0" lcKeepRight="0" lcOvertakeRight="0"
>>>>> lcOpposite="0" lcSpeedGainLookahead="0" lcCooperativeRoundabout="0"
>>>>> lcSublane="0" lcPushy="0" /><route id="r0" color="1,1,0" edges="1f2" />
>>>>
>>>> </routes>
>>>>
>>>>
>>>> In TraCI (Python):
>>>>
>>>> step = 0
>>>>> traci.vehicle.add(vehID='ghost', routeID='', typeID='veh', depart=0,
>>>>> departLane=0, departSpeed='random')
>>>>> traci.vehicle.setColor(vehID='ghost',color=(0,255,0))
>>>>>
>>>>> while step < 1000:
>>>>>     traci.simulationStep()
>>>>>     if step % 10 == 0:
>>>>>         traci.vehicle.add(vehID='agent_{}'.format(step), routeID='r0',
>>>>> typeID='veh', depart='now', departLane='random', departSpeed='random',
>>>>> arrivalLane='random')
>>>>>     # traci.vehicle.moveToXY(vehID='ghost', edgeID='1f2', lane=0,
>>>>> x=68.0, y=-3.3, angle=90, keepRoute=1)
>>>>>     traci.vehicle.setStop(vehID='ghost', edgeID='1f2', pos=1,
>>>>> laneIndex=0, duration=100, flags=0, startPos=0, until=120)
>>>>>     step+=1
>>>>> traci.close()
>>>>
>>>>
>>>> The moveToXY seems to stop the 'ghost' vehicle at the specified
>>>> coordinates indefinitely (until simulation ends) but the setStop command
>>>> doesn't seem to make any modifications. So I was wondering if a combination
>>>> of these would make it ideal for my case.
>>>>
>>>> Why does the vehicle completely stop after using the moveToXY command
>>>> indefinitely? Could you clarify the parameters used for the setStop
>>>> command, specifically *pos, duration, flags, startPos and until*? I'm
>>>> assuming until is from the start time of the simulation (at 0). So if I set
>>>> until to 300, the vehicle should stay in the stopped state till 300
>>>> simulation time. But then I am confused because duration would mean time in
>>>> seconds for the stopped state?
>>>>
>>>> Also, I have already tried using TraCI's lane.setDisallowed() method,
>>>> but it blocks the entire lane and not just the specified part of it.
>>>>
>>>> Thank you for any assistance in advance.
>>>>
>>>> Sincerely,
>>>> Hriday.
>>>> _______________________________________________
>>>> sumo-user mailing list
>>>> [email protected]
>>>> To unsubscribe from this list, visit
>>>> https://www.eclipse.org/mailman/listinfo/sumo-user
>>>>
>>> _______________________________________________
>>> sumo-user mailing list
>>> [email protected]
>>> To unsubscribe from this list, visit
>>> https://www.eclipse.org/mailman/listinfo/sumo-user
>>>
>> _______________________________________________
>> sumo-user mailing list
>> [email protected]
>> To unsubscribe from this list, visit
>> https://www.eclipse.org/mailman/listinfo/sumo-user
>>
> _______________________________________________
> sumo-user mailing list
> [email protected]
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/sumo-user
>
_______________________________________________
sumo-user mailing list
[email protected]
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/sumo-user

Reply via email to