Hello Jakob,

Thank you for catching my silly mistake! Sorry about that, it's all clear
now. That was a very stupid mistake on my part.

Sincerely,
Hriday


On Mon, 25 Apr 2022 at 19:56, Jakob Erdmann <[email protected]> wrote:

> > 2. For each vehicle *i* in that list *L, *I am checking the left /right
> and following / leading blocking vehicles for vehicle *i, *and I find
> that there is never a case when the *ego* *vehicle X is blocking vehicle
> i.*
>
> According to you code, the second call to getRightFollowers uses vehID=vh
> again rather than the intended rel_veh
>
> Am Mo., 25. Apr. 2022 um 20:31 Uhr schrieb Hriday Sanghvi via sumo-user <
> [email protected]>:
>
>> Hello,
>>
>> As discussed previously, I am trying to find out if ego vehicle *X *is
>> considered a blocking vehicle by any of its neighbouring vehicles. So using
>> a combination of convenience functions built on *getNeighbors(self,
>> vehID, mode) *from
>> https://sumo.dlr.de/pydoc/traci._vehicle.html#VehicleDomain-getNeighbors
>> - namely, *getRightFollowers(), getRightLeaders(), getLeftFollowers()
>> and getLeftLeaders()* with the flag *blockingOnly=True, *I am:
>>
>> 1. Gathering any blocking vehicles on the left / right and following /
>> leading of ego vehicle into a list *L.*
>> 2. For each vehicle *i* in that list *L, *I am checking the left /right
>> and following / leading blocking vehicles for vehicle *i, *and I find
>> that there is never a case when the *ego* *vehicle X is blocking vehicle
>> i.*
>>
>> I tested this out by visually observing the output as follows (example):
>>
>> ### STEP 1 ###
>> Blocking vehicles around ego vehicle f.0 : ['f.1']
>> Blocking vehicles for ego-blocking vehicle f.1 : []
>>
>> Blocking vehicles around ego vehicle f.1 : ['f.0']
>> Blocking vehicles for ego-blocking vehicle f.0 : []
>>
>> ### STEP 2 ###
>> Blocking vehicles around ego vehicle f.0 : ['f.4', 'f.1']
>> Blocking vehicles for ego-blocking vehicle f.4 : ['f.1']
>> .
>> .
>> .
>>
>> Python TraCI code:
>>
>> blocking_flag_ego = True
>> blocking_flag_neighbors = True
>>
>> step = 1
>> while len(traci.vehicle.getIDList()) <= 0:
>> traci.simulationStep()
>>
>> LC_MODE = 513 # collision avoidance, safety-gap enforcement AND
>> strategic changes ONLY if not conflicting with TraCI (to get on the correct
>> route)
>>
>> while len(traci.vehicle.getIDList()) > 0:
>> veh_list = traci.vehicle.getIDList()
>> for vh in veh_list:
>> traci.vehicle.setLaneChangeMode(vh, LC_MODE)
>>
>> relevant_vehicles = []
>> speed = traci.vehicle.getSpeed(vh)
>>
>> right_followers = [x[0] for x in traci.vehicle.getRightFollowers(vehID=vh,
>> blockingOnly=blocking_flag_ego)]
>> right_leaders = [x[0] for x in traci.vehicle.getRightLeaders(vehID=vh,
>> blockingOnly=blocking_flag_ego)]
>> left_followers = [x[0] for x in traci.vehicle.getLeftFollowers(vehID=vh,
>> blockingOnly=blocking_flag_ego)]
>> left_leaders = [x[0] for x in traci.vehicle.getLeftLeaders(vehID=vh,
>> blockingOnly=blocking_flag_ego)]
>>
>> relevant_vehicles.extend(right_followers)
>> relevant_vehicles.extend(right_leaders)
>> relevant_vehicles.extend(left_followers)
>> relevant_vehicles.extend(left_leaders)
>>
>> print('Blocking vehicles around ego vehicle {} : {}'.format(vh,
>> relevant_vehicles))
>>
>> for rel_veh in relevant_vehicles:
>> blocking_vehicles = []
>> right_followers_blocking = [x[0] for x in traci
>> .vehicle.getRightFollowers(vehID=vh, blockingOnly=blocking_flag_neighbors)
>> if x[0] not in [rel_veh]]
>> right_leaders_blocking = [x[0] for x in traci.vehicle.getRightLeaders(
>> vehID=vh, blockingOnly=blocking_flag_neighbors) if x[0] not in [rel_veh]]
>> left_followers_blocking = [x[0] for x in traci.vehicle.getLeftFollowers(
>> vehID=vh, blockingOnly=blocking_flag_neighbors) if x[0] not in [rel_veh]]
>> left_leaders_blocking = [x[0] for x in traci.vehicle.getLeftLeaders(vehID
>> =vh, blockingOnly=blocking_flag_neighbors) if x[0] not in [rel_veh]]
>>
>> blocking_vehicles.extend(right_followers_blocking)
>> blocking_vehicles.extend(right_leaders_blocking)
>> blocking_vehicles.extend(left_followers_blocking)
>> blocking_vehicles.extend(left_leaders_blocking)
>> print('Blocking vehicles for ego-blocking vehicle {} : {}'.format(rel_veh,
>> blocking_vehicles))
>>
>> if vh in blocking_vehicles: # IF ego is one of the vehicles blocking it
>> print('Ego vehicle {} will cooperate'.format(vh))
>> input()
>>
>> traci.simulationStep()
>> print('### STEP {} ###'.format(step))
>> step += 1
>> traci.close()
>>
>> edges.xml:
>>
>> <?xml version='1.0' encoding='UTF-8'?>
>> <edges>
>> <edge from="1" id="1f2" numLanes="3" to="2" />
>> </edges>
>>
>> nodes.xml:
>>
>> <nodes>
>> <node id="1" x="0.0" y="0.0" type="priority"/>
>> <node id="2" x="2000.0" y="0.0" type="priority"/>
>> </nodes>
>>
>> routes.xml:
>>
>> <?xml version='1.0' encoding='UTF-8'?>
>> <routes>
>> <vType carFollowModel="Krauss" color="0,1,0" id="veh" length="5" sigma=
>> "0" speedDev="0" speedFactor="1.0" />
>> <route color="1,1,0" edges="1f2" id="r0" />
>> <flow arrivalLane="random" begin="0" departLane="random" departSpeed=
>> "random" id="f" number="100" route="r0" type="veh" vehsPerHour="10000" />
>> </routes>
>>
>> If this is working as intended*, *how then would I go about finding out
>> the list of vehicles that are being blocked by ego vehicle *X? *Please
>> advise.
>>
>> Thank you.
>>
>> 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

Reply via email to