Featured Webinar: MISRA C++ 2023: Everything You Need to Know | Watch Now

Coding Standards Compliance for Autonomous Driving Software Testing

Headshot of Ricardo Camacho, Director of Safety & Security Compliance
October 20, 2023
9 min read

Coding standards for autonomous vehicles are constantly changing due to the evolution of technology and people's needs. Read on to learn about the challenges in autonomous driving software testing and best practices to ensure coding standards compliance.

Autonomous driving adds additional challenges to compliance when developing vehicles compared to traditional requirements. What’s more, autonomous driving is an extremely competitive space. Whoever can first bring a certified product to market will have a significant advantage over the competition. As such, it’s easy for developers to view static analysis and other quality initiatives as an obstacle to development.

Though cultural buy-in can be a challenge with development teams, education around the quality processes required for safety-critical software development is crucial to faster, lower-cost workflows with better documentation and higher rates of compliance. So how do you approach autonomous driving software testing?

Let’s explore the world of driverless cars, static analysis, functional safety requirements, and more.

What Is Autonomous Driving?

Autonomous driving is when vehicles operate themselves without the need for human intervention. This operation utilizes a variety of technology including artificial intelligence algorithms, sensors, cameras, microprocessors, and more. Keep in mind that “self-driving” and “autonomous” are not the same thing.

A self-driving or automated car will still require human intervention at some point. Fully autonomous vehicles can sense and navigate their environments without human input. To categorize a car’s level of autonomy, there are six levels as developed by SAE International in 2014.

  • Level 0. The system has no continuous control of the vehicle and can only intervene temporarily or give warnings.
  • Level 1. This advanced driver assistance system (ADAS) is what many cars have for safety suites such as rearview cameras, adaptive cruise control, lane departure alerts, and more.
  • Level 2. This ADAS system requires the human to act as the driver but can steer and accelerate or brake while driving.
  • Level 3. This self-driving or automated driving system (ADS) category can do things like park a car, but humans must be ready to operate the vehicle as they remain the chief operator of the car.
  • Level 4. The vehicle is mostly autonomous with little need for a human driver to pay attention.
  • Level 5. A fully autonomous vehicle capable of driving in all situations. As of writing this blog, we have not yet fully reached this level of autonomous driving.

This level system suggests that automation increases in a linear fashion, which is not always the case. However, it remains a useful tool in classifying types of automation in vehicles.

What Is Autonomous Driving Software?

Autonomous driving software is any software used on autonomous driving platforms. This includes much more than just artificial intelligence and machine learning. It also includes things found in non-autonomous driving capable vehicles such as electronic control units or ECUs. These onboard computerized resources control everything from the brakes to doors and driver-assistance systems. However, it is neural networks that power autonomous driving.

These networks can find data patterns for machine learning algorithms to parse and translate into actions. An example situation might be the autonomous car’s system seeing a green light changing to yellow and slowing down in response.

How Does Autonomous Driving Software Work?

Autonomous driving software makes use of many types of sensors to perceive and parse data. They can determine where a vehicle is in physical space or in relation to objects like curbs or other cars. Other software plots a path for the vehicle to a specific location or controls acceleration, braking, steering, and more.

It is just like how you would operate a vehicle—except it is a series of programs, algorithms, and AI doing it for you.

What Is Autonomous Driving Software Testing?

As with any system designed for human use, autonomous driving platforms require rigorous testing and meeting specific standards. For instance, ISO 26262 acts as the automotive functional safety standard for the entire automotive product development process. It helps automakers detect, manage, and mitigate the effects of system and hardware failures to ensure safety. However, it’s not sufficient enough to cover all the engineering challenges that come with autonomous vehicles. They can perform as designed but fail to cope with real-world scenarios like extreme weather conditions or people’s conduct. For example, to consider child dart-out behavior in the streets or that of a drunken adult.

In lieu of many interesting scenarios and to help with analysis of environmental as well as human behavior, automotive standard ISO 21448:2021 was added to provide guidance on the applicable design, verification and validation measures, as well as activities during the operation phase that are needed to achieve and maintain Safety of the Intended Functionality (SOTIF).

AUTOSAR, or Automotive Open System Architecture, is a partnership of interested bodies that pursue and develop standardized software architecture for ECUs in vehicles. Additionally, MISRA, the Motor Industry Software Reliability Association, creates guidelines by which developers can create automotive industry electronic components.

Therefore, testing of autonomous driving software is more than just testing that the software components ensure safety even if failure occurs. It includes testing the vehicle’s autonomous response to real-world conditions and ensures safety. In addition, organizations need to prove that the autonomous software satisfies all regulatory requirements.

How Are Autonomous Vehicles Tested?

Autonomous vehicles require simulations of real-world test cases. These include realistic driving environments, models of other vehicles, and situations that automated cars would encounter. However, since these are computerized systems, concerns must also be addressed regarding cyberattacks.

Understanding Coding Standards for Autonomous Driving Software

Coding standards for autonomous vehicles are ever-evolving thanks to the technology and needs of people also evolving. Despite this, developers can always fall back on traditional safety-critical compliance standards when writing code for the cars of tomorrow.

Common Coding Standards in the Software Industry

There are a number of common coding standards across software for various industries. However, a coding standard by itself is merely a set of coding rules, best practices, and guidelines by which developers should write code.

This goes beyond general advice such as limiting the use of global or standardized naming conventions. There are guidelines or best practices from individuals and companies with decades of experience in software development that guarantee an increase in code quality.

From the automotive to medical devices, aviation, rail, and more, industries have adopted C and/or C++ safety and security coding standards. Some of these include:

  1. MISRA C 2023 is the latest C programming language coding standard for code security, safety, reliability, and portability for embedded systems.
  2. MISRA C++ 2023, which is the soon-to-be-announced coding standard for C++ 17 code safety, security reliability, and portability for embedded systems.
  3. AUTOSAR C++ 14 is the coding standard for C++ 14 code safety, security, reliability, and portability for embedded systems. It will be superseded by MISRA C++ 2023.
  4. SEI CERT C is the C programming language secure coding standard to identify software security risks and effectively reduce vulnerabilities in the applications developed.
  5. SEI CERT C++ is the C++ programming language secure coding standard that helps increase the security of software and reduce vulnerabilities in the applications developed.

Coding Standards Specific to Autonomous Driving

When it comes to autonomous driving, teams should use the coding standards previously listed. These would be the ones highly recommended, but due to the nature of autonomous vehicles, these safety and security coding standards are not enough.

Other standards, like CWE and OWASP, have coding rules and guidelines but go beyond the scope of the code. They also take into consideration the overall development workflow, organizational policies, and processes that people need to follow to ensure the safety and security of autonomous vehicles.

Additional standards and regulations come into play when considering autonomous vehicles and the advanced AI systems involved with autonomous processes. This list is not comprehensive, but provides general guidance:

  1. ISO 26262, road vehicles functional safety
  2. ISO 21434, road vehicles cybersecurity
  3. ISO 21448, SOTIF (Safety of the Intended Functionality)
  4. Automotive SPICE, quality management
  5. UNECE WP.29, vehicle cybersecurity

Key aspects of autonomous vehicles that these and other standards take into consideration are:

  • Real-time constraints. Autonomation in driving requires the processing of data in real time. As such, the systems need to be able to process substantial amounts of data quickly to make split-second decisions.
  • Cybersecurity. A hacked vehicle is bad news. Coding standards should ensure contingencies for such scenarios.
  • Human/machine interactions. Humans are unpredictable. Developers will have to build in the expectation for the unexpected as a result.

Challenges in Autonomous Driving Software Testing

The inherent safety-critical nature of developing autonomous driving software naturally leads to the need for thorough and continuous testing. But, like all kinds of software development, creating AI-driven systems has its own pitfalls and challenges.

  • Compliance with multiple coding standards. This task requires planning, consistent testing, and that developers be attentive to how they write code.
  • Cybersecurity risks. All computerized systems are vulnerable to security risks. A bad actor taking over an autonomous vehicle, for instance, is a real-world situation that should be anticipated throughout development and testing.
  • Legacy code. Whether it’s your own old code or something inherited, legacy code can pose an obstacle in development. Address it with two mantras: “clean as you go” and “zero new violations.”
  • Vehicle data collection. Tons of new data will have to be gathered, parsed, and reviewed in real time for truly autonomous driving. As such, robust systems around data collection are important.
  • Tech debt. Some developers want to work more efficiently by not making everything they write coding standard compliant before testing. This could lead to prototyping something with non-safety compliant code causing delays. It’s better to clean as you go.
  • Limitations of testing. Testing just one prototype at a time bogs down any updates that can be made, and errors can prove costly.
  • Automation-friendly infrastructure. Public roads and highways in their current states pose a significant obstacle for autonomous vehicles. They’re designed around human drivers. Developing software for these systems can be hampered as a result.
  • Evolving technology. AI and machine learning change rapidly, but so do ancillary technologies in autonomous driving such as sensors, radar, and so on.

Best Practices for Ensuring Coding Standards Compliance

Achieving compliance is not an easy task. Even the most experienced professionals can fail in some capacity. But there are general best practices outside of autonomous driving software development that benefit all software engineers.

Establishing Coding Standards From the Outset

No matter the project scope, schedule, or budget, setting up expectations and standards at the beginning is crucial. Not only will this ensure that your code is more easily understood by everyone on a team, but it will also ensure that there are fewer issues with addressing bugs quickly. No one will have to play the telephone or a guessing game.

Regular Code Reviews & Audits

Just like continuous testing, regularly reviewing code allows you to better enforce standards and address problems early. This allows you to catch things like deep nesting, illegible code, correct naming conventions, and more.

Continuous Training & Skill Development

Possessing a student mindset—even as an expert in a field—can help bolster and improve your abilities. As such, it pays to invest in your developers with education and training beyond what they might have initially been hired for. Besides, technology is always changing. That means that your team needs to keep up.

Utilizing Automation & Tooling

Static analysis testing is not every developer’s favorite thing. But automation has made reaping the benefits of such testing types much easier. Utilizing every tool in the arsenal, including AI and machine learning, is a no-brainer in an Agile or shift-left setup.

Documentation & Reporting

Again, the easiest way to avoid issues is to prevent them in the first place. Documentation and reporting allow teams to cross-reference as needed versus taking additional time to track down the person who originally wrote the code. Or worse, they might just make an assumption and move forward on something that won’t be usable.

Benefits of Testing

Introducing static analysis with the soon-to-be-announced MISRA C++ 2023 and soon-to-be legacy AUTOSAR C++ 14 coding standards, compliance as a sustainable process can seem daunting. But testing remains an integral part of best practices, even in a field as innovative as autonomous driving.

Testing using tools such as C/C++test from Parasoft integrates benefits into your workflow including:

  1. Certification and compliance. All automotive organizations recognize ISO 26262 as the main functional safety standard that simplifies approval and certification. Autonomous car software must be approved and certified before going into mass production, so testing early and often can get you to certification more quickly.
  2. Quality at lower cost. Building high-quality, compliant code from the beginning and testing as early as possible makes it faster to fix issues. You will avoid common pitfalls because developers will start adopting best practices from the beginning. It’s essential to test while code is being written to create complex software at a rapid pace. Static analysis is one of the methods that fits well into this picture.
  3. Accountability and documentation. With millions of cars on the roads, accidents are going to happen and some of them will be traced to software errors. Organizations must be able to show they have done everything practically possible to prevent safety hazards. Having a documented coding standards compliance process will prove beneficial.
  4. Testing in closed loop systems. Creating test cases in virtual environments helps to cut down on testing costs and time. Simulating various situations for analysis allows for minute tweaks or major overhauls throughout the testing process to allow for more actionable data.

Future Trends & Considerations for Autonomous Driving Software Testing

There are numerous companies out there trying to be the first to have a truly autonomous vehicle on the market. This technology requires comprehensive testing to protect life, function properly, and adapt to everyday life.

Though not an official document from the National Highway Traffic Safety Administration (NHTSA), the Institute of Electrical and Electronics Engineers (IEEE) published a preliminary set of guidelines for ADS standards in 2022. The IEEE P2846 Draft Standard for Assumptions for Models in Safety-Related Automated Vehicle Behavior seeks to address the unique issues with autonomy and driving. However, having a standard guideline for this use case is not the only future consideration.

As mentioned earlier, autonomous driving software testing also relies on the real-world to welcome actual self-driving cars. The traditional technology and manners by which we navigate may have to change with widespread adoption of automated driving. It begs the question: what if cities were designed around human use and not parking cars?

Summary

Incorporating static analysis or other types of continuous tests into your workflow delivers tangible results. But with tools such as one of Parasoft’s many solutions, reaching safety compliance with software for automated cars is that much more achievable. Just remember to do the following:

  1. Make clear why you are testing.
  2. Address the cost of delayed releases.
  3. Make adoption as relevant and frictionless as possible.
  4. Be intentional as you implement your static analysis tool.
  5. Select the right rules and checkers for a workflow that integrates into the developers’ processes.

With the goals of being efficient, thorough, and developer-oriented, you will achieve safety compliance sooner than you think.

Learn about the crucial role that ISO 26262 plays in the automotive industry for delivering safe and secure software.

Related Post + Resources