Data Stream Processing in Software-Defined Automotive Scenarios

In today's rapidly evolving technological environment, the automotive industry is in a period of change. Software-Defined Vehicles (SDVs) are at the forefront of this transformation, providing users with unparalleled connectivity, intelligence and data insights. SDV will generate massive amounts of data, and how to process these data in real time and efficiently has become a top priority.

This article will deeply analyze the stream processing technology of SDV data and discuss how it can help innovation in safety, performance and user experience in the field of software-defined vehicles.

What is a software-defined car?

A software-defined car is a highly connected, automated and intelligent vehicle. They can interact with other vehicles, infrastructure, cloud services, and mobile devices, and adapt to different environments and user needs. SDVs can also be remotely controlled or updated through a software application, changing their functionality, performance or appearance.

For example, with SDV we can:

  • According to the driver's mood or road conditions, it can freely switch between different modes such as environmental protection, sports or automatic driving.
  • Adjust its interior lighting, music or temperature based on passenger preferences or weather conditions.
  • Receive software updates from the manufacturer or third-party vendors to improve its functionality or security.

Mining the value of SDV data through stream processing technology

SDV generates massive amounts of data with variety and complexity from multiple sources such as sensors, cameras, GPS, and radar. They need to be processed in real-time or near real-time to provide useful information and assist decision-making actions for SDV and its users.

Stream processing is an efficient processing technique for such streams of data. It takes the form of processing data as soon as it arrives, without saving it in a database or file system. Stream processing can perform various operations on streams of data, such as filtering, aggregation, transformation, completion, and analysis.

In addition, stream processing can integrate data from multiple sources, enabling multi-source data integration to provide a unified data view. It also has the ability to scale horizontally to handle increasing data volumes and growth rates.

With stream processing, we can leverage SDV data to benefit in the following ways:

  • Improve safety and performance : Stream processing can detect abnormalities or failures in vehicles and notify drivers or service providers in a timely manner. It can also adjust the parameters according to the data analysis results to optimize the performance of SDV.
  • Optimize user experience : Stream processing can provide drivers or passengers with customized suggestions or feedback based on their preferences or behavior. It can also provide SDV with new features or services, such as entertainment, navigation or social networking.
  • Increased Efficiency and Profit : Stream processing can reduce the operating and maintenance costs of SDVs by improving resource utilization and reducing energy consumption. In addition, stream processing can generate additional revenue for service providers through value-added services and products derived from data insights.

eKuiper: A Powerful Stream Processing Engine for SDV Data

LF Edge eKuiper is a lightweight data flow processing engine designed for the edge of IoT. Its core functionality occupies only 10MB and can be easily deployed on a vehicle MPU. Users can use eKuiper to stream process SDV data.

In our article Bridging CAN Bus data to MQTT on-demand with eKuiper , we have demonstrated how eKuiper connects and parses CAN bus data. In addition, eKuiper also supports multiple data sources such as MQTT, HTTP, SQL database and files. Combined with NanoMQ, it can even connect to SOA (SomeIP, DDS) data bridged with MQTT. With stream processing capabilities, eKuiper can compute and transform data from these various data sources to generate useful information and trigger corresponding actions.

eKuiper uses SQL to create stream processing pipelines called rules. These rules enable hot deployment and hot update. Multiple rules can be flexibly chained together to build complex scenarios. With a single rule, eKuiper can:

  • Signal layer data filtering : flexibly select the signal layer data you want to view or analyze, whether it is a specified signal, a changed signal, or a signal that meets certain conditions.
  • Vehicle-side rule engine : Some custom rules can be set on the vehicle side, allowing eKuiper to automatically perform some actions when certain conditions are met. For example, you can set it to automatically close all windows when the speed of the vehicle exceeds 70 kilometers.
  • Intelligent Analysis : Using eKuiper's local analysis capabilities, data can be processed and analyzed in real time without coding or connecting to the cloud. You can also use eKuiper's integrated artificial intelligence model (currently supports TF Lite) for deeper data mining and prediction. It can also feed data back to the training model on the vehicle to improve the accuracy and efficiency of the model.
  • Edge Computing : Use eKuiper's edge computing capabilities to reduce transmission bandwidth and cloud computing pressure. eKuiper can aggregate data based on time windows, greatly reducing the amount of data transferred while keeping the trend of the data unchanged. It also supports downsampling and compression of data to save storage space and network resources.
  • Heterogeneous data fusion : Utilize eKuiper's data fusion capabilities to parse data from various protocols (such as TCP, UDP, HTTP, MQTT) and various formats (such as CAN, JSON, CSV) and merge them through flexible rules for a unified data stream.
  • Message routing : Utilize eKuiper's message routing capability to intelligently decide which data to send to the cloud and which data to store locally for use by other in-vehicle applications. For example, you can route messages based on GDPR or some whitelist to protect user privacy and security.

eKuiper Empowers Software-Defined Cars

According to the above capabilities of eKuiper, we can freely build SDV workflows and implement various possible scenarios by executing them.

Security issue detection

Using real-time data from vehicles, eKuiper can intelligently analyze and identify safety issues, and promptly remind drivers to take measures. We can use simple SQL statements to formulate our own safety rules, such as issuing warnings when the vehicle speed exceeds the limit; we can also use artificial intelligence models to detect more complex safety issues, such as fatigue driving, lane departure, collision risk, etc. We only need to upload the trained TensorFlow Lite model to the car, and eKuiper will automatically load and input the data into the model. The results can be used to trigger actions or alert drivers.

In the following example, we will use CAN bus data to identify frequent braking and alert the driver.

SELECT CASE WHEN count(*) > 5 THEN 1 ELSE 0 END as alert
FROM CANStream
WHERE SENSOR_TYPE_BRAKE_DEPTH>15
Group by SlidingWindow(ss, 10)

It detects whether there are more than 5 braking events with a braking depth greater than 15 within the last 10 seconds. If there is, it will sound an alert.

Improve user experience with automation

Using the meaningful data analyzed, eKuiper can automatically trigger some actions to optimize the user's driving experience. For example, when you forget to close the car window and the speed exceeds 80 km/h, eKuiper can automatically close the car window; when the car is stuck in a traffic jam and the temperature inside the car rises, eKuiper can automatically turn on the air conditioner, and adjust the temperature and temperature according to your preference. wind speed. In this way, you can enjoy a more comfortable and convenient driving experience.

In the following example, we will use the CAN bus data to automatically recommend the best driving mode for the driver based on the pre-trained artificial intelligence model. Assume we have trained a model to recognize driving patterns based on previously collected CAN bus data.

  1. Upload the model to the vehicle via the REST API.
  2. Define rules to load models, perform inference on streaming data, and send alerts via MQTT. tflitefunction is a plug-in function provided by eKuiper, which is used to infer TensorFlow lite models. The first argument is the variable model name, and the next arguments are the input data. The result is the output of the model.
SELECT tflite("trained_mode",signal1, signal2) as result FROM CANStream

Calculation and visualization of derived metrics

Collected data usually only contains basic raw data. In order to obtain useful information from data, we need to use algorithms to perform calculations. For example, calculate the average speed over a specified time window. This data can then be displayed on the car's interface and provide driving advice.

In the example below, we record and calculate the pattern of each braking, including average deceleration, braking distance, etc. This analysis helps us understand users' braking habits and provide drivers with recommendations based on this information. The results can be displayed on the car's interface, giving drivers an idea of ​​their braking habits.

eKuiper uses two rules to accomplish this function. The first rule detects braking and selects the signal to be calculated. The second rule calculates these metrics incrementally. These two rules are connected by an in-memory sink/source and work like a pipeline.

Rule 1 : Detect the brake signal, determine the start condition of the calculation, and select the appropriate signal to pass to the next rule. We can describe this algorithm using SQL statements: only when the brakes are on and the speed exceeds 10, do the calculations begin. When the brakes are off or the speed drops below 3, stop the calculation.

SELECT CASE WHEN brake = 1 AND speed > 10 THEN 1 ELSE 0 END AS brake_start,
       CASE WHEN brake = 0 OR speed < 3 THEN 1 ELSE 0 END AS brake_end,
       speed, distance, timestamp
FROM CAN_STREAM
WHERE brake_start = 1 OR (brake_end = 1 AND lag(brake_end) = 0)

This rule will pass data to the second rule when braking starts or ends. The output data format is as follows:

{
  "brake_start": 1,
  "brake_end": 0,
  "speed": 20,
  "distance": 100,
  "timestamp": 1622111111
}
{
  "brake_start": 1,
  "brake_end": 0,
  "speed": 18,
  "distance": 120,
  "timestamp": 1622111311
}
...
{
  "brake_start": 0,
  "brake_end": 1,
  "speed": 0,
  "distance": 200,
  "timestamp": 1622112511
}

Rule 2 : a=△v/△tCalculate the average deceleration according to the formula, and output the calculation result when braking to stop.

SELECT lag(speed) OVER (WHEN had_changed(brake_end)) as start_speed, speed as end_speed, (start_speed - end_speed) / (timestamp - lag(timestamp) OVER (WHEN had_changed(brake_end)) ) AS deceleration
FROM BRAKE_MEM_STREAM
WHERE brake_end = 1

Among them, lag(speed) OVER (WHEN had_changed(brake_end))it refers to the speed value at the moment when brake_end changed from 1 to 0 last time, that is, the speed when the brake is activated. The lag function is also used to calculate time intervals. The result is shown in the figure below, it only outputs once when the brake is stopped.

{
  "start_speed": 20,
  "end_speed": 0,
  "deceleration": 0.5
}

epilogue

As software-defined vehicles continue to shape the future of transportation, stream processing technology has become a key driver in unlocking the full value of SDV data. Through real-time analysis capabilities, stream processing technology improves safety, optimizes performance, and provides a personalized experience for intelligent vehicles. With the continuous advancement of technology and the expansion of applications, stream processing technology will profoundly change our perception and interaction with software-defined cars, making our travel safer, more comfortable and more efficient.

Copyright statement: This article is original by EMQ, please indicate the source for reprinting.
Original link: https://www.emqx.com/zh/blog/data-stream-processing-for-software-defined-vehicle

Guess you like

Origin blog.csdn.net/emqx_broker/article/details/131655673