carla-simulator / carla

Open-source simulator for autonomous driving research.
http://carla.org
MIT License
11.33k stars 3.67k forks source link

Error when using get_waypoint() with carla.LaneType.Any in Windows #3119

Closed LikhitaNukala closed 4 years ago

LikhitaNukala commented 4 years ago

I have executed the following command for OpenSCENARIO. python scenario_runner.py --openscenario L:\carla_latest\scenario_runner-0.9.9\srunner\examples\CyclistCrossing.xosc

I'm getting the following.

WARNING:OpenScenarioConfiguration:Wrong OpenDRIVE map in use. Forcing reload of CARLA world Preparing scenario: CARLA:CyclistCrossing ScenarioManager: Running scenario OpenScenario Traceback (most recent call last): File "scenario_runner.py", line 382, in _load_and_run_scenario self.manager.run_scenario() File "L:\carla_latest\scenario_runner-0.9.9\srunner\scenariomanager\scenario_manager.py", line 216, in run_scenario self._tick_scenario(timestamp) File "L:\carla_latest\scenario_runner-0.9.9\srunner\scenariomanager\scenario_manager.py", line 260, in _tick_scenario self.scenario_tree.tick_once() File "C:\Users\lnukala\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\py_trees\behaviour.py", line 158, in tick_once for unused in self.tick(): File "C:\Users\lnukala\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\py_trees\composites.py", line 578, in tick for node in child.tick(): File "C:\Users\lnukala\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\py_trees\composites.py", line 578, in tick for node in child.tick(): File "C:\Users\lnukala\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\py_trees\composites.py", line 578, in tick for node in child.tick(): File "C:\Users\lnukala\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\py_trees\behaviour.py", line 249, in tick new_status = self.update() File "L:\carla_latest\scenario_runner-0.9.9\srunner\scenariomanager\scenarioatomics\atomic_criteria.py", line 648, in update current_wp = self._map.get_waypoint(current_loc, lane_type=carla.LaneType.Any) OverflowError: can't convert negative value to unsigned int can't convert negative value to unsigned int Destroying ego vehicle 258 No more scenarios .... Exiting

Desktop

glopezdiest commented 4 years ago

Hey. That WARNING is normal. Each scenario needs a specific town so if you aren't in the correct one, the world is reloaded.

OverflowError: can't convert negative value to unsigned int

This however, isn't. Can you explain the step you did to reproduce it? I just tried it and couldn't see anything like that.

PD: I'm changing the title to match the actual issue

LikhitaNukala commented 4 years ago

image

I have followed the same steps of importing/ simulating OpenSCENARIO files using the command. python scenario_runner.py --openscenario I'm getting the error.

glopezdiest commented 4 years ago

Okay, I'll take a look, see if I can reproduce the error.

glopezdiest commented 4 years ago

@LikhitaNukala I'm sorry to say this but I can't seem to reproduce this error. This makes me believe it might be a Windows related issue, but I can't ensure that's the case, as I currently don't have the possibility to test it in Windows. I'll keep digging, see if I find something else.

DevOpsMVP commented 4 years ago

I got this error on windows10,not for ubuntu.

glopezdiest commented 4 years ago

@DevotionGit Could you please print the exact current_loc and paste it here?

charlie-wartnaby commented 4 years ago

Hello, I've just run into this under Windows too. It seems to be because:

carla\PythonAPI\carla\dependencies\include\carla\road\Lane.h(51):      Any           = 0xFFFFFFFE

... which should be fine, but in Windows Python (Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32), that gets interpreted like a signed int as -2. Or at least does if I use an int() conversion in a debug print statement in the Python.

So then the Python is passing -2 to the function get_waypoint(), in C++ GetWaypoint(), expecting a uint32_t when it uses LaneType.Any here in npc_vehicle_control.py:

            waypoint = CarlaDataProvider.get_map().get_waypoint(
                transform.location, project_to_road=True, lane_type=carla.LaneType.Any)

Changing it to carla.LaneType.Driving as a workaround avoids the exception (in my case at least). But obviously that's not a proper solution.

glopezdiest commented 4 years ago

Hey @charlie-wartnaby. Thanks for the information. We'll take a look, see what we can do to fix it.

charlie-wartnaby commented 4 years ago

Thank you @glopezdiest , and note @LikhitaNukala and @DevotionGit . For now a simple workaround is to change the definition of LaneType::Any here in LibCarla/source/carla/road/Lane.h (and then rebuild CARLA and the PythonAPI):

      Any           = 0x7FFFFFFE // CW: IDIADA workaround to avoid overflow exception when 0xFFFFFFFE interpreted as -2 in Windows Python and passed to uint32_t function in API

For good measure I did the same thing for LightState::All in LibCarla/source/rpc/VehicleLightState.h, I didn't spot any others like this:

      All          = 0x7FFFFFFF // CW: IDIADA workaround to avoid overflow exception when 0xFFFFF... interpreted as -ve in Windows Python

I have never written my own Python library in C/C++ and am new to CARLA, so to be honest I have no idea how the type mapping is supposed to work there from C++ to Python. But this seems to do the trick.

glopezdiest commented 4 years ago

Adding @bernatx and transferring it to the CARLA main repository, as this doesn't seem to be ScenarioRunner related anymore

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

fabianoboril commented 4 years ago

This still seems to be relevant. According to discord, people still see this issue in CARLA 0.9.10

bernatx commented 4 years ago

I'm working on this issue

zhengsongyue commented 4 years ago

Screenshot from 2020-10-21 12-48-16 Hello, have you fixed this issue? seems like i met the same issue on Ubuntu 18.04.

glopezdiest commented 4 years ago

Hey @zhengsongyue, you seem to not be finding the carla/PythonAPI/carla/agents folder. Can you check that you have the carla/PythonAPI/carla folder added to your PYTHONPATH?

Also, why didn't you create a new issue instead of posting it here? Your error is unrelated to the one above.

TeeManiac commented 4 years ago

I have been working with xml scenario files and everything was working fine. When I tried to run OpenSCENARIO files, only CatalogExample, ChangingWeather and OscControllerExample was working and I am getting the following error when trying to run CyclistCrossing, PedestrianCrossingFront, FollowLeadingVehicle and LaneChangeSimple files.

"current_wp = self._map.get_waypoint(current_loc, lane_type=carla.LaneType.Any) OverflowError: can't convert negative value to unsigned int
can't convert negative value to unsigned int
Destroying ego vehicle 5752
ERROR: failed to destroy actor 5752 : unable to destroy actor: not found
No more scenarios .... Exiting

Desktop

OS: [Windows 10] CARLA Version [CARLA 0.9.10] Python version [3.9.0] Scenario_runner Version [0.9.10]

I've seen that this issue is for Windows. Please help me to resolve this issue.

Screenshot from 2020-10-29 19-36-03

glopezdiest commented 4 years ago

hey @TeeManiac. That's not an ScenarioRunner error but a CARLA one. We recently fixed it with PR's https://github.com/carla-simulator/carla/commit/aedd70911905d1cb80844c55cfc324469de07c90 and https://github.com/carla-simulator/carla/commit/530f56e78b999550670c7e5002b9b740218b8a58.

If you are using CARLA from source I'd recommend either cherrypicking those two commit, or upgrading to current dev branch

TeeManiac commented 4 years ago

@glopezdiest Thank you..it worked now

aakashsehgal commented 3 years ago

@glopezdiest i am facing the same issue on Win10 and Carla 0.9.10 (Binary)...any idea how could this be resolved ?

glopezdiest commented 3 years ago

Unfortunately, you can't change any code of the package so you'd have to either: 1) Upgrade to 0.9.11 2) Get CARLA 0.9.10 from source, apply the PR's and make a new package I'd like to give you a package with those changes but Win10 and Carla 0.9.10 (Binary) is a pretty bad configuration for me to do it on. I'll see if I can do it but I can't promise anything

aakashsehgal commented 3 years ago

Upgrading to 0.9.11 solved the problem. Thanks.