Why C++ has gained traction in Autonomous Driving and ADAS (Self Driving Cars)

It has been over 40 years that automobiles and C++ have co-existed. While the world is well aware of the features of the cars that run on the roads, not many are familiar with the fact that C++ is the reason why today cars are more efficient, safe, smart, and clean. The trend of convergence of these two disciplines has made it almost impossible to have one without the other.

“Not many people are familiar with the fact that C++ is the reason why today cars are more efficient, safe, smart, and clean”

Automotive Software is the backbone of modern vehicles – The statement is not an exaggeration. The newest trends pursued in this highly competitive market, that are highly automated driving and full automation, are pushing the boundaries of current engineering capabilities sparking innovation in every segment of vehicle design and further increasing the complexity with some luxury vehicle models having up to 150 ECUs and over 100 Million lines of software code running them. Considering this, some common software requirements in the field of autonomous driving are:

  • Scaling, updating, and integrating software from multiple suppliers
  • Optimized performant software
  • Software dependability in terms of ASIL qualified components, tooling, libraries, etc.

Automotive Industry Software is a major component of a modern vehicle and it will continue to grow. The cost of electronics is optimized by leveraging software implementation on highly integrated ECUs, making it easier than ever to devise complex architectures working in synergy with a very good dependability grade, involving more software suppliers than ever.

C++ Software for Autonomous Driving / C++ self-driving carSource: IEEE, Automotive Designline

C++ for good interoperability between automotive software components

To achieve good interoperability between software components is the necessity for good abstractions, interface contracts, and deterministic functioning. C++ language is positioning itself as a key factor in bringing all the mentioned points together with its flexibility, OOP facilities, and a good typing system. In addition to that, there is a substantial talent pool, an established set of performant containers and algorithms, and a very advanced toolchain (compilers, static code analysis tools, testing frameworks, etc.). All these are supported by language features like RAII, smart pointers, lambdas, templates, concepts, contracts, and many others. Furthermore, even though being a high-level language, it provides low-level system programming capabilities and therefore turns out to be an ideal language for the development of cyber-physical systems.

“C++ language is positioning itself as a key factor in bringing all the mentioned points together with its flexibility, OOP facilities, and a good typing system. In addition to that, there is a substantial talent pool, an established set of performant containers and algorithms, and a very advanced toolchain (compilers, static code analysis tools, testing frameworks, etc.)”

 Autonomous Driving / self-driving car
The above picture is an example of how different sensors are positioned to build the picture of the world around an L5 car at any given point in time. The total bandwidth of data from these sensors can vary in the range of ~100 Kbit/s up to ~3500 Mbit/s per sensor.

Sensors help ADAS and Autonomous Driving Vehicles or Self Driving vehicles make decisions

When considering data throughput in AD (Autonomous Driving) & ADAS (Advanced Driver Assistance Systems), especially L4 and L5 systems, there is a big requirement for sensor coverage which brings the challenge of processing a huge amount of data in software in milliseconds. A concept of fusing all the inputs from sensors to produce a manageable probabilistic approximation of real-world environment is a very processing intensive task, involving for example time-consuming matrix operations which usually need to be hardware accelerated with dedicated chip facilities. Libraries with APIs for the usage of such facilities are usually provided in C/C++.

The C++ language provides a comprehensive feature set for handling lifetime and ownership of memory in a very robust and safe way making it an ideal candidate for applications where there is no scope of overlooking the overhead of passing the data around or making redundant copies of big data structures. There is no garbage collector in C++ like in some other managed languages where the entire system randomly comes to a complete halt on a
non-deterministic basis so that GC can mop up the unused resources.

The C++ language provides a comprehensive feature set for handling lifetime and ownership of memory in a very robust and safe way making it an ideal candidate for applications where there is no scope of overlooking the overhead of passing the data around or making redundant copies of big data structures.

Developing Autonomous Driving or Self Driving Vehicles is a Safety Critical application

The final point being dependability is the one being most discussed in autonomous driving. In its formal definition, dependability refers to reliability, availability, safety, security, maintainability, and all the accompanying activities necessary to reach that. Informally, in terms of AD (Autonomous Driving) development, it boils down to two major requirements: “keep running whenever needed” and “do not run into things”. While software in other tech areas is developed with positive scenarios in mind, AD (Autonomous Driving)  development is failure driven – the possibilities of failure are addressed from the beginning, and mechanisms to validate failure handling are assured. That kind of development mindset is a must overall levels of development, involving both high- and low-level automotive software.

Informally, in terms of AD development, it boils down to two major requirements: “keep running whenever needed” and “do not run into things”.

Reflecting on the statements from the language creator Bjarne Stroustrup that in C++ one pays only for what one uses and that the concept of C++ language is to have a simple and direct mapping for hardware means that there is a natural progression into critical and high scale applications like autonomous driving

To do autonomous driving software one needs to make it safe, to make it safe one is to be able to validate and vouch for all of it. Reflecting on the statements from the language creator Bjarne Stroustrup that in C++ one pays only for what one uses and that the concept of C++ language is to have a simple and direct mapping for hardware means that there is a natural progression into critical and high scale applications like autonomous driving. Such a concept allows a good overview of function chain components and the possibility of automotive testing and validation of every one of them.

The rule of thumb here is to make high quality code. The high level of quality is achieved through employing good software development with confirmed practices, keeping it as simple as possible, and having code reviews. Such activities are supported by coding standards which, for C++ language, are abundant over a big set of existing language versions. Some examples are JSF AV C++, MISRA C++, and AUTOSAR C++14 with coverage until C++14 with an indication that version 17 will be covered soon, with the extension on C++20 when available.

Considering the huge scale of autonomous driving software and the complexity in adas (Advanced Driver Assistance Systems) development, even though you do the entire code correctly and vouch for all of it, what guarantees you is that in the end when you compile it, the compiler you are using is producing the desired machine instructions for the target architecture. C++ history and maturity make it an ideal candidate for such applications considering the availability of proven and qualified compilers and tools supporting the entire C++ software development ecosystem.

C++ history and maturity make it an ideal candidate for such applications considering the availability of proven and qualified compilers and tools supporting the entire C++ software development ecosystem

To conclude, C++ in the case of autonomous driving, where maximum safety and performance must be achieved while needing a staggering amount of software components to work and scale together, C++ is a field-proven language that can facilitate this need of managing complexity without incurring performance or safety penalties. That is why C++ has a bright future in the autonomous driving and ADAS field.

Related Articles

3 reasons why India can be a global hub for ADAS/AD software development

3 reasons why India can be a global hub for ADAS/AD software development

An expert perspective on careers in Autonomous Driving technology

An expert perspective on careers in Autonomous Driving technology

A car is the most complex software-driven gadget

A car is the most complex software-driven gadget

Your feedback form has been submitted successfully!