Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more map shifting fixes #791

Merged
merged 8 commits into from
Apr 28, 2021
Merged

more map shifting fixes #791

merged 8 commits into from
Apr 28, 2021

Conversation

sah-huawei
Copy link
Contributor

@sah-huawei sah-huawei commented Apr 23, 2021

Fixed bug where the positions of Sumo vehicles were incorrectly being shifted. After PR #727, they no longer needed to be shifted because the map being used by Sumo now matches the map in the SumoRoadNetwork object.

However, this also exposes a potential problem for external / third-party simulators that might add vehicles directly to Sumo because they may not know about the map shifting and so still have their coordinate systems relative to the unshfited/offset map. So this PR also adds the --allow-offset-map option to scl scenario build to support not auto-shifting maps. Now, maps are only potentially shifted when scenarios are built (as opposed to being auto-shifted whenever SumoRoadNetwork opens an offset map.net.xml file), and this flag can override that at scenario build time if desired/required.

Also, similar to PR #727, use the possibly-shifted road network map if one has been auto-generated for traffic generation.

Closes #790

@sah-huawei sah-huawei linked an issue Apr 23, 2021 that may be closed by this pull request
@sah-huawei sah-huawei changed the title shift traffic generation more map shifting fixes Apr 23, 2021
map_offset = self._scenario.road_network.net_offset
assert len(map_offset) == 2
front_bumper_pos[0] += map_offset[0]
front_bumper_pos[1] += map_offset[1]
Copy link
Contributor

@JingfeiPeng JingfeiPeng Apr 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm, the reason why these are no longer needs is because when building the scenario, it is already using the shifted map thus traffic vehicle coordinates are shifted when built? Please correct me if otherwise.

This part is also somewhat needed when running third-party simulators that add traffic directly to sumo right? if so, it is possible to have a configurable option in sumo_traffic_simulation to control shift coordinates or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, actually the reason is that, as of PR #727 , Sumo is started with the shifted map (thanks to the update to the --net-file parameter in _base_sumo_load_params() in sumo_traffic_simulation.py), so its coordinate system matches the coordinate system in use within Smarts. Vehicle locations coming from Sumo via Traci will be relative to the shifted/offset map already.

However, any third-party simulator that is adding vehicles to Sumo directly (outside of Smarts) may not know about the fact that the scenario map was shifted before Sumo was started. If they were to try to add vehicles to the map via Traci using the original coordinate system, things would seem off to them. So that's what necessitated adding the option to prevent map shifting entirely (i.e., not here, but where the scenario is built) in such situations.

@sah-huawei sah-huawei merged commit fafcbfc into develop Apr 28, 2021
@sah-huawei sah-huawei deleted the shift-trafficgen branch April 28, 2021 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Physics off in 0.4.16 pre-release
3 participants