Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Error while running SUMO using Python

Thanks for your email. But I am already using the latest version. 

On Fri, Aug 9, 2024 at 6:18 PM Mirko Barthauer <m.barthauer@xxxxxxxxxxx> wrote:

The parameter has been renamed some time ago. Please be sure you use the latest version of SUMO (v1.20).

 

 

 

 

-----Original-Nachricht-----

Betreff: Re: [sumo-user] Error while running SUMO using Python

Datum: 2024-08-09T13:57:53+0200

Von: "Parth Loya" <loya.parth@xxxxxxxxx>

An: "Mirko Barthauer" <m.barthauer@xxxxxxxxxxx>

 

 

 

Hi Mirko,
 
Thank you so much for your reply. Kindly note that I am getting following error when I am trying to access electric vehicle charge value during simulation:
 
traci.exceptions.TraCIException: Vehicle 'v_0' does not support device parameter 'device.battery.chargeLevel' (Parameter 'chargeLevel' is not supported for device of type 'battery').  
 
I am using following code - 
charge_level = float(traci.vehicle.getParameter("v_0", "device.battery.chargeLevel"))
 
Could you be kind enough to suggest what mistake I might be doing?
 
Thanks in advance
 

On Fri, Aug 9, 2024 at 12:13 PM Mirko Barthauer <m.barthauer@xxxxxxxxxxx> wrote:

Hi Parth,

 

traci.vehicle.getParameter always returns a string you have to cast to float to use it in mathematical expressions:

float(traci.vehicle.getParameter(electricVeh, "device.battery.chargeLevel"))

 

Please note the complete parameter name above. You might be interested as well in the stationfinder device which reroutes vehicles to charging stations.

 

Best regards

Mirko

 

 

 

 

-----Original-Nachricht-----

 

Betreff: Re: [sumo-user] Error while running SUMO using Python

Datum: 2024-08-08T16:09:33+0200

Von: "Parth Loya" <loya.parth@xxxxxxxxx>

An: "Mirko Barthauer" <m.barthauer@xxxxxxxxxxx>

 

 

 

Hi Mirko,
 
I am trying to model a scenario where an EV is moving in a loop on a route multiple times. If its charge gets below a certain threshold value, it needs to go to a nearby charging station. 
 
I am implementing it by first checking current charge level:
charge_level = traci.vehicle.getParameter("v_0", "chargeLevel")
 
But this is giving me charge level in string. When I am doing -
float(traci.vehicle.getParameter("v_0", "chargeLevel")) it is giving me an error message.
 
Next, based on the charge level, I want to change its route. 
current_edge = traci.vehicle.getRoadID("v_0")
current_route = traci.vehicle.getRouteID("v_0")
if current_edge == "B4A4" and current_charge < (threshold_low * max_charge):
            traci.vehicle.setRouteID("v_0", "r_1")
            traci.vehicle.setChargingStationStop("v_0", "cs_0", duration = time )
        if current_edge == "A3A2" and current_charge > (threshold_high * max_charge):
            traci.vehicle.setRouteID("v_0", "electric")
 
Can you please help? "B4A4" is not found. 
 

On Thu, Aug 8, 2024 at 6:22 PM Mirko Barthauer <m.barthauer@xxxxxxxxxxx> wrote:

Do you refer to your previous question about displaying the current charge in the GUI or do you want to read it using TraCI? Please follow the link I gave you if it is about the GUI, otherwise call traci.vehicle.getParameter(vehID, "chargeLevel").

 

Best regards

Mirko

 

 

 

 

-----Original-Nachricht-----

Betreff: Re: [sumo-user] Error while running SUMO using Python

Datum: 2024-08-08T14:02:01+0200

Von: "Parth Loya" <loya.parth@xxxxxxxxx>

An: "Mirko Barthauer" <m.barthauer@xxxxxxxxxxx>

 

 

 

I want to find the current charge of the battery of an electric vehicle during simulation run. Can you tell me how to do that? 

On Thu, Aug 8, 2024 at 12:56 PM Mirko Barthauer <m.barthauer@xxxxxxxxxxx> wrote:

Hi,

 

did you check that the sumocfg runs without errors when loaded directly in sumo? If it does, then you miss at least a traci.close() call (see example in documentation).

 

 Best regards

Mirko

 

 

 

 

-----Original-Nachricht-----

Betreff: [sumo-user] Error while running SUMO using Python

Datum: 2024-08-08T07:35:28+0200

Von: "Parth Loya via sumo-user" <sumo-user@xxxxxxxxxxx>

An: "sumo-user@xxxxxxxxxxx" <sumo-user@xxxxxxxxxxx>

 

 

 

Hi,
I am trying to run SUMO using python code. I am getting the following error - 
Error: tcpip::Socket::recvAndCheck @ recv: peer shutdown
Quitting (on error).
 
I am attaching my python script. Most of it is inspired from following github repository - https://github.com/ecetinturk/mqtt-ev-charging
 
Can you suggest why I am getting this error?
 
--
Regards,
Parth Loya
 

 


 
--
Regards,
Parth Loya

 


 
--
Regards,
Parth Loya
 

 


 
--
Regards,
Parth Loya
 

 




--
Regards,
Parth Loya
B.Tech: IIT Bombay 
MS: University of California at Berkeley (USA)
Mob - +91-9340267098

Back to the top