高级汽车物理系统(C++)
您应该升级到
Wheeled vehicles are widely used in various simulations. The high-level Car Physics system, implemented as a set of C++ components, is intended to simplify creation of realistic wheeled vehicles in UNIGINE. It minimizes efforts required to create virtually any wheeled vehicle, be it a 4WD SUV, an exploration rover, or a sophisticated multi-axle transporter.轮式车辆在各种模拟中被广泛使用。高级汽车物理系统,实现为一组 C++组件,旨在简化在UNIGINE中创建逼真的轮式车辆。它最大限度地减少了创造几乎任何轮式车辆所需的努力,无论是四驱车SUV,探索漫游者,还是复杂的多轴运输车。
The following features are available:提供以下特性:
- Setting the engine power and resistance curves, as well as idle speed (RPM)设置发动机功率和阻力曲线,以及怠速(RPM)
- Gearbox simulation (manual and automatic) enabling you to adjust throttle an speed values for shifting gears along with transition time, as well as to set the number of gears and configure gear ratios变速箱模拟(手动和自动),使您能够调整油门和速度值的换挡随着过渡时间,以及设置齿轮的数量和配置齿轮比
- Mathematical wheel model for more realistic steering, enabling simulation of forces affecting the rotating wheel, along with an ability to adjust suspension travel distance, spring, and damping values数学车轮模型,更真实的转向,能够模拟影响旋转车轮的力,以及调整悬挂行程距离,弹簧和阻尼值的能力
- Easy setup of steering and driving axes along with capability to turn the differential lock on and off易于设置转向和驱动轴,并具有打开和关闭差速锁的能力
- A set of debug windows displaying information on all vehicle parameters in real time一组调试窗口实时显示所有车辆参数的信息
- Switching between different views (driver's, external camera, etc.)在不同视图之间切换(司机的,外部摄像头等)
- Simulation of various surface conditions (such as dry, wet, snow-covered, or icy road, mud, and so on)模拟各种表面条件 (如干燥、潮湿、积雪或结冰的道路、泥泞等)
Instructions given below cover the process of creation of a wheeled vehicle using the High-Level Vehicle demo from the SDK in a new empty project. The step-by-step guide will take you through the process of creating all necessary nodes and configuring component parameters you need to have a functional vehicle, assuming that you have a model of the vehicle's body and models of its wheels at your disposal.下面给出的说明涵盖了在一个新的空项目中使用SDK的 High-Level Vehicle 演示创建轮式车辆的过程。假设您拥有车辆的车身模型和车轮模型,那么分步指南将带您完成创建所需的所有必要节点和配置所需的组件参数的过程。
See also另请参阅#
- The C++ Component System article to learn more about implementing logic in C++ using components.C++ 组件系统文章了解有关使用组件在c++中实现逻辑的更多信息。
- The High-Level Vehicle demo included in the SDK.SDK中包含的High-Level Vehicle 演示。
Step 1. Prepare a Project步骤1。准备一个项目#
First, we should prepare a project and get all necessary source files containing implementation of components from the demo. So, we perform the following actions:首先,我们应该准备一个项目,并得到所有必要的源文件包含实现组件的示例。所以,我们执行以下动作:
- Open your new project's source folder and create the new vehicle_components folder in it.打开您的新项目的源文件夹,创建新的vehicle_components文件夹。
- Then open the source/vehicle_sample folder of the demo and copy all the files it contains to the vehicle_components folder that you've just created.打开source/vehicle_sample文件夹并将其包含的所有文件复制到刚刚创建的vehicle_components文件夹中。
- Open your project in the IDE and add all source files from the vehicle_components folder to it.在IDE中打开您的项目,并将vehicle_components文件夹中的所有源文件添加到其中。
-
Add initialization code for C++ Component System to the AppSystemLogic::init() method:对于C++组件系统初始化代码添加到AppSystemLogic::init()方法:
#include <UnigineComponentSystem.h> /* ... */ int AppSystemLogic::init() { /* ... */ // initialize ComponentSystem and register all components Unigine::ComponentSystem::get()->initialize(); /* ... */ }
- Build and run your project to register all components and generate necessary properties. We are going to use these properties later to configure our vehicle. Meanwhile, we can proceed to the next step.构建并运行项目以注册所有组件并生成必要的属性。稍后我们将使用这些属性来配置我们的车辆。与此同时,我们可以进行下一步。
Step 2. Prepare Your Vehicle Model步骤2。准备车辆模型#
Next, we create a model representing the vehicle's body and a model for vehicle's wheels (or several models, depending on how many different types of wheels your vehicle has).接下来,我们创建一个代表车辆车身的模型和一个代表车辆车轮的模型(或者几个模型,这取决于您的车辆有多少种不同类型的车轮)。
The Y axis of all models (including wheels) should be pointing forward. So, you can't just make a copy of a wheel and rotate it around the Z axis by 180 degrees.所有型号(包括车轮)的Y轴应指向前方。所以,您不能复制一个轮子然后绕Z轴旋转180度。
The scale of all models should be equal to 1 along all axes, to ensure correct physics simulation.所有模型的规模应该等于1沿着所有轴,以确保正确的物理模拟。
Step 3. Create Node Hierarchy步骤3。创建节点层次结构#
In order for the system to work, your vehicle's hierarchy should be properly organized. The following hierarchy is recommended:为了使系统工作,您的汽车的层次结构应该适当的组织。以下推荐等级:
All nodes in the hierarchy, except for the vehicle's body and wheels, are Node Dummy. These Node Dummy serve only to organize the components logic and have an identity transform matrix, except for the center_of_mass, as its position defines the position of the vehicle's center of mass in the local coordinates of the vehicle's body (must have the body as parent).层次结构中的所有节点(除了车身和车轮)都是Node Dummy。这些Node Dummy只用于组织组件逻辑并具有单位变换矩阵,除了center_of_mass,因为它的位置定义了车辆质心在车身局部坐标中的位置(必须以车身为父)。
Step 4. Engage Physics步骤4。使物理#
Then, we should assign a rigid body to the object representing the vehicle's body and disable the Shape-Based option for it, to turn off automatic calculation as inertia, mass, and center of mass are specified in the component. Then, add necessary number of physical shapes to specify the geometry of the body.然后,我们应该将刚体分配给表示车身的对象,并禁用它的Shape-Based选项,以关闭自动计算,因为惯性、质量和质心都在组件中指定。然后,添加必要数量的物理形状,以指定主体的几何形状。
Step 5. Assign and Configure Components步骤5。分配和配置组件#
At this stage we assign component properties generated at Step 1 and configure necessary parameters for the engine, transmission, wheels, etc.在此阶段,我们分配在 步骤1生成的组件属性,并为发动机、变速器、车轮等配置必要的参数。
Configure Vehicle Body车身配置#
Assign the car component to the object representing the vehicle's body. For this component we should specify necessary car characteristics, such as dimensions, mass, frontal area, etc. along with the number of iterations, which defines joints simulation accuracy. Here we also set up links to Node Dummy with other logic components assigned (engine, gearbox, transfer case, wheels, axles). 将 car 组件分配给表示车身的对象。 对于这个组件,我们应该指定必要的汽车特性,例如尺寸、质量、正面面积等,以及定义关节模拟精度的迭代次数。 在这里,我们还设置了指向 Node Dummy 的链接,并分配了其他逻辑组件(引擎,齿轮箱, 分动箱,轮子,轴)。
Iterations | The number of iterations used to solve joints. If the value is too low, the precision of calculations will suffer.用于求解关节的迭代次数。如果该值过低,计算的精度将受到影响。 |
---|---|
Car Body Node | Object representing the car body.表示车身的对象。 |
Size | Car dimensions, in meters (width, length, height).汽车尺寸,以米为单位(宽、长、高)。 |
Mass |
Vehicle mass, in kilograms. A lifelike value is to be used. Higher values increase the car stability when colliding with other cars. Along with that, higher values increase inertia thus requiring enhanced brakes and springs, better greep of wheels, etc.车辆质量,单位是千克。要使用逼真的值。更高的数值增加了汽车与其他汽车碰撞时的稳定性。与此同时,更高的数值增加了惯性,因此需要增强制动器和弹簧,更好的车轮greep等。 This value affects numerous aspects of the vehicle behavior, therefore it's better to set it first.这个值会影响车辆行为的许多方面,因此最好先设置它。 |
Driving Efficiency | Multiplier of the gear ratio. The efficiency of the whole transmission — all moving parts from wheels to the gearbox. Higher values mean less inertia and resistance in the gearbox.传动比倍增器。整个传动系统的效率——从车轮到变速箱的所有运动部件。更高的数值意味着变速箱中的惯性和阻力更小。 |
Movement Resistance | The effect of resistance to the movement. The higher the value, the more the wheels resist rotation (transmitting this resistance to the engine, reducing its power). The effect is amplified by large and heavy wheels.阻力对运动的影响该值越高,车轮就越抵抗旋转(将这种抵抗传递给发动机,降低其功率)。这种效果被又大又重的车轮放大了。 |
Moving Transmission Parts Inertia | Inertia multiplier for moving parts of transmission used to calculate the vehicle moment of inertia. The higher the value, the more inert the gearbox is.惯量乘法器用于计算变速器运动部件的车辆惯量。该值越高,说明齿轮箱的惰性越强。 |
Air Density | Air density that affects downforce. The faster you drive, the more the car is pressed against the asphalt, while at the same time control is improved due to increased road grip. It is recommended to keep this value unchanged and adjust the CarFrontalArea and ShapeResistanceCoefficient parameters, if required.影响下压力的空气密度。您开得越快,车就越容易被压在沥青上,而与此同时,由于增加了路面抓地力,控制也得到了改善。建议保持该值不变,并根据需要调整CarFrontalArea和ShapeResistanceCoefficient参数。 |
Car Frontal Area | Maximum cross-sectional area of the vehicle used for calculation of the drag coefficient (less for cars, more for trucks).用于计算阻力系数的车辆的最大横截面积(轿车较小,卡车较大)。 |
Shape Resistance Coefficient | Drag coefficient of the shape which can be obtained experimentally in the wind tunnel (more in cars, less in trucks).外形的阻力系数,可以在风洞实验中获得(在汽车中更多,在卡车中更少)。 |
Clutch Sync Factor | Clutch multiplier, the degree of synchronization between the engine and the gearbox. The higher the value, the more the engine rpm drops when torque is transmitted.离合器倍增器,发动机与变速箱之间的同步程度。该值越高,传递扭矩时发动机转速下降越多。 |
Center Of Mass | Reference to the node that is the vehicle's center of mass. This node affects the wind resistance and stability of the vehicle. The closer it is to the ground, the higher is the stability. If the center of mass is below the ground, the behavior may feel unrealistic when the car rolls over.参考节点,即车辆的质心。这个节点影响车辆的抗风能力和稳定性。离地面越近,稳定性越高。如果重心在地面以下,当汽车翻滚时,这种行为可能会让人感觉不现实。 |
Input | Node with a vehicle input interface component assigned.分配了车辆输入接口组件的节点。 |
Engine | Node with a vehicle engine component assigned.分配了一个vehicle 引擎组件的节点。 |
Gearbox | Node with a vehicle gearbox component assigned.分配了车辆变速箱组件的节点。 |
Transfer Case | Node with a vehicle transfer case component assigned.分配了车辆转运箱组件的节点。 |
Axles | Nodes with a vehicle axle component assigned. Axles are to be specified in the front-to-rear order.分配了车辆轴组件的节点。轴按从前到后顺序指定。 |
Engine引擎#
Assign the car_engine component to the engine Node Dummy and specify necessary engine parameters, such as maximum, minimum, and idle rpm values, inertia of moving parts of the transmission and set up dependencies for torque and resistance on rpm.将 car_engine 组件分配给 engine Node Dummy 并指定必要的引擎参数,例如每分钟最大、最小,和 怠速值,传动运动部件的惯性并设置扭矩和阻力对每分钟速率的依赖关系。
Min RPM | Minimum engine rotation per minute. If the engine RPM is less than this value, the engine is considered to have stalled.发动机每分钟最小转速。如果发动机的RPM小于此值,则认为发动机已熄火。 |
---|---|
Max RPM | Maximum engine rotation per minute.发动机每分钟最大转速。 |
Idle RPM | Idle engine rotation per minute, when the vehicle is not moving and the gas pedal is not pressed.怠速发动机每分钟转一圈,当车辆不移动且油门踏板未踩下时。 |
Inertia | Moment of inertia of the engine moving parts. Higher values mean slower changes in engine RPM.发动机运动部件的转动惯量。数值越高,意味着发动机转速变化越慢。 |
Idle Throttle | Automatic throttle level helping to keep stable idle rpm. It defines the minimum throttle plate position, if the engine RPM is less than minimum (idle).自动油门水平有助于保持稳定的怠速转速。它定义了最小节流阀板的位置,如果发动机转速小于最小(怠速)。 |
RPM - Torque | Correlation between the engine RPM and Torque. Specific torque values can be set for various RPMs. Changing the value affects speed and acceleration.发动机转速和扭矩之间的关系。具体的扭矩值可以设置不同的rpm。改变该值会影响速度和加速度。 |
RPM - Resistance | Correlation between the engine RPM and Resistance — friction of the internal engine details depending on the RPM changes. Higher resistance values mean that the vehicle will pick up speed less.发动机转速和阻力之间的相关性-内部发动机细节的摩擦取决于转速的变化。较高的电阻值意味着车辆的加速速度越慢。 |
Formulas applied in the engine implementation:引擎实现中应用的公式:
- result_torque = torque - resistance - gearbox_resistance * clutchResult_torque =转矩-阻力-变速箱-阻力*离合器
- result_inertia = inertia + gearbox_inertia * clutchresult_惯性=惯性+齿轮箱惯性*离合器
- current_rpm += result_torque / result_inertiaCurrent_rpm += result_torque / result_inertia
Gearbox齿轮箱#
Assign the car_gearbox component to the gearbox node. Here we set transmission type (MT or AT), specify all gear numbers and shifting time. This component also controls switching between the gears (AT), so for each gear we should set throttle and speed values for switching up or down to the next gear.将car_gearbox组件分配给gearbox节点。这里我们设置变速器类型(机械传动或自动传动),指定所有档位和换挡时间。这个组件还控制在档位(自动传动)之间的切换,因此对于每个档位,我们应该设置 throttle 和 speed 值,以便向上或向下切换到下一个档位。
The array of gear values must contain at least 3 elements: neutral, first front, and rear. Tables describing Up and Down switching sequences should have the number of elements equal to the number of transitions: number of forward gears - 1. For example, for a 3-speed gearbox we have:档位值数组必须至少包含 3 元素:空档、第一档和后档。 描述向上和向下切换序列的表的元素数量应等于转换数量: 前进档数 - 1。 例如,对于 3 速变速箱,我们有:
- 1 -> 2
- 2 -> 3
Gear Values | Gear ratio at each stage. The first element is set for neutral, and the last one is for the reverse. Higher values mean a higher output (it will be easier for the vehicle to climb the hill) at a slower speed (wheels rotate slower). Usually the gear values are in descending order. Adjust these values if you want a faster car (higher values at the beginning and lower values at the end).每个阶段的传动比。第一个元素设置为中性,最后一个元素设置为相反。更高的数值意味着更高的输出(车辆在较慢的速度下更容易爬坡)(车轮转动较慢)。通常齿轮值按降序排列。如果您想要一辆更快的车,可以调整这些值(开始的值更高,结束的值更低)。 |
---|---|
Automatic | If enabled, the transmission is automatic (AT), if disabled, the transmission is manual (MT).如果启用,传输是自动的(AT),如果禁用,传输是手动的(MT)。 |
Shift Time | Interval for switching between gears, in seconds.换档间隔,以秒为单位。 |
Gear Switching Sequence Up | Array of conditions describing the sequence of switching the gears up: the Throttle value (0, 1] and current speed in km/h. The first row corresponds to switching 1->2, the second one 2->3, etc.描述换挡顺序的条件数组:油门值(0, 1]和当前速度(km/h)。第一行对应切换1->2,第二行对应切换2->3,以此类推。 |
Gear Switching Sequence Down | Array of conditions describing the sequence of switching the gears down: the Throttle value (0, 1] and current speed in km/h. The first row corresponds to switching 2->1, the second one 3->2, etc.描述换档顺序的条件数组:节流阀值(0, 1]和当前速度(km/h)。第一行对应于切换2->1,第二行对应于切换3->2,以此类推。 |
Transfer Case分动箱#
Assign the car_tranfer_case component to the transfer_case Node Dummy. Specify necessary parameters and configure torque distribution for all axles in the front-to-back order.将 car_tranfer_case 组件分配给 transfer_case Node Dummy。指定必要的参数和配置所有轴的扭矩分布从前到后的订单。
Low Gear | Lower gear ratio. It is used to make it easier to pass difficult off-road sections, where the full power of the engine is required, and speed is not important.较低的传动比。它是用来使它更容易通过困难的越野路段,在那里需要发动机的全功率,速度并不重要。 |
---|---|
High Gear | Higher (regular) gear ratio.更高的(常规)传动比。 |
Is Used | If enabled, transfer case is used. If disabled, an even distribution of torque and rpm from the transmission is used between all axles.如果启用,则使用转移箱。如果禁用,扭矩和每分钟转数从变速器的均匀分布是在所有轴之间使用。 |
Has Inter-Axle Lock | Inter-axle lock. Used on off-the-road vehicles.轴间锁。用于越野车辆。 |
Dynamic Lock | Dynamic inter-axle differential locking. If this option is enabled, the lock can be enabled when the vehicle is moving on receiving the information that its wheels have started to spin.动态轴间差动锁紧。如果启用此选项,当车辆在接收到其车轮已开始旋转的信息时,可以启用锁。 |
Torque Distribution | Torque distribution between all axles of the vehicle, in percent. The sum must be equal to 100%.车辆所有轴之间的扭矩分配,以百分比表示。总和必须等于100%。 |
Axles轴#
Assign the car_axle component to every Node Dummy representing vehicle's axles (e.g. front_axis and rear_axis). You can create as many axles as you need. For each axle, attach nodes representing wheels as children, and specify them in the corresponding fields of the car_axle component.将 car_axle 组件分配给每个代表车辆轮轴的 Node Dummy(例如 front_axis 和 rear_axis)。您可以创建您需要尽可能多的轴。对于每个轴,附加轮子节点作为子节点,并指定他们的对应字段car_axle组件。
Then specify if the axle is a steering/driving one, if it has a locking differential, etc.然后指定车轴是否为转向/驱动轴,是否有锁定差速器等等。
Main Gear Ratio | Main gear ratio, the difference between what goes to the axle and what goes to wheels.主齿轮传动比,传递给车轴和车轮的传动比之差。 |
---|---|
Driving | Indicates if the axle is the driving one.指示轴是否为驱动轴。 |
Steering | Indicates if the axle is the steering one (i.e. whether the wheels on this axis are turned).指示该轴是否为转向轴(即该轴上的车轮是否转动)。 |
Max Steering Angle | The maximum angle of the wheel rotation, in degrees (relative to the steering axis, Z-axis). Affects the ease of turning in tight places.车轮旋转的最大角度,以度为单位(相对于转向轴,z轴)。影响在狭窄的地方转弯的便利性。 |
Use Handbrake | Indicates if the axle is affected by the handbrake.指示车轴是否受到手刹的影响。 |
Locking Differential | Indicates if the axle has interwheel locking, which is required for off-road vehicles to drive safely in the mud. If it is turned on, it is easier to drive in the mud keeping your wheels straight, but turning corners will be harder, because while turning the wheels should rotate at different speed, however with locking turned on, they start rotating at the same speed, which increases the risk of drifting.指示车轴是否有轮间锁紧,这是越野车辆在泥浆中安全行驶所必需的。如果锁紧装置开启,在泥泞中行驶会更容易保持车轮笔直,但转弯会更困难,因为在转弯时车轮应该以不同的速度旋转,但是当锁紧装置开启时,它们开始以相同的速度旋转,这增加了漂移的风险。 |
Dynamic Lock | Indicates if locking differential can be toggled on and off, while the vehicle is moving. It works only if Locking Differential is enabled.指示当车辆行驶时,锁定差速器是否可以开关。只有启用了Locking Differential,它才会起作用。 |
Right Wheel Node | Link to the node representing the right wheel of the axle (relative to forward direction).链接到表示轴右轮的节点(相对于前进方向)。 |
Left Wheel Node | Link to the node representing the left wheel of the axle (relative to forward direction).链接到代表轴左轮的节点(相对于前进方向)。 |
Wheels轮子#
Assign the car_wheel component to all nodes representing vehicle's wheels. By adjusting the parameters of this component we can simulate different physical behavior of the vehicle with various types of wheels. Here you can set up wheel mass and radius, friction and additional forces, as well as suspension parameters.将car_wheel组件分配给所有表示车辆车轮的节点。通过调整该组件的参数,我们可以模拟具有不同类型车轮的车辆的不同物理行为。在这里,您可以设置车轮质量和半径,摩擦力和附加力,以及悬挂参数。
You can enable the Use General Settings option and specify a preset property with general wheel settings for a certain wheel type in the General Settings field to override values of component parameters. This simplifies configuration process: you set all required parameter values for a certain wheel type in a dedicated property, and then use this property for all similar wheels.您可以启用Use General Settings选项,指定一个预设属性与一般轮设置一定轮类型General Settings领域覆盖组件参数的值。这简化了配置过程:您设置一定轮所需的所有参数值类型在一个专用的属性,然后使用这个属性对所有类似的轮子。
Suspension settings are to be set indivudually for each car by eye. These settings affect the vehicle bouncing, rigidity and wind resistance when driving over bumps and around tight corners.悬挂设置为每辆车单独设置。这些设置影响车辆的弹跳,刚性和风阻力,当驾驶颠簸和周围的急转弯。
General | |
---|---|
Wheel Node | Node representing the wheel. A single mesh should be used for dual wheels.代表轮子的节点。双轮应使用单网。 |
Use General Settings | Enabling this option allows using a preset property specified in the General Settings field. This property contains general wheel settings for a certain wheel type to override values of the component parameters listed below. This can be used to simplify configuration process: you set all required parameter values for a certain wheel type in a dedicated property, and then enable this option and assign this property to the field below.启用此选项允许使用在General Settings字段中指定的预设属性。此属性包含特定车轮类型的一般车轮设置,以覆盖下面列出的组件参数的值。这可以用来简化配置过程:您可以在专用属性中为特定车轮类型设置所有必需的参数值,然后启用该选项并将该属性分配给下面的字段。 |
General Settings | Preset property with general wheel settings for a certain wheel type to be used instead of the values of the component parameters listed below.预设属性,具有要使用的特定车轮类型的一般车轮设置,而不是下面列出的组件参数值。 |
Mass | Wheel mass, in kilograms. Setting a higher value requires a more powerful engine to rotate the wheel.车轮质量,单位是千克。设置更高的值需要更强大的发动机来旋转车轮。 |
Radius | Wheel radius, in meters.车轮半径,单位是米。 |
Joint Parameters | |
Linear Restitution | Linear stiffness of the joint. In the physical engine, the wheel and the vehicle body are two different bodies, not connected to each other. When these bodies move apart, the restitution value controls the amount of force applied to both bodies so that their fulcrums are aligned again. At the value of 1.0 all the energy from hitting the wheel is transferred to the body instantly. At the value of 0.5 the wheel moves slightly relative to the body. It imitates the suspension arms reducing the impact.关节的线性刚度。在物理发动机中,车轮和车身是两个不同的主体,彼此之间没有连接。当这些物体分开时,恢复值控制施加在两个物体上的力的大小,使它们的支点再次对齐。在1.0值时,所有撞击车轮的能量立即传递到身体上。当值为0.5时,车轮相对于物体稍微移动。它模仿悬挂臂减少冲击。 |
Angular Restitution | Angular stiffness of the joint. This value is similar to Linear Restitution, but affects rotation: it controls the effect of the vehicle body rotation on the wheel rotation and vice versa.关节的角刚度。这个值类似于Linear Restitution,但是会影响旋转:它控制车身旋转对车轮旋转的影响,反之亦然。 |
Linear Softness | Linear elasticity of the wheel joint. Defines whether linear velocities of the bodies are averaged out when the joint is stretched. The value of 0 means that the joint is rigid.车轮关节的线弹性。定义当关节被拉伸时,物体的线速度是否平均。取值为0表示该节点为刚性节点。 |
Angular Softness | Angular elasticity of the wheel joint. Defines whether angular velocities of the bodies are averaged out when the joint is twisted. The value of 0 means that the joint is rigid.车轮关节的角弹性。定义关节扭曲时物体的角速度是否平均。取值为0表示该节点为刚性节点。 |
Suspension | |
Suspension Damping | Linear damping coefficient of the suspension. Higher values ensure faster vibration damping of the vehicle when driving over the bumps.悬架的线性阻尼系数。更高的值确保车辆在行驶颠簸时更快地减振。 |
Suspension Spring | Suspension spring rigidity coefficient determining how strong the spring resists the vertical linear motion. If set to 0, the spring is disabled. Higher values cause more bouncing when hitting the curb.决定弹簧抵抗垂直直线运动的强度的悬架弹簧刚度系数。如果设置为0,则禁用该弹簧。更高的数值会在撞到路边时产生更多的弹跳。 |
Suspension Distance From | The lowest possible position of the wheel (relative to the initial position). This value together with Suspension Distance To forms the height of the vehicle suspension. The more this interval is, the easier it is for the vehicle to drive over bumps, but at the same time it becomes more wobbly.车轮的最低可能位置(相对于初始位置)。该值与Suspension Distance To一起构成车辆悬架的高度。这个间隔越长,车辆越容易越过颠簸,但同时也会变得更不稳定。 |
Suspension Distance To | The highest possible position of the wheel (relative to the initial position). This value together with Suspension Distance From forms the height of the vehicle suspension. The more this interval is, the easier it is for the vehicle to drive over bumps, but at the same time it becomes more wobbly.车轮的最高可能位置(相对于初始位置)。该值与Suspension Distance From一起构成车辆悬架的高度。这个间隔越长,车辆越容易越过颠簸,但同时也会变得更不稳定。 |
Suspension Target Distance | Suspension height at rest, the value between the Distance From and Distance To values. The suspension spring, if enabled, tries to keep the specified height.静止时的悬架高度,介于Distance From和Distance To之间的值。如果启用悬架弹簧,则会尝试保持指定的高度。 |
Braking | |
Max Brake Damping | Maximum damping coefficient of the brake.制动器的最大阻尼系数。 |
Max Handbrake Damping | Maximum damping coefficient of the handbrake.手刹的最大阻尼系数。 |
Tire | |
Tire Damping | Damping coefficient of the tire. This value adds up to Max Brake Damping and Max Handbrake Damping. Can be perceived as the resistance of the wheels to air flow.轮胎的阻尼系数。该值的总和为Max Brake Damping和Max Handbrake Damping。可以理解为车轮对气流的阻力。 |
Friction | |
Forward Friction | Longitudinal friction of the tires. Higher values reduce the likelihood of wheels spinning in place. This value also may enhance acceleration and improve braking performance.轮胎的纵向摩擦。较高的值减少车轮原地打转的可能性。这个值也可以增强加速和改善制动性能。 |
Lateral Friction | Transverse friction of the tires. Higher values reduce the likelihood of drifting (for the front wheels) or skidding (for the rear wheels) also increasing the steerability — the vehicle seems to turn sharper and faster.轮胎的横向摩擦。更高的数值减少了漂移(前轮)或打滑(后轮)的可能性,也增加了方向盘的可转向性——车辆似乎转得更快更锋利。 |
Additional Forces | |
Forward Factor | Coefficient specifying how fast the optimum longitudinal force can be achieved. Higher values increase the impulse produced by the tire.指定达到最佳纵向力的速度的系数。数值越高,轮胎产生的冲量就越大。 |
Lateral Factor | Coefficient specifying how fast the optimum lateral force can be achieved. Higher values increase the impulse produced by the tire.指定能多快达到最佳横向力的系数。数值越高,轮胎产生的冲量就越大。 |
Threshold Factor | Threshold value between the wheel and "ground" velocities. If the value is too small, the longitudinal force is scaled down to prevent unnatural vibrations.车轮和“地面”速度之间的阈值。如果该值太小,则纵向力按比例减小以防止不自然的振动。 |
Step 6. Set Up Input Controls步骤6。设置输入控件#
You can choose to use various types of input devices to control your vehicle, be it a joystick or a gamepad, a driving wheel or a keyboard. The following NodeDummy hierarchy is recommended to implement user input handling:您可以选择使用不同类型的输入设备来控制您的车辆,无论是操纵杆或手柄,驱动轮或键盘。推荐以下NodeDummy层次结构来实现用户输入处理:
The car_input_manager component implements vehicle control and enables simultaneous handling of input events from several input devices. It contains an array of nodes (NodeDummy), each having the corresponding input component (car_keyboard_input, car_joystick_input, or car_gamepad_input) assigned. Each component implements input handling for the corresponding device.car_input_manager组件实现车辆控制,并支持同时处理来自多个输入设备的输入事件。它包含一个节点数组(NodeDummy),每个节点都分配了相应的输入组件(car_keyboard_input,car_joystick_input,or car_gamepad_input)。每个组件为相应的设备实现输入处理。
Input events can be generated by either of the following:输入事件可以通过生成下列:
- ButtonButton
- Axis - can be either a physical axis of the controller, or it can be imitated with buttons 强轴——可以是一个物理轴控制器的,也可以是模仿与按钮
So here we simply configure necessary buttons and axes. Several options are available for an axis:因此,在这里我们只需配置必要的按钮和轴。一个轴有几个选项:
- Full - full axis range: [-1, 1]Full -全轴范围:[-1,1]
- Positive range - only the positive range of axis values is taken: [0, 1]Positive range 只取轴值的正范围:[0,1]
- Negative range - only the negative range of axis values is taken: [-1, 0]Negative range 只有负轴值的范围是:[-1,0]
- Full to positive - converts values in the full [-1, 1] range to values in the positive [0, 1] rangeFull to positive 将完整的[-1,1]范围的值转换为正的[0,1]范围的值
- Full to negative - converts values in the full [-1, 1] range to values in the negative [-1, 0] range在完整的0 Full to negative 转换值[-1,1]范围在- [-1,0]值范围
The NONE value for a button indicates that it's not used.按钮的NONE值表示它没有被使用。
Debug Configuration (Optional)Debug Configuration (Optional)#
Convincing simulation of any vehicle requires fine-tuning. To simplify the process of adjusting parameters, a set of debug windows displaying various vehicle parameters (engine, transmission, wheels, etc.) is at your disposal.任何令人信服的模拟车辆需要微调。简化调整参数的过程中,一系列的调试窗口显示各种车辆参数(发动机、变速箱、车轮等)在您的处置。
In order to enable the debug option, you should create the following hierarchy of Node Dummy (they're just used to enable component logic) and assign the corresponding components to them as shown below:为了启用调试选项,您应该创建以下Node Dummy的层次结构(它们只是用于启用组件逻辑),并将相应的组件分配给它们,如下所示:
Switching Views (Optional)切换视图(可选)#
You can switch between the driver's view and other custom views (e.g. external cameras, etc.). Suppose you have various cameras (players) added to the scene and placed at desired locations. To enable switching between them, simply add a Node Dummy to the scene and assign the camera_switcher component to it. Then, in the Input field, specify the node responsible for input handling, that we added at Step 6. And, finally, specify the number of cameras you want to use, and drag the corresponding Player nodes to the fields of the Cameras parameter. All available cameras will be switched in a looped sequence according to the order they are listed.您可以在驾驶员视图和其他自定义视图(例如外部摄像头等)之间切换。假设您将各种摄像机(Player)添加到场景中,并放置在所需的位置。要在它们之间进行切换,只需向场景中添加一个Node Dummy,并将camera_switcher组件分配给它。然后,在Input字段中,指定负责输入处理的节点,即我们在 Step 6添加的节点。最后,指定要使用的摄像机数量,并将相应的Player节点拖到Cameras参数的字段中。所有可用的摄像机将根据它们列出的顺序按循环顺序进行切换。
Road Surface Conditions Simulation路面条件模拟#
Driving simulation would be incomplete without the ability to set various surface conditions, such as dry, wet, snow-covered, or icy road, mud, etc. You can simulate various surface conditions by setting up friction coefficients and specifying masks to define areas of the Landscape Terrain for them.驾驶模拟将是不完整的没有设定各种表面条件的能力,如干燥、潮湿、冰雪覆盖,或结冰的道路,泥浆等。您可以模拟各种表面条件通过建立摩擦系数并指定Landscape Terrain的面具来定义区域。
To enable simulation of surface conditions add a Node Dummy to the scene and assign the friction_controller component to it. Then specify masks of Landscape Terrain defining the areas to which the values of longitudinal (forward) and lateral friction will be applied.为了启用表面条件的模拟,在场景中添加一个Node Dummy,并将friction_controller组件分配给它。然后指定掩码Landscape Terrain定义将应用纵向(向前)和横向摩擦值的区域。
Now you can mark areas with different surface conditions on your terrain and fine-tune your vehicle using the debug windows to make your driving simulation as close to real conditions as possible.现在,您可以在您的地形上标记具有不同表面条件的区域,并使用调试窗口微调您的车辆,使您的驾驶模拟尽可能接近真实条件。