基于NI_TestStand的智能驾驶自动化测试

本文详细探讨了NI_TestStand在汽车智能驾驶自动化测试中的应用,介绍了其作为测试管理软件的角色,如何与VTD交通环境模拟器协同工作,以及如何通过Python脚本实现远程控制。重点涵盖了TestStand的架构、功能、模块调用和与VTD的交互过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

汽车产业不断发展的今天,智能驾驶已经成为了汽车中必不可少的一部分。虽然目前真正的无人驾驶技术还未广泛应用于我们的日常生活中,但各式各样的驾驶辅助系统,如碰撞预警、自动刹车、自适应巡航等功能已经在为我们的驾驶员保驾护航。

今天小编就带大家一起来探讨一下基于NI_TestStand的智能驾驶自动化测试问题。

老规矩,先来看看NI-TestStand是个什么神器~

NI-TestStand是什么?

NI TestStand是一款可立即执行的测试管理软件,它可以帮助用户更快地开发自动测试和验证系统,用于组织、控制和执行自动化原型设计、验证或制造测试系统。加入在LabVIEW、LabVIEWs/CVI、Visual C/C++、Visual Basic、.NET和C#中编写的测试程序,使用NI TestStand快速创建测试序列。NI TestStand应用的极为广泛,在我们的汽车测试行业中也是家喻户晓的存在。

NI-TestStand的软件使用

NI TestStand软件架构的中心组件是一个执行引擎,它提供一个开放API接口以方便与其他应用的通信。序列编辑器和操作者界面利用API访问NI TestStand引擎。此外,共有三种用于定义开发环境、运行时环境和执行环境的特性的重要文件类型。

▲ 图一:NI TestStand架构示意图

NI TestStand的功能完全由用户定义。为满足特定需求,我们可自行对其进行功能修正和改进,例如定制操作界面、生成自定义报告或修改序列执行要求等。借助NI TestStand,我们可将精力集中于特殊的测试要求,NI TestStand则管理普通的序列、执行和汇报任务。

▲ 图二:NI TestStand软件界面

我们在TestStand中可以调用不同的模块来进行测试用例的编写,这种调用方式可以使我们编写的测试用例更加灵活,从而实现更多完善细致的功能。如下图所示,可以调用的模块类型包括LabVIEW、LabVIEW/CVI、C++、.NET、Acitive/COM、LabVIEWNXG以及Phython等,除此之外我们还可以使用TestStand自带的语句,多样化的模块和语句的结合可以使我们的测试用例更加全面。

▲ 图三:可添加模块示意图

我们知道,在测试用例的编写中,变量参数是极其重要的。下图就是序列浏览和参数变量浏览窗口。在序列浏览窗口中,我们可以看到编写好的主序列或者一些子序列,其中子序列是可以被调用在主序列中的,这样可以使我们的测试用例更加有层次感和逻辑性。

▲ 图四:图为序列窗口和变量窗口

由于任何自动化系统的开发都不是一步到位的,所以当我们编写好一个测试用例后,势必要对其进行调试和改进。因此TestStand中的调试工具对于加速系统开发也是极其重要的。开发人员可以充分利用各窗口所提供的信息,并结合各种调试工具和不同的调试策略,快速诊断问题所在。在下图中我们可以看到在通过语句与模块的共同使用下编写了一个简单的序列文件,此时该窗口就可以作为执行窗口去对序列文件进行一些执行操作,比如:添加断点,单步执行,交互式执行步骤或改变步骤运行模式等。

▲ 图五:添加了LabVIEW模块的测试用例

对于TestStand的自动化测试来说,最重要的还是与其他软件的结合使用。在我们今天的介绍中还有一个尤为重要的内容就是如何将TestStand与一款功能强大的 复杂交通环境视景建模仿真软件VTD联合使用,构成成熟的自动化测试体系。关于VTD的内容在我们往期的公众号中已经有较为详尽的介绍,所以,下面我们就直接介绍一些联合使用的方式。

NI TestStand与VTD的交互使用

在想要通过TestStand调用VTD之前,我们需要先弄清楚如何对VTD进行调用。我们发现可以用SCP命令对VTD发送指令,从而实现远程控制VTD工作。所以在这里我们还要简单介绍一下SCP命令。

▲ 图六:交互逻辑整体示意图

SCP命令

SCP命令全称是Simulation Control Protocol,即仿真控制协议。它是VTD中基于事件的,用于对VTD进行远程交互的特殊命令集,包括控制和动作命令,以及状态信息的查看。我们可以通将SCP与Python相结合,编写一些脚本程序来对VTD进行动作指令。SCP指令中的关键字与一般的XML指令相似。

▲ 图七:SCP部分指令

在根据相关文档进行好脚本的编译之后,我们便可以进行后续的软件交互内容。除了SCP指令之外,我们还需要认识两个新“朋友”,一位是同样属于NI公司的VeriStand,另一位就是同样负责通信的命令RDB。

VeriStand

VeriStand应用软件用于为NI实时硬件配置I/O通道、数据记录、激励生成和主机通信。 除此之外,我们还可以导入仿真模型和控制算法、配置警报来响应事件。 用户界面在运行时是可编辑的,以便我们监测和控制应用程序数据、警报状态和系统执行指标。虽然使用VeriStand不需要掌握编程知识,但我们也可以使用各种编程软件环境(如LabVIEW、ANSI C/C ++、Python和ASAM XIL)来为VeriStand添加自定义功能。

▲ 图八:VeriStand的软件界面

RDB

RDB全称是Runtime Data Bus,即数据运行总线,它是通过周期性的I/O数据帧,也就是仿真信息,去反馈当前VTD的信息,包括目标信息、环境信息、传感器信息、图像数据等。

▲ 图九:VTD中RDB的使用示例

综上所述,我们可以很清楚的了解VTD与TestStand的交互模型。当我们了解完了基本软件的内容之后我们便可以对其进行连通。首先我们要通过Python编写期望的SCP指令,在编写好脚本文件并确保我们的文件可以指示VTD产生动作后,接下来我们就可以从TestStand里面对Python脚本进行调用。

▲ 图十:调用Python模块示意图

这样我们便初步实现了TestStand对VTD的动作指示。但正如我们所知,如果只是像这样简单的联通是并不能完成我们所期望的自动化测试需求的,所以除了要对VTD发送命令,我们势必还要接收VTD一端返回的命令,从而在TestStand里面对参数变量以及条件进行编写,才能获得一条完整的测试用例。那么如何才能接收到VTD的反馈呢?这就需要用到我们刚才介绍的VeriStand与RDB命令了。

TestStand对VTD的控制

在RDB数据到达VeriStand后,我们可以通过VeriStand对数据进行解析,从而再将解析后的数据传达给我们的TestStand,这样便实现了由VTD到TestStand的交互。

当我们成功实现了由VeriStand接收VTD返回的指令之后我们接下来就要实现VeriStand与TestStand的互联。关于TestStand的灵活性我们已经深有体会了,所以想要实现TestStand与自己的“兄弟”软件——VeriStand的交互对于我们来说也是易如反掌。

我们只需要在TestStand中右键点击Template列表中的任何地方,然后选择“Import”,定位到VeriStand的Template路径,最后点击OK。(注:默认路径一般在C:\Documents and Settings\All Users\Documents\National Instruments\VeriStand\TestStand\NIVeriStand TestStand 4.2 Steps Template.ini)

▲ 图十一:添加了NI VeriStand的模板窗口

这样我们便成功实现了VeriStand的工程的添加,也就基本实现了TestStand与VTD的连通。之后,我们再根据自己的期望去编写不同的测试用例,再通过不断地调试、测验去改善测试用例,保证测试用例的完整性,我们便完成了基本的自动化测试流程。

以上便是如何将TestStand与我们的自动驾驶相关软件进行自动化测试串联的过程,该交互理念与逻辑也适用于其他的软件

最全的Teststand 教程(英文版) Introduction Introduction.................................................................................................................xi Technical Support Options.........................................................................................xii Course Objectives.......................................................................................................xiii Course Description .....................................................................................................xiii Course Map.................................................................................................................xiv Items You Need for this Course Module:...................................................................xv Note on Hands-On Exercises......................................................................................xvi Lesson 1 Introduction to TestStand Introduction.................................................................................................................1-1 The Role of a Test Executive......................................................................................1-2 The TestStand Goal ....................................................................................................1-3 What is TestStand?.....................................................................................................1-4 The TestStand Architecture........................................................................................1-5 The Sequence Editor...................................................................................................1-6 The Operator Interface................................................................................................1-7 The TestStand Engine.................................................................................................1-8 Module Adapters ........................................................................................................1-9 The TestStand Architecture........................................................................................1-10 Summary.....................................................................................................................1-13 Exercises Exercise 1-1 Running a Sequence File..................................................................1-15 Exercise 1-2A Running a Sequence File from the LabVIEW Operator Interface ............................................................................1-20 Exercise 1-2B Running a Sequence File from the LabWindows/CVI Operator Interface..............................................1-25 Contents TestStand Development Course Manual iv www.ni.com Lesson 2 The TestStand Environment Introduction.................................................................................................................2-1 What is a Sequence?...................................................................................................2-2 Step Groups.................................................................................................................2-3 TestStand Sequence Files ...........................................................................................2-4 Debugging Tools.........................................................................................................2-5 The TestStand Process Model.....................................................................................2-8 The Default Process Model: Test UUTs Mode ..........................................................2-9 TestStandModel.seq....................................................................................................2-10 The Role of the Process Model within the TestStand Architecture............................2-11 Exercises Exercise 2-1 Understanding the Sequence File.....................................................2-15 Exercise 2-2 Running a Sequence File with Breakpoints and Single Stepping.................................................................................2-21 Exercise 2-3 Understanding the Process Model....................................................2-28 Lesson 3 Creating Sequences Introduction.................................................................................................................3-1 How to Create Test Sequences ...................................................................................3-2 Action 1 : Specify the Adapter ...................................................................................3-3 Action 2: Select the Step Type ...................................................................................3-4 Step Types...................................................................................................................3-5 Action 3: Specify the Test Module.............................................................................3-6 Specifying the Module................................................................................................3-7 Specifying the Module: Search Directories................................................................3-8 Action 4: Configure Step Properties...........................................................................3-9 Step Properties: General Tab......................................................................................3-10 Step Properties: Preconditions....................................................................................3-11 Step Properties: Run Options......................................................................................3-12 Step Properties: Post Actions......................................................................................3-14 Step Properties: Loop..................................................................................................3-15 Step Properties: Expressions.......................................................................................3-17 Exercises Exercise 3-1 Creating Steps in the Sequence Editor .............................................3-23 Exercise 3-2 Configuring Loop Options ...............................................................3-34 Exercise 3-3 Creating a Sequence.........................................................................3-38 Exercise 3-4 Running Sequences in Parallel (Optional) .......................................3-58 Contents © National Instruments Corporation v TestStand Development Course Manual Lesson 4 TestStand Parameters, Variables, and Expressions Introduction.................................................................................................................4-1 Parameters...................................................................................................................4-2 Parameters: Passing data from top-level sequences to subsequences.........................4-3 TestStand Variables....................................................................................................4-4 Local Variables...........................................................................................................4-5 Creating Locals Variables...........................................................................................4-6 Sequence File Global Variables..................................................................................4-8 Creating Sequence File Global Variables...................................................................4-9 Station Globals............................................................................................................4-10 The Expression Browser.............................................................................................4-11 Exercises Exercise 4-1 Using Local Variables......................................................................4-19 Exercise 4-2 Examine the Uses and Differences between Locals, File Globals, and Station Globals.....................................................4-22 Exercise 4-3 Using Expressions to Change Step Properties..................................4-30 Exercise 4-4 Passing Parameters...........................................................................4-39 Exercise 4-5 Dynamically Selecting Which Sequence to Run..............................4-49 Exercise 4-6 Using the UUT Serial Number to Determine Which Sequence to Run...............................................................................4-50 Lesson 5 Creating Test Modules in External Environments Introduction.................................................................................................................5-1 Creating Tests in External Application Development Environments (ADEs)...........5-2 Methods of Data Transfer for TestStand ....................................................................5-3 Method 1—Passing Parameters Directly Using Structures........................................5-3 Using Clusters to Pass Data from LabVIEW..............................................................5-4 Using Structures to Pass Data from LabWindows/CVI..............................................5-6 Method 2—Passing Arbitrary Number of Parameters Directly..................................5-8 Method 3—Using the ActiveX Automation API to Access Properties and Methods .............................................................................................................5-12 What is ActiveX Automation?....................................................................................5-13 Summary of ActiveX Automation..............................................................................5-14 TestStand and ActiveX Automation...........................................................................5-15 Using TestStand ActiveX Automation Functions in LabVIEW.................................5-16 An Example of Using ActiveX Automation in LabVIEW.........................................5-17 Using ActiveX Automation in LabWindows/CVI......................................................5-18 An Example Of Using The TestStand API Instrument Driver In LabWindows/CVI.....................................................................................................5-19 Using TestStand to Generate Code Templates...........................................................5-24 Code Templates ..........................................................................................................5-25 Contents TestStand Development Course Manual vi www.ni.com Exercises Exercise 5-1A Creating Pass/Fail Tests in LabVIEW..............................................5-27 Exercise 5-1B Creating Pass/Fail Tests with LabWindows/CVI.............................5-33 Exercise 5-1C Creating Pass/Fail Tests for the DLL Flexible Prototype Adapter.............................................................................5-44 Exercise 5-2A Creating Numeric Limit Tests with LabVIEW................................5-54 Exercise 5-2B Creating Numeric Limit Tests with LabWindows/CVI.............................................................................5-59 Exercise 5-2C Creating Numeric Limit Tests for the DLL Flexible Prototype Adapter...............................................................5-67 Exercise 5-3A Debugging Tests Using LabVIEW...................................................5-80 Exercise 5-3B Debugging Tests Using LabWindows/CVI......................................5-84 Exercise 5-3C Debugging Tests that use the DLL Flexible Prototype Adapter.............................................................................5-88 Exercise 5-4A Using the ActiveX API in Code Modules with LabVIEW .................................................................................5-91 Exercise 5-4B Using the ActiveX API in Code Modules with LabWindows/CVI ....................................................................5-100 Exercise 5-4C Using the ActiveX API in Flexible DLL Code Modules............................................................................................5-110 Exercise 5-5A Creating a Simple Test Using the LabVIEW Standard Prototype Adapter .............................................................5-122 Exercise 5-5B Creating A Simple Test Using The C/CVI Standard Prototype Adapter .............................................................5-124 Exercise 5-6A Passing Parameters from TestStand to LabVIEW using The TestStand API..................................................................5-125 Exercise 5-6B Passing Parameters from TestStand to LabWindows/CVI using The TestStand API...................................5-127 Exercise 5-7 Passing Data Between TestStand and a Test Module Using the DLL Flexible Prototype Adapter........................5-129 Lesson 6 User Management Introduction.................................................................................................................6-1 The TestStand User Manager .....................................................................................6-2 Default User Profiles in TestStand .............................................................................6-3 Linking Windows System Users.................................................................................6-5 Exercise Exercise 6-1 Setting User Login Access and Privileges........................................6-7 ...............
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值