[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [sumo-user] traci and libsumo
|
Hello Michael,
I'm using python 3, so that is fine.
libsumo has not constant and no StepListener, so I still need to import traci, right?
Using https://github.com/lcodeca/SUMOActivityGen/blob/master/activitygen.py and fixing lines 34 and 35 to use libsumo you have the following error:
Traceback (most recent call last):
File "./activitygen.py", line 1342, in <module>
_main()
File "./activitygen.py", line 1327, in _main
mobility.mobility_generation()
File "./activitygen.py", line 223, in mobility_generation
self._compute_trips_per_slice()
File "./activitygen.py", line 365, in _compute_trips_per_slice
_chain, _modes)
File "./activitygen.py", line 521, in _generate_trip_traci
route[-1].stageType == tc.STAGE_DRIVING):
File "/home/drone/Applications/SUMO/sumo-git/sumo/tools/libsumo/libsumo.py", line 996, in <lambda>
__getattr__ = lambda self, name: _swig_getattr(self, TraCIStage, name)
File "/home/drone/Applications/SUMO/sumo-git/sumo/tools/libsumo/libsumo.py", line 80, in _swig_getattr
raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
AttributeError: 'TraCIStage' object has no attribute 'stageType'
The problem is not in the call:
route = traci.simulation.findIntermodalRoute(stage.fromEdge, p_edge, depart=_new_start_time, walkFactor=.9, modes=_mode, pType=_ptype, vType=_vtype)
but in the returned value. That is why I was looking for the documentation..
In https://github.com/lcodeca/PyPML/blob/master/examples/simple.example.py if you change traci with libsumo,
the error is the following:
Traceback (most recent call last):
File "./simple.example.py", line 125, in <module>
_main()
File "./simple.example.py", line 60, in _main
monitor = ParkingMonitor(traci, parking_monitor_options)
File "/home/drone/EURECOM/Projects/GITHUB/PyPML/pypml/pypml.py", line 245, in __init__
tc.VAR_PARKING_ENDING_VEHICLES_IDS))
TypeError: simulation_subscribe() takes no keyword arguments
More precisely, here the question is in how to handle
self._traci_handler.simulation.subscribe(varIDs=(tc.VAR_PARKING_STARTING_VEHICLES_IDS, tc.VAR_PARKING_ENDING_VEHICLES_IDS))
where self._traci_handler is the return value of traci.start()
All the code works fine with SUMO 1.2.0 and Python TraCI APIs.
Thanks for your time!
Lara
On Fri, 19 Apr 2019 20:49:51 +0200
Michael Behrisch <oss@xxxxxxxxxxx> wrote:
> Hi Lara,
> if libsumo is compiled correctly and is in your python path (together
> with the dll / so file), it should really be just a matter of "import
> libsumo as traci". It works only with Python3 however. Please tell us
> what ypu tried and which errors occured.
>
> Best regards,
> Michael
>
> Am 18.04.19 um 10:35 schrieb Lara CODECA:
> > Hello community,
> >
> > I wrote a python library that uses traci to implement a parking monitoring system (https://github.com/lcodeca/PyPML).
> > I'm trying to find a way to use libsumo (or even better both, leaving the choice to the user) in order to improve the performances.
> >
> > Unfortunately, although is written in https://sumo.dlr.de/wiki/Libsumo that "Existing traci scripts can mostly be reused by calling import libsumo as traci", it's not true for me.
> >
> > I always used http://sumo.sourceforge.net/pydoc/traci.html to use traci, but this is not true for libsumo.
> > I'm trying to use https://sumo.dlr.de/daily/doxygen/d8/d1c/class_tra_c_i_a_p_i.html because it's written "C++ interface based on static functions and a few simple wrapper classes", but I don't understand how to apply this documentation to a python3 style use of traci.
> >
> > I cannot find any explicit example in the wiki that gives me the hint on how to do this.
> >
> > I would love if someone could point me in the right direction..
> >
> > All the Best!
> > Lara
> >
>
>
--
Lara CODECA
Postdoc
Tel : 04.93.00.81.51
EURECOM
Campus SophiaTech
http://www.eurecom.fr/