CityFlow icon indicating copy to clipboard operation
CityFlow copied to clipboard

How to access functions like getPoint() which are in Vehicle class

Open Sdinesh7 opened this issue 5 years ago • 4 comments

I tried adding this part of code to cityflow.cpp

Screen Shot 2020-06-25 at 10 05 06 AM Screen Shot 2020-06-22 at 5 06 32 PM

Functions in engine class can be accessed by starting the engine at above. But how can I access functions like getPoint()

Screen Shot 2020-06-25 at 10 06 38 AM Screen Shot 2020-06-25 at 10 09 09 AM

Sdinesh7 avatar Jun 25 '20 14:06 Sdinesh7

I think one solution is to write a new function which return a std::vector with size of 2 to represent the point.

soodoshll avatar Jun 26 '20 09:06 soodoshll

Do you mean to write a function in the vehicle class in vehicle.cpp file. Even after that, I can't seem to figure out how to use any of those functions like getMinGap(), getYeildDistance(), or any of those functions in vehicle class to use in my script file like I use the functions in engine class.

Sdinesh7 avatar Jun 26 '20 15:06 Sdinesh7

@soodoshll Please can you make it more clear. I can't seem to figure it out.

Sdinesh7 avatar Jun 30 '20 19:06 Sdinesh7

@Sdinesh7 If you want to use the method in Vehicle class, you need to call it on the Vehicle object instead of Engine object. That means, you need to add a method to Engine first, which return a vector of vehicles (In python, list of vehicle objects). Then you can call the method on each vehicle object.

zhc134 avatar Dec 04 '20 03:12 zhc134