3. Carla导入openDRIVE地图

本文介绍如何在Carla中使用OpenDRIVE独立模式导入任意OpenDRIVE地图,包括地图导入步骤、关键参数配置及注意事项。该模式允许用户仅使用OpenDRIVE文件进行全仿真模拟。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

OpenDRIVE standalone mode

在其他为默认设置的情况下,将xodr格式文件导入到Carla中的方法可以总结为以下2步:

  1. 将xodr后缀格式的文件,放入到Carla的PythonAPI /util/opendrive文件夹下。
  2. 打开CarlaUE4这一服务器。通过默认的cmd,运行命令 config.py –x opendrive/文件名.xodr。随后CarlaUE4的界面上就能显示出所导入的地图的样式了。

This feature allows users to ingest any OpenDRIVE file as a CARLA map out-of-the-box. In order to do so, the simulator will automatically generate a road mesh for actors to navigate through.
• Overview
• Run a standalone map
• Mesh generation


该功能允许用户将任何OpenDRIVE文件作为即开即用的CARLA 地图。为了做到这一点,模拟器将自动生成一个道路路网供车辆进行导航通过。
Overview(概述)
This mode runs a full simulation using only an OpenDRIVE file, without the need of any additional geometries or assets. To this end, the simulator takes an OpenDRIVE file and procedurally creates a temporal 3D mesh to run the simulation with.
此模式仅使用OpenDRIVE文件运行完整的模拟,而不需要任何其他几何图形或特性。为此,模拟器获取一个OpenDRIVE文件并创建一个临时的3D路网来进行仿真模拟。
产生的路网以极简的方式描述道路的定义。所有元素都将与OpenDRIVE文件相对应,但除此之外,为了防止车辆从路上掉下来,采取了两项措施。
The resulting mesh describes the road definition in a minimalistic manner. All the elements will correspond with the OpenDRIVE file, but besides that, there will be only void. In order to prevent vehicles from falling off the road, two measures have been taken.
• Lanes are a bit wider at junctions, where the flow of vehicles is most complex.
• Visible walls are created at the boundaries of the road, to act as a last safety measure.
• •在车流最复杂的路口,车道要宽一些。
• •在道路的边界上创建了可见的墙,作为最后的安全措施。

Traffic lights, stops and yields will be generated on the fly. Pedestrians will navigate over the sidewalks and crosswalks that appear in the map. All of these elements, and every detail on the road, are based on the OpenDRIVE file. As the standalone mode uses the .xodr directly, any issues in it will propagate to the simulation. This could be an issue especially at junctions, where many lanes are mixed.
交通灯、停车和让行标志将在飞行中产生。行人将行走在地图中的人行道和人行横道。所有这些元素以及道路上的每个细节,都是基于OpenDRIVE文件。由于独立模式直接使用.xodr,因此其中的任何问题都会传播到模拟中。这可能是一个问题,特别是在车道混合的交叉路口路段。
Important
It is especially important to double check the OpenDRIVE file. Any issues in it will propagate when running the simulation.
在这里插入图片描述

Run a standalone map(运行独立地图)
Open an OpenDRIVE file is just a matter of calling client.generate_opendrive_world() through the API. This will generate the new map, and block the simulation until it is ready. The method needs for two parameters.
只需通过API调用client.generate_opendrive_world()即可打开OpenDRIVE文件。这将生成新的映射,并阻塞模拟,直到准备好为止。该方法需要两个参数。
• opendrive is the content of the OpenDRIVE file parsed as a string.
• parameters is a carla.OpendriveGenerationParameters containing settings for the generation of the mesh. This argument is optional.
•OpenDRIVE是被解析为字符串的OpenDRIVE文件的内容。
•参数是 carla.OpendriveGenerationParameters的一个参数,包含了生成路网的相关设置。这个参数是可选的。
o vertex_distance (default 2.0 meters) — Distance between the vertices of the mesh. The bigger, the distance, the more inaccurate the mesh will be. However, if the distance is too small, the resulting mesh will be too heavy to work with.
顶点间的距离:(默认2.0米)-路网顶点之间的距离。距离越大,路网就越不准确。然而,如果距离太小,产生的路网就会太重而无法处理。
o max_road_length (default 50.0 meters) — Maximum length of a portion of the mesh. The mesh is divide in portions to reduce rendering overhead. If a portion is not visible, UE will not render it. The smaller the portions, the more probably they are discarded. However, if the portions are too small, UE will have too many objects to manage, and performance will be affected too.
最大道路长度:(默认为50.0米)-路网部分的最大长度。路网被分成若干部分以减少渲染开销。如果部分不可见,UE将不渲染它。分量越小,就越有可能被丢弃。但是,如果这些部分太小,UE就会有太多的对象需要管理,性能也会受到影响。
o wall_height (default 1.0 meters) — Height of the additional walls created on the boundaries of the road. These prevent vehicles from falling to the void.
墙的高度:(默认1.0米),在道路边界上创建的附加墙体的高度。这样可以防止车辆掉到空中。
o additional_width (default 0.6 meters, 0.3 on each side) — Small width increment applied to the junction lanes. This is a safety measure to prevent vehicles from falling.
额外的宽度:(默认为0.6米,每边0.3米),应用于交叉口车道的小宽度增量。这是防止车辆坠落的安全措施。
o smooth_junctions (default True) — If True, some information of the OpenDRIVE will be reinterpreted to smooth the final mesh at junctions. This is done to prevent some inaccuracies that may occur when various lanes meet. If set to False, the mesh will be generated exactly as described in the OpenDRIVE.
平滑链接:(默认为真),如果为True, OpenDRIVE的一些信息将被重新编译以平滑最终的路网链接。这样做是为了防止在不同的车道相遇时发生一些不准确的情况。如果设置为False,路网将完全按照OpenDRIVE中描述的那样生成
o enable_mesh_visibility (default True) — If False, the mesh will not be rendered, which could save a lot of rendering work to the simulator.
启用路网的可见性:(默认为真),如果为False,路网将不会被渲染,这可以为模拟器节省很多渲染工作。
In order to easily test this feature, the config.py script in PythonAPI/util/ has a new argument, -x or --xodr-path. This argument expects a string with the path to the .xodr file, such as path/example.xodr. If the mesh is generated with this script, the parameters used will always be the default ones.
为了方便地测试这个特性,PythonAPI/util/中的config.py脚本有一个新的参数-x或——xord -path。这个参数需要一个带有.xodr文件路径的字符串,比如path/example.xodr。如果路网是用这个脚本生成的,使用的参数将始终是默认的。
这个功能可以用CARLA提供的新TownBig来测试。
This feature can be tested with the new TownBig provided by CARLA.
python3 config.py -x opendrive/TownBig.xodr
Important
client.generate_opendrive_world() uses content of the OpenDRIVE file parsed as string. On the contrary, config.py script needs the path to the .xodr file.


Mesh generation(路网的生成)
The generation of the mesh is the key element of this mode. The feature can only be successful if the resulting mesh is smooth and fits its definition perfectly. For that reason, this step is constantly being improved. In the last iterations, junctions have been polished to avoid inaccuracies that occur, especially where uneven lanes joined.
路网的生成是该模式的关键。只有最终得到的路网平滑且完美地符合其定义,该特征才能成功。因此,这一步骤正在不断得到改进。在最后的迭代中,路口已经被抛光,以避免出现不准确,特别是在不均匀的车道连接。
在这里插入图片描述

When generating junction meshes, higher lanes tend to block the ones below them. The parameter smooth_junctions prevents this kind of issue.
在生成结点网格时,较高的车道往往会阻塞较低的车道。参数smooth_junction防止了这类问题。

Besides that, instead of creating the whole map as a unique mesh, different portions are created. By dividing the mesh, the simulator can avoid rendering portions that are not visible, and save up costs. Working smaller also allows to generate huge maps and contain issues that may occur on a small portion of the mesh.
除此之外,不是创建整个地图作为一个独特的网格,而是创建不同的部分。通过划分网格,模拟器可以避免渲染不可见的部分,并节省成本。更小的工作也允许产生巨大的地图和包含问题,可能发生在网格的一小部分。
对于当前网格生成的状态,需要考虑一些问题。
Regarding the current state of the mesh generation, some considerations should be taken into account.
• Junction smoothing. The default smoothing prevents the issues at tilted junctions described above. However, it will modify the original mesh in the process. Set smooth_junctions to False to disable the smoothing if preferred.
• 连接平滑。默认的平滑防止了上面描述的倾斜节点的问题。但是,它会在这个过程中修改原来的网格。将“平滑节点”设置为False可以禁用平滑效果。
• 横向坡度。这个特性目前还没有集成到CARLA中。
• Lateral slope. This feature is currently not integrated in CARLA.
• 人行道高度。目前,所有人行道的赢编码都是一样的。人行道必须高于道路水平,才能检测到碰撞,但RoadRunner不会将此值导出到OpenDRIVE文件。高度是硬编码的,以保证碰撞。
• Sidewalk height. This is currently hard-coded for all the sidewalks the same. Sidewalks must be higher than the road level for collisions to be detected, but RoadRunner does not export this value to the OpenDRIVE file. The height is hard-coded to guarantee collisions.
That covers all there is to know so far, regarding the OpenDRIVE standalone mode. Take the chance and use any OpenDRIVE map to test it in CARLA.
这涵盖了到目前为止关于OpenDRIVE独立模式的所有知识。抓住机会,使用任何OpenDRIVE地图在Carla中测试它。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值