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

Hi ,
It will be great if you can look into this as well.


On Sun, Aug 25, 2024, 14:48 Parth Loya <loya.parth@xxxxxxxxx> wrote:
Hi Mirko, 

Thanks for your earlier emails. I am trying to implement a stationfinder in order to reroute EVs to the nearest charging station. I am using the following code in my rou.xml file. however, despite enabling stationfinder, the vehicles are not being rerouted. They are not even stopping once they are discharged. What to do in that case? 

<?xml version="1.0" encoding="UTF-8"?>

<!-- generated on 2024-08-07 18:26:44 by Eclipse SUMO netedit Version 1.20.0
-->

<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
    <!-- VTypes -->
    <vType id="ElectricBus" length="12.00" minGap="2.50" maxSpeed="100.00" emissionClass="Energy" mass="10000.00" color="white" accel="1.0" decel="1.0" sigma="0.0">
        <param key="airDragCoefficient" value="0.6"/>
        <param key="constantPowerIntake" value="100"/>
        <param key="device.battery.maximumChargeRate" value="35000"/>
        <param key="frontSurfaceArea" value="5"/>
        <param key="has.battery.device" value="true"/>
        <param key="maximumPower" value="10000"/>
        <param key="propulsionEfficiency" value="0.9"/>
        <param key="radialDragCoefficient" value="0.5"/>
        <param key="recuperationEfficiency" value="0.9"/>
        <param key="rollDragCoefficient" value="0.01"/>
        <param key="rotatingMass" value="100"/>
        <param key="stoppingThreshold" value="0.1"/>



    </vType>
    <!-- Routes -->
    <route id="electric" edges="A4A3 A3A2 A2B2 B2C2 C2C3 C3C4 C4B4 B4A4" repeat = "50" />
    <route id="r_1" edges="B4A4 E0 E1 E2 A3A2"/>
    <!-- Vehicles, persons and containers (sorted by depart) -->
    <vehicle id="v_0" type="ElectricBus" depart="0.00" route="electric">
<param key="actualBatteryCapacity" value="35000"/>
<param key="device.stationfinder.rescueTime" value="150"/>
<param key="device.stationfinder.rescueAction" value="tow"/>
<param key="device.stationfinder.emptyThreshold" value="0.4"/>
<param key="device.stationfinder.radius" value="1800"/>
<param key="device.stationfinder.needToChargeLevel" value="0.4"/>
    </vehicle>
   

</routes>

On Mon, Aug 12, 2024 at 12:54 PM Mirko Barthauer <m.barthauer@xxxxxxxxxxx> wrote:

Sorry, I thought it happened before the last release, but it was renamed actually some weeks later. In v.1.20 the battery charge can be queried using the parameter 'device.battery.actualBatteryCapacity'.

 

Best regards

Mirko

 

 

 

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

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

Datum: 2024-08-09T18:34:25+0200

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

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

 

 

 

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

 




--
Regards,
Parth Loya


Back to the top