4.5.1. Soda Vehicle API

4.5.1.1. ASodaVehicle

ASodaVehicle - is the base abstract class for any vehicle (a car, an airplane, a tank, a copter, a sea vessel etc). It implements the basic functionality:

  • Vehicle = set of vehicle components” pattern;

  • Control, clocking and синхронизация of all vehicle components;

  • JSON or binary (de)serialization of a vehicle;

  • Manage vehicle configurations storage, both on local drive and database (local or remote);

  • Store data to the database;

  • Debug functions (see Vehicle Debug Panel);

  • Custom widgets;

  • CAN buses.

4.5.1.1.1. Main concept

The SODA.Sim concept is built on the principle that any vehicle can be divided into multiple components. Each component encapsulates a specific aspect of the vehicle’s functionality, such as the engine, wheels, steering rack, sensors, and more. Components are not limited to physical functions; they can also represent non-physical functionalities like input devices, CAN bus, vehicle physics, or even a virtual driver.

Each component can seamlessly connect and interact with others to form a cohesive vehicle system. Consider the interaction chain of Engine ↔ Gear Box ↔ Differential ↔ Wheels. Here, each component engages with the others through torque transmission, demonstrating the interconnectivity and interaction within the vehicle’s various parts.

Untitled

4.5.1.1.2. ASodaVehicle lifecycle

ASodaVehicle Lifecycle.jpg

4.5.1.1.3. Vehicle Component

Any vehicle component should inherit from ISodaVehicleComponent and any successor of UActorComponent. Optionally, it can also inherit from IVehicleTickableObject.

ISodaVehicleComponent Interface implements the following basic functionalities:

  • Connection with ASodaVehicle

  • Activation/Deactivation of the component

  • UI Generation

  • Health Logic

  • Debug Functions

Add the IVehicleTickableObject Interface to a component if it needs to tick at the frequency of the vehicle’s physics simulation (see functions PrePhysicsSimulation and PostPhysicsSimulation). This is most often necessary for components involved in calculating physics simulations (such as engines, transmission, braking systems, etc.).

4.5.1.2. ASodaWheeledVehicle

ASodaWheeledVehicle is inherited from ASodaVehicle and represents the implementation of an N-wheeled vehicle. An instance of this vehicle must have at least one vehicle component with the inherited interface ISodaWheeledVehicleSimulationInterface. This component is responsible for calculating the physics (simulation) of wheels and suspensions. There are four implementations of this component:

  • USodaChaosWheeledVehicleMovementComponent is based on the default UE class UChaosWheeledVehicleMovementComponent.

  • USoda2WDWheeledVehicleMovementComponent simulates the physics of a vehicle in 2D space (XY-plane).

  • UNCOMWheeledVehicleMovement does not handle physics simulation but substitutes the simulation results with external IMU OXTS sensor data. It may be useful for augmented reality tasks when the vehicle is moving in the real world, and the sensors “see” a virtual image.

  • UStaticWheeledVehicleMovementComponent is a “placeholder” component and does not calculate physics.

At any one time, only one ISodaWheeledVehicleSimulationInterface component can be active.

Also, an instance of this type of vehicle must contain at least one USodaVehicleWheelComponent. This component represents the interface interaction between ISodaWheeledVehicleSimulationInterface and one of the wheels. The number of USodaVehicleWheelComponent must correspond to the number of wheels on the vehicle. If the vehicle has four USodaVehicleWheelComponent installed and for each wheel, the WheelIndex4WD parameter is set according to the index of that wheel, the vehicle is marked as a 4WD vehicle. This is useful to know as some vehicle components support only 4WD vehicles.

Optionally, the following components can be installed on the vehicle:

  • UVehicleSteeringRackBaseComponent: a base component for all steering racks.

  • UVehicleHandBrakeBaseComponent: a base component for all hand brakes.

  • UVehicleGearBoxBaseComponent: a base component for gearboxes.

  • UVehicleEngineBaseComponent: a base component for engines (currently only electric).

  • UVehicleDifferentialBaseComponent: a base component for differentials.

  • UVehicleBrakeSystemBaseComponent: a base component for all braking systems.

  • UVehicleDriver: implements basic interfaces for an abstract onboard computer or Vehicle Driver Unit (DCU). DCU is a controller found in most modern cars with AD/ADS functions, providing interfaces and protocols for vehicle control from an external device (AD/ADS).

  • UVehicleInputComponent is responsible for “simulating the driver.” Formally, UVehicleInputComponent is not an input device, but rather represents “driver intentions,” for example,(the driver pressed the gas pedal by 50%, or turned the wheel by 10%. Other components (for example, UVehicleSteeringRackBaseComponent) can receive and execute these intentions. There are four implementations of UVehicleInputComponent (UVehicleInputKeyboardComponent, UVehicleInputJoyComponent, UVehicleInputExternalComponent, UVehicleInputAIComponent).

4.5.1.3. CAN Subsystem

4.5.1.4. DBC Parsing