.osm格式转.xodr报错:Only unshifted Coordinate systems are supported 解决办法

注:实际使用发现,这个只是个warning,并不影响最终结果的输出,不需要修改,保留原样就好​​​​​​​

今天在使用OpenStreetMap导出了osm格式的文件,想给Carla使用,就使用了官网的提供的Python代码来准换为xodr格式:

import io

# Read the .osm data
f = io.open("test", mode="r", encoding="utf-8")
osm_data = f.read()
f.close()

# Define the desired settings. In this case, default values.
settings = carla.Osm2OdrSettings()
# Set OSM road types to export to OpenDRIVE
settings.set_osm_way_types(["motorway", "motorway_link", "trunk", "trunk_link", "primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link", "unclassified", "residential"])
# Convert to .xodr
xodr_data = carla.Osm2Odr.convert(osm_data, settings)

# save opendrive file
f = open("path/to/output/file", 'w')
f.write(xodr_data)
f.close()

运行后发现报错了:

Warning: Could not write OpenDRIVE geoReference. Only unshifted Coordinate systems are supported (center_map and use_offsets need to be set to False)

其实问题很简单,已经提示是 center_map use_offsets 的问题,但是要先意识到要查官方文档,链接:https://carla.readthedocs.io/en/latest/python_api/

(我使用的Carla是最新的0.9.12版本,大概8月初更新的)

在Osm2OdrSettings的Instance Variables 可以看到这两个参数。

所以只需要在代码中加上settings.center_map =False;即可

修改后:

import io

# Read the .osm data
f = io.open("test", mode="r", encoding="utf-8")
osm_data = f.read()
f.close()

# Define the desired settings. In this case, default values.
settings = carla.Osm2OdrSettings()
# Set OSM road types to export to OpenDRIVE
settings.set_osm_way_types(["motorway", "motorway_link", "trunk", "trunk_link", "primary", "primary_link", "secondary", "secondary_link", "tertiary", "tertiary_link", "unclassified", "residential"])

#修改开始,添加新设置
settings.use_offsets =False;
settings.center_map =False;
#修改结束

# Convert to .xodr
xodr_data = carla.Osm2Odr.convert(osm_data, settings)

# save opendrive file
f = open("path/to/output/file", 'w')
f.write(xodr_data)
f.close()

 附:

 查看0.9.12的更新发现,center_map是这个版本才加入的变量:

所以无论在百度还是谷歌的相关的介绍和错误解决方法都很少, 记录下来给后来学习的人少踩坑。

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值