-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plexe various questions #44
Comments
Thanks for spotting the error and most importantly the 404 on the website. The 404 was due to an additional 's' in the URL that I fixed. The correct URL is http://plexe.car2x.org/download/setenv. pip install --user numpy scipy pandas matplotlib posix_ipc or sudo pip install numpy scipy pandas matplotlib posix_ipc depending on whether you want to install them system-wide or not. |
Ok, thank you. I am referring to something like this:
|
It is already integrated in SUMO. But if you use the Python interface, you won't have the simulation of communications. |
I am using SUMO 1.19.0 version (installed using homebrew). I have non problems in importing TraCi module, but when I try to import Plexe, it raise the following error:
Am I doing something wrong? |
Did you install the Python API following the README in the official repo? |
Thanks, I actually was missing that step. Regarding the yield rules, how platoons interact with other vehicles (or other platoons)? I hope I have been clear in explaining the situation. |
Simple and sad answer, they don't know about each other. Unless the external car is a human-driven vehicle, they might simply collide. The only way platoons interact and are aware of each other is longitudinally. The leader is driven by an ACC, so if it approaches a slower vehicle it will slow down. They are also partially aware of adjacent lanes meaning that they should change lane only if the adjacent lane is free and only if you tell a platoon to do so or if you enable the automatic lane change feature. Notice however that we are currently working on the lane change feature as it has known bugs and there can still be collisions. We should release patches soon, but we're still doing testing at the moment. Coming back to your point, the idea is that any advanced cooperative maneuver (say, intersection crossing) requires coordination among vehicles and this needs to be implemented on top of Plexe. It is like taking a real car, activating the ACC and then approaching a red semaphone. The car won't slow down. We have an active project on cooperative maneuvers, so this is still an open issue. |
A question regarding the Plexe API, given the following method to change a vehicle following model in order to add it to a platoon
How does the vehicle I tried to implement a method to create a platoon given the leader and a list of vehicles which are behind it.
In general, taking a look at Plexe API implementation it seems a traci wrapper to handling better the following models. Am I correct? In that case, is the comunication side (Omnet++ side) not handled in the python module? Thank you for your time. |
In Plexe API, what constant variable represents CC controller? I need to set the controller back to CC when the platoon formation is freed. |
There is no pure cruise control (CC), only adaptive cruise control (ACC). If you would like to have pure CC, then you should modify the logic in SUMO, which is not too complicated.
The fact that the ACC passes with the red light is intended behavior, as it would do in real life. If you switch to DRIVER, the problem is that currently the model does not share the required data with the followers, as it is not an automated controller. This is not in principle an impossible problem. Here I am suggesting other people how to do that, but it seems nobody tried. The idea of open sourcing all this would be to enable anyone to add features and then merge them in the main release. So if you work this out, let me know. |
In order to modify the controller logic, is it necessary to make changes in SUMO source code? Right now I am working with the Homebrew based installation of SUMO. Talking about CC, how is it different from DRIVER? I saw that in the definition of vType in rou.xml file it is possible to set |
Yes, you would need to clone SUMO from github, edit the code and recompile it. However, before doing it, you might want to check whether you can simply fetch the required data (such as acceleration and speed) of the leader that is using
Wait, here there is a misconception. CC is the car following model I implemented for SUMO that includes several control algorithms (ACC, plus a set of CACCs). You can switch between different controllers using the |
Shouldn't the
Now it is clearer to me, thank you. Is there a paper or a documentation page for faked and ploeg CACC? |
Yes you can use
Faked CACC is the same as CACC, the only difference is that you feed the distance manually instead of picking the one of the radar, and you use |
I noticed that
Nevertheless there is something wrong. The speed and acceleration of the leader are not propagated through the entire platoon at the same time. Screen.Recording.2024-04-27.at.12.32.40.movIt emerges a kind of cooperation but it is not the ideal situation where the last vehicle starts moving at the same time of the leader. I am currently using the following settings for the vehicles:
There is no specific reason why I am using these parameters, I have taken them from a different project.
but it raises the following error on creating the platoon (in particular when
|
Yes, I cross-checked that and indeed that works. However,
Now here the problem might be the following. There is the possibility of using, in the
No, this will never work. This way you are instantiating a normal human vehicle within SUMO, which provides no Plexe API. |
It actually worked, the latency between the leader start and the other members is near to zero. But now there is an issue occurring sometimes and I cannot understand if it is related to the inter-vehicle distance ( Screen.Recording.2024-05-01.at.21.00.40.movAs you can see, it seems the members are notified of the leader's deceleration too late. I cannot tell if it is due to the use of real acceleration (instead of the controller one) or if it is due to some issues in setting the inter-vehicle distance of the platoon.
To instantiate an autonomous vehicle should I set the carFollowModel to a CC controller? |
I made a test by modifying the brake demo. In particular, I changed the deceleration of the leader to 8 m/s/s instead of 6 m/s/s, and checked what changes by using or not the controller acceleration. The difference is huge. When using the controller acceleration, the minimum distance between the leader and the second vehicle is 3.9 m, whereas when not using it, the second vehicle is 0.95 meters from the leader. So I guess this is what happens in your simulations as well, and it is to be expected.
Yes. |
Yes, it is what happened in my simulations. But why is to be expected? Is there a way to avoid the collision? I tried the brake demo using |
Can you check what is the maximum deceleration of your human driven vehicle? BTW, by setting the deceleration to my vehicles as -20 m/s/s they won't brake that hard because the maximum deceleration is set to 8. The best thing here is to always try to look at actual values to have a comparison and try to understand what are the differences. |
My vehicles should have a maximum deceleration of 10. By the way you are right about the brake demo, i tried to set the maximum deceleration to 20 and it occurred a collision. However, I also tried to set it to 10 (the value of my simulation) and there isn't any collision, but I think it is due to a lower vehicles speed.
Thank you for the advice. |
Is there a way to make a platoon member start moving only when its distance from the front vehicle is equal to a fixed value? That is because my vehicles stop at the minGap distance from the front vehicle. Accordingly, whenever the platoon is created the inter-vehicle distance is minGap. As soon as the front vehicle decelerate then the distance falls below minGap and eventually the simulation threat that as a collision. If I could set a distance of minGap+offset even if there is a deceleration it can be handled (whithin a certain limit). |
For platooning vehicles the minGap should be set to 0. In fact, the |
I imagined that as it is set to zero in brake demo. As soon as the platoon members are selected, their minGap is set to 0. But for vehicles which are not included in the platoon I think is useful to have a minGap greater than zero.
I tried to increase that value but the result is the same. The inter-vehicle distance remains the same as when they stop before crossing. As it can be seen in the following clip, in the second platoon the last member is teleported because of a collision, even if its minGap is 0. Screen.Recording.2024-05-08.at.15.58.41.movI also noticed that the distance between members tends to be shorter towards the end of the platoon, although I believe it should be approximately the same in every part of the platoon. The method I use to create a platoon is the following:
where vids[0] is the leader. |
Yes, that is correct.
I don't see the collision... anyhow, minGap set to 0 won't prevent collisions. It actually adds to the actual distance, so if you set a target distance of 5m but you have a minGap of 2m, the actual distance will be 7m. So better set it to 0 for platooning vehicles.
Well not really. Shorter in which sense? You should always compare the distance to the target one by measuring it, not looking at it. If the target distance is 5 m, the further you go down the platoon, the more the vehicles will be able to maintain such target regardless of disturbances occurring at the head of the platoon. This is what is called string stability of a platoon. If at the end, the distance is always around 5 meters, then everything is working as expected.
No it is not. I suggest upgrading to SUMO 1.20.0. We fixed the lane change model. After upgrading please be sure to add every vehicle as member of a specific platoon using the
|
I updated to version 1.20.0. Using DRIVER controller on the leader and the following code to add members:
where The second platoon showed in the last video is behaving this way.
This is the situation after few steps.
Is there something I am missing in setting the platoon? |
I tried some more testing. I edited the import os
import sys
import random
from build.lib.plexe import DRIVER
from utils import add_platooning_vehicle, start_sumo, running, communicate
if 'SUMO_HOME' in os.environ:
tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
sys.path.append(tools)
else:
sys.exit("please declare environment variable 'SUMO_HOME'")
import traci
from plexe import Plexe, ACC, CACC, RPM, GEAR, RADAR_DISTANCE, RADAR_REL_SPEED
# vehicle length
LENGTH = 4
# inter-vehicle distance
DISTANCE = 5
# cruising speed
SPEED = 120/3.6
# distance between multiple platoons
PLATOON_DISTANCE = SPEED * 1.5 + 2
# vehicle who starts to brake
BRAKING_VEHICLE = "v.0.0"
def add_vehicles(plexe, n, n_platoons, real_engine=False):
"""
Adds a set of platoons of n vehicles each to the simulation
:param plexe: API instance
:param n: number of vehicles of the platoon
:param n_platoons: number of platoons
:param real_engine: set to true to use the realistic engine model,
false to use a first order lag model
:return: returns the topology of the platoon, i.e., a dictionary which
indicates, for each vehicle, who is its leader and who is its front
vehicle. The topology can the be used by the data exchange logic to
automatically fetch data from leading and front vehicle to feed the CACC
"""
# add a platoon of n vehicles
topology = {}
p_length = n * LENGTH + (n - 1) * DISTANCE
for p in range(n_platoons):
for i in range(n):
vid = "v.%d.%d" % (p, i)
add_platooning_vehicle(plexe, vid, (n-p+1) *
(p_length + PLATOON_DISTANCE) + (n-i+1) *
(DISTANCE+LENGTH), 0, SPEED, DISTANCE,
real_engine)
plexe.set_fixed_lane(vid, 0, False)
traci.vehicle.setSpeedMode(vid, 0)
plexe.use_controller_acceleration(vid, False)
if i == 0:
plexe.set_active_controller(vid, DRIVER)
else:
plexe.set_active_controller(vid, CACC)
if i > 0:
topology[vid] = {"front": "v.%d.%d" % (p, i - 1),
"leader": "v.%d.0" % p}
else:
topology[vid] = {}
return topology
def main(demo_mode, real_engine, setter=None):
# used to randomly color the vehicles
random.seed(1)
start_sumo("cfg/freeway.sumo.cfg", False)
plexe = Plexe()
step = 0
topology = dict()
out = open("log.csv", "w")
out.write("nodeId,time,distance,relativeSpeed,speed,acceleration,controllerAcceleration\n")
while running(demo_mode, step, 6000):
# when reaching 60 seconds, reset the simulation when in demo_mode
if demo_mode and step == 6000:
start_sumo("cfg/freeway.sumo.cfg", True)
step = 0
random.seed(1)
traci.simulationStep()
if step == 0:
# create vehicles and track the braking vehicle
topology = add_vehicles(plexe, 8, 1, real_engine)
traci.gui.trackVehicle("View #0", BRAKING_VEHICLE)
traci.gui.setZoom("View #0", 20000)
if step % 10 == 1:
# simulate vehicle communication every 100 ms
communicate(plexe, topology)
if real_engine and setter is not None:
# if we are running with the dashboard, update its values
tracked_id = traci.gui.getTrackedVehicle("View #0")
if tracked_id != "":
ed = plexe.get_engine_data(tracked_id)
vd = plexe.get_vehicle_data(tracked_id)
setter(ed[RPM], ed[GEAR], vd.speed, vd.acceleration)
if step == 500:
plexe.set_fixed_acceleration(BRAKING_VEHICLE, True, -20)
traci.vehicle.setAcceleration(BRAKING_VEHICLE, -4, 10)
if step > 1:
vehicles = traci.vehicle.getIDList()
for v in vehicles:
if v == BRAKING_VEHICLE:
distance = -1
rel_speed = 0
else:
radar = plexe.get_radar_data(v)
distance = radar[RADAR_DISTANCE]
rel_speed = radar[RADAR_REL_SPEED]
acc = traci.vehicle.getAcceleration(v)
out.write(f"{v},{step},{distance},{rel_speed},{traci.vehicle.getSpeed(v)},{acc},{acc}\n")
step += 1
out.close()
traci.close()
if __name__ == "__main__":
main(False, False) This creates a platoon with a leader which uses <routes>
<vType id="vtypeauto" accel="2.5" decel="8" sigma="0" length="4" tau="3.0"
minGap="0" maxSpeed="33.33" color="1,0,0" probability="1"
carFollowModel="CC" tauEngine="0.5" omegaN="0.2" xi="1" c1="0.5"
lanesCount="4" ccAccel="1.5" ploegKp="0.2" ploegKd="0.7"
ploegH="0.5" speedFactor="2" laneChangeModel="LC2013_CC"
lcStrategic="5" lcCooperative="5" lcSpeedGain="5" lcKeepRight="5"/>
<route id="platoon_route" edges="edge_0_0 edge_0_1 edge_0_2 edge_0_3 edge_1_0 edge_1_1 edge_1_2 edge_1_3 edge_2_0 edge_2_1 edge_2_2 edge_2_3 edge_3_0 edge_3_1 edge_3_2 edge_3_3 edge_4_0 edge_4_1 edge_4_4 edge_4_6 absorption_4"/>
</routes> Then I tried to plot the data using the following library(ggplot2)
allData <- read.csv("log.csv")
allData$controllerName <- "CACC"
p.speed <- ggplot(allData, aes(x=time, y=speed*3.6, col=factor(nodeId))) +
geom_line() +
facet_grid(controllerName~., scales='free_y')
ggsave('braking-speed.pdf', p.speed, width=16, height=9)
p.distance <- ggplot(subset(allData, distance != -1), aes(x=time, y=distance, col=factor(nodeId))) +
geom_line() +
facet_grid(controllerName~., scales='free_y')
ggsave('braking-distance.pdf', p.distance, width=16, height=9)
p.accel <- ggplot(allData, aes(x=time, y=acceleration, col=factor(nodeId))) +
geom_line() +
facet_grid(controllerName~., scales='free_y')
ggsave('braking-acceleration.pdf', p.accel, width=16, height=9) Obtaining the following plots: First you can see that the human model introduces noise in the acceleration, which is something SUMO does and that for sure affects the |
It sets the time headway for the ACC algorithm, but given that you are not using it, it has no effect.
What do you mean with "a platoon is cleared after each member cross the intersection"? Does that mean they are not using CACC anymore? What do you switch to? Switching to another controller at such small distances can lead to collisions.
I don't know if I understood your question correctly. Are you asking whether I can use the controller acceleration of CACC vehicles to feed other CACC vehicles? So using the real acceleration of the leader and the controller acceleration of the preceding vehicle? You can do it by simply passing as actual acceleration of the preceding vehicle its controller acceleration, but honestly I don't know what happens from a stability perspective using inconsistent data. Give it a try though. |
The scope of my project is to exploit the platoon members' cooperation in order to optimise the throughput of an intersection controlled by a traffic light and the total waiting time of the vehicles. Given a queue of stationary vehicles waiting for the green light, my idea is to create a platoon of vehicles which have to turn the same way. When the entire platoon has passed the intersection, it is cleared, i. e. the members controller change from CACC to the one they previously had. Ideally the controller should be the one defined in the vtype:
but given the fact that I am not sure on how to set it properly, I currently am setting the controller to DRIVER when the platoons are cleared. If I understood correctly DRIVER is a krauss follwing model so it is the nearest thing to the standard autonomous vehicle. Screen.Recording.2024-05-21.at.22.14.00.movWith a careful management of the minGap and the platoon inter vehicle distance, even if the controller is switched at a small distance, no collision occurs, on the worst case only a brake.
My doubt is about the way acceleration and speed are computed when using real acceleration and speed. On the plexe paper is show the rule for computing the desired acceleration in a CACC vehicle. So what change in that formula when the real acceleration is passed? Does it remain unchanged apart from |
Yes, it is clear. However, switching the control directly from a CACC at a very small distance to Krauss (which is basically giving the control back to the driver) is not safe. In the real world this would lead to collisions, even with autonomous cars, because the distance is simply too small and you are suddenly losing important information (what the leader is doing) which is what enables you to maintain a constant spacing gap policy. Basically, you are suddenly switching from a constant spacing policy to constant time headway policy, which can cause instabilities and collisions. What this will do is generate a deceleration shockwave that will cause sooner or later a collision. The fact that they do not collide does not mean things are safe, because the Krauss model is basically collision free, so SUMO will brake unrealistically hard to avoid the collision, but in the real world they will crash into each other. If you want to switch to another controller, you should first progressively increase the distance, and then switch.
Yes you can give it a try. But without looking deeply into it I cannot really understand why this is happening.
The formula does not change, you just use a different value. |
I see, in fact as soon as the carFollwingModel changes, a deceleration shockwave occurs. The problem is that, given the fact that the platoon is cleared when it passes the intersection, there is not enough time for the members to distance themselves. I tried by setting the inter-vehicle distance of the platoon to 30, it works only for small platoons. Since the benefits of platoon strategy have more effect the larger the platoon is, it would be a waste to limit the platoon size. In addition, using a great distance, the members' departure does not happen at the same moment because of the close distance at which they find themselves when the platoon is created. Perhaps I can use something like
I tried it, but nothing changes. However, in case you would like to take a look at it here is the repository link (
Ok, so at every step the desired acceleration is computed. As a result, the actual acceleration is adjusted to meet the desired acceleration, and that is the acceleration and speed passed to the following member when choosing to pass real values. Otherwise, the passed values are the desired ones. Is that right? |
It would not help in my opinion, because you are doing a lot of work to improve traffic flow and then, to dismantle the platoon, you slow everyone down. I guess here the good thing to do is to keep the platoon, not dismantling it immediately after crossing. Or, in any case, take more time to dismantle that. Just a question on this. Are you doing this as bachelor or master thesis? Or as part of a PhD? I guess this kind of details needs to be discussed with your advisor.
I see. Call self.plexe.set_fixed_lane(vid, traci.vehicle.getLaneIndex(vid)) to every platoon member in self.plexe.set_fixed_lane(vid, -1) in
Exactly. |
It is a bachelor's thesis. Yes, I will discuss it with my tutor.
Thank you. |
My bad! I realized I didn't push the new changes! Can you update from the repo, re-install, and try again? |
It works, thank you. |
Why in brake example is used
|
The first one works on vehicles using |
I see, that is why |
Krauss is a human behavioral model, so it should mimic a person, not really an autonomous vehicle |
Thank you, my problem was solved by editing the path of Windows |
@hosseinihalimeh Glad that you solved your problem, but please next time open a dedicated issue. |
One question regarding CACC controller. Usually the controller is in speed control mode, when the distance from the preceding vehicle and the relative speed is below a threshold, it switches to gap-closing mode and then gap control mode. |
In Plexe it is not that way, unless you set up a protocol that does so, like in the JoinManeuver example. Currently, if you use the CACC, then this is always in gap control mode. The only exception is the ACC, which has a target speed. If your car is driving at the target speed, then the ACC will not catch up with the preceding vehicle. |
I see. Thank you. |
Hello,
I am trying to install plexe on my system (MacOs M2 Sonoma). I am facing the following error when executing:
The error it gives is:
In the Building section of the Plexe website it is mentioned to substitute the
setenv
file, but the link is not working for me.What should I do?
I also tried to use Instant Plexe on UTM (converting OVA file in the extension UTM uses) but it is really slow and unreactive so it is impossible for me to use. Have you got any advice on which way is best for me? I would like to use Plexe for my Bachelor's thesis. Thank you in advance.
The text was updated successfully, but these errors were encountered: