Simulation and Visualization Tool Design for Robot Software Zhou Lu, Tjalling Ran and Jan Broenink Robotics and Mechatronics, University of Twente August 22, 2016
Outline ◮ Introduction ◮ Design of Simulation ◮ Visualizing Simulation Results ◮ Results ◮ Conclusions and Recommendations [ Z. Lu ] 2/18
Introduction - Context ◮ Cyber-Physical Systems (CPS) co-design: why challenging? ◮ Combine multiple different engineering disciplines/domains ◮ Seamless interaction with physical environments ◮ Concurrency is intrinsically presented in CPS ◮ Most CPS are safety-critical [ Z. Lu ] 3/18
Introduction - Related Work ◮ Design CPS using Model-Driven Design (MDD) ◮ Models can be formalized and checked ◮ Modelled systems can be tested and simulated off-line ◮ Ease tedious and error-prone concurrent software development Electronics design Software design Controller design Mechanics design Legend a) b) d) e) TERRA ECS software 1 Plant dynamics architecture 20-sim c) (G)UI, Supervisory, Control laws (co) simulation 2 Plant dynamics Sequence, Safety (Loop control,CT) Time Triggered & Plant dynamics 3a Discrete Event software & 3D animation Simulation time Real-time Target I/O Plant model 3b (RT sim) execution platform stub Target I/O Real plant 4 execution platform [ Z. Lu ] 4/18
Introduction - Problem Statements and Motivation ◮ Iterative and incremental design and development in MDD ◮ Sufficient verification and/or validation of models are required ◮ MDD in CPS: different domain models are involved ◮ Discrete-Event and Continuous-Time domains ◮ Co-simulation is needed to support co-design ◮ Current infrastructure: TERRA ◮ Does not provide sufficient simulation nor visualization facilities [ Z. Lu ] 5/18
fi Design of Simulation - Obtain Executable Models ◮ Executable models ◮ Executability: depends more on execution tools ◮ Execution tools: depend on assessment requirements ◮ Required assessments in CPS ◮ Process execution order ◮ Results of algorithms [ Z. Lu ] 6/18
Design of Simulation - Obtain Executable Models conforms to DSL meta-model Model ◮ Executable models ◮ Executability: depends more DSL Lexical Analysis on execution tools DSL Syntactic Analysis ◮ Execution tools: depend on assessment requirements Virtual Execution Real Execution Environment Environment ◮ Required assessments in CPS Source Intermediate platform Code ◮ Process execution order Representation speci fi cation static ◮ Results of algorithms libraries Source Code shared Execution Compiler ◮ Two strategies to obtain libraries (Simulation) Engine Machine Code executable models (Assemble, Java Bytecode...) ◮ Model interpretation Model Interpretation Code Generation ◮ Code generation Strategy Strategy [ Z. Lu ] 6/18
Design of Simulation - Analysis conforms to DSL meta-model Model ◮ Model Interpretation DSL Lexical Analysis ◮ Relies on the existence of a DSL Syntactic Analysis Virtual Execution Environment (VEE) Virtual Execution Real Execution ◮ Interpretation can be done Environment Environment Source dynamically Intermediate platform Code speci fi cation Representation ◮ Code generation static libraries Source Code ◮ Uses M2T transformation to shared Execution Compiler libraries (Simulation) generate lower-level system Engine Machine Code (Assemble, representation Java Bytecode...) ◮ Platform-dependent Model Interpretation Code Generation Strategy Strategy [ Z. Lu ] 7/18
Design of Simulation - Analysis ◮ From a practical perspective: code generation is preferred ◮ Control algorithms generated from 20-sim must be taken into account ◮ TERRA is able to generate C++ code ◮ Model interpretation will just be simulation without code implementation [ Z. Lu ] 8/18
Design of Simulation - Analysis ◮ Coupling strategies ◮ Loose-Coupling Execution ◮ Generate source code from different models ◮ Generate APIs for interacting purpose ◮ Execution coordinator ◮ Tight-Coupling Execution ◮ Integrate different models by using M2M transformations ◮ Generate code from an integrated model [ Z. Lu ] 9/18
Design of Simulation - A hybrid simulation approach ◮ Tight-Coupling Execution ◮ Integrate 20-sim controller model into TERRA ◮ Generate code from the integrated model Step1 Step2 Step3 Edit Models (Co) Simulation Visualization 20-sim Controller Plant FMU Model Execution Dynamics Animation FMI Wrapper LoggerServer Enviroment Plug-ins Platform LogInterpretor Speci fi c Plug-ins TERRA Executable SimCon Plug-ins TERRA TERRA TERRA CSP CSP CSP LUNA Lib [ Z. Lu ] 10/18
Design of Simulation - A hybrid simulation approach ◮ Loose-Coupling Execution ◮ Generate code from C/P models ◮ Generate APIs from TERRA FMI interface model ◮ FMI wrapper as coordinator Step1 Step2 Step3 Edit Models (Co) Simulation Visualization 20-sim Controller Plant FMU Model Dynamics Execution Animation FMI Wrapper LoggerServer Enviroment Plug-ins Platform LogInterpretor Speci fi c Plug-ins TERRA Executable SimCon Plug-ins TERRA TERRA TERRA CSP CSP CSP LUNA Lib [ Z. Lu ] 11/18
Design of Simulation - A hybrid simulation approach ◮ Visualizing simulation results ◮ Process execution order ◮ Results of algorithms ◮ Iterative and incremental design and development Step1 Step2 Step3 Edit Models (Co) Simulation Visualization 20-sim Controller Plant FMU Model Execution Dynamics Animation FMI Wrapper LoggerServer Enviroment Plug-ins Platform LogInterpretor Speci fi c Plug-ins TERRA Executable SimCon TERRA TERRA TERRA Plug-ins CSP CSP CSP LUNA Lib [ Z. Lu ] 12/18
Visualizing Simulation Results ◮ Five states for CSP constructs and processes ◮ Activate, Activating other processes, Waiting, Running, Done Activating Activating Done Activate Waiting Done Activate Done Activate other processes other processes Waiting Waiting Running P || Q writer !<variable> P ; Q P [] Q reader ?<variable> ◮ Logging facilities were designed to capture state changes ◮ Registration phase ◮ States recording phase Process ID:1 Process ID:2 Process ID:3 Process ID:n-1 Process ID:n State State State State State ............ time stamp Index 1 Index 2 Index 3 Index n-1 Index n [ Z. Lu ] 13/18
Visualizing Simulation Results ◮ Overall structure of the visualization ◮ Execute models ◮ Logged data will be stored as CSV files ◮ Mapping model elements ◮ Parsing logged data ◮ Publishing states to a graphical view TERRA T ool Suite State Tree Signal Animation Structure Changes Values Mapping Parsing Execution Publishing Enviroment LUNA View Executable TERRA Console TERRA TERRA logger log receiver CSP CSP Development T arget Platform Platform [ Z. Lu ] 14/18
Results ◮ Loop control model for testing * PARALLEL Step Controller Plant SEQUENTIAL_Plant SEQUENTIAL_Step SEQUENTIAL_Controller ? C++ INS ! v_u XXStepModel ? v_output v_SP C++ C++ ! XXControllerModel XXLinearSystemModel v_output ? v_MV ! v_y [ Z. Lu ] 15/18
Results ◮ Simulation Comparison Simulation Comparison TERRA-LUNA-sim vs 20-sim 1.2 0.18 Minor differences 0.16 1 0.14 0.8 0.12 Values 0.1 0.6 0.08 0.06 0.4 0.04 0.02 0.2 0 1.95 2 2.05 2.1 2.15 2.2 0 0 2 4 6 8 10 12 14 16 18 Simulation Time (s) Step-output Controller-output Plant-y 20sim-step-output 20sim-controller-output 20sim-plant-y [ Z. Lu ] 16/18
Results ◮ One snapshot of logged process states Process ID 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 time stamp 0.230 1 1 1 1 0 0 3 0 0 0 1 0 2 4 4 ◮ Using different colors to represent process states * PARALLEL Step Controller Plant [ Z. Lu ] 17/18
Conclusions and Recommendations ◮ Conclusions ◮ The simulation provides comparable results as the ground truth ◮ The animation can sufficiently indicate process execution order ◮ Opportunity to implement a rapid prototyping system ◮ Opportunity to obtain an executable and deployable binary which can be right-first-time ◮ Recommendations ◮ Signal values are not automatically visualized as state changes ◮ Options to include or exclude processes/states from animations ◮ Timing analysis need to be implemented ◮ FMI interfacing and wrapping facilities [ Z. Lu ] 18/18
Thanks! [ Z. Lu ] 18/18
Results ◮ Tree structure of the example model MainModel ID: 15 PARALLEL ID: 14 PAR Controller Step ID: 4 ID: 11 Plant ID: 7 INS r_SP ID: 1 SEQUENTIAL SEQUENTIAL ID: 2 _Controller _Step PAR w_output SEQUENTIAL SEQ SEQ ID: 13 _Plant XXController r_MV Model SEQ ID: 3 ID: 5 XXStepModel ID: 12 w_output w_y r_u ID: 6 ID: 8 XXLinear ID: 10 SystemModel ID: 9 [ Z. Lu ] 18/18
Recommend
More recommend