How can I get real-time charge or battery status for electric vehicles in Simulation of Urban MObility (SUMO)?

89 Views Asked by At

Example code is below.

import traci 

distance = traci.vehicle.getDistance(vehID) 
speed = traci.vehicle.getSpeed(vehID) 
lane_pos = traci.vehicle.getLanePosition(vehID)

print("Vehicle", vehID, "Speed: {:.2f}".format(speed), "Lane Position: {:.2f}".format(lane_pos), "Distance : {:.2f}".format(distance), "Battery_Level : {:.2f}".format(battery_level))

traci.close()

For example, I can draw and print the distance values of a vehicle with the code "traci.vehicle.getDistance(vehID)". However, I can't get any instantaneous value related to the battery status. How can I get? is there a way to do this? Very happy if you help.

1

There are 1 best solutions below

0
On

You can ask for the remaining charge using traci.vehicle.getParameter(vehID, "device.battery.actualBatteryCapacity"). This needs a battery device in the vehicle which can be enabled in the XML or using the command line e.g. --device.battery.probability 1 to enable it for all vehicles. It's all in the docs: https://sumo.dlr.de/docs/Models/Electric.html#traci