Interfacing Chrono & Matlab. Chrono units for MATLAB and SIMULINK

Similar documents
Model Based Systems Engineering Engine Control: from concept to validation. Jan Smolders Technical Account Manager

Multi-Physics RecurDyn Style Interoperability

Vom Konzept zum Modell physikalischer Systeme Smarter Modellieren mit Simscape

Integration of CAE Tools for Complete System Prototyping EASY5 User Conference May, 2000 Presented by: Joel Tollefson

Matlab Simulink Simscape

MATLAB MATLAB mat lab funtool

FUZZY LOGIC CONTROL. Helsinki University of Technology Control Engineering Laboratory

Simcenter Motion 3D. Mechatronics - Improve Design Dynamics Performance: Combine 3D Multi-Body Simulation with 1D Actuation & Controls Simulation

Introduction to Matlab

Entwicklung mechatronischer Systeme in der Luft- und Raumfahrt

SIMULINK Tutorial. Select File-New-Model from the menu bar of this window. The following window should now appear.

Note 10 Introduction to MATLAB & SIMULINK

MECHATRONICS. William Bolton. Sixth Edition ELECTRONIC CONTROL SYSTEMS ENGINEERING IN MECHANICAL AND ELECTRICAL PEARSON

What Is SimMechanics?

MATLAB AND MODELSIM LINKING

Example: Modeling a Cruise Control System in Simulink

the Simulation of Dynamics Using Simulink

Experiment 8 SIMULINK

Coupling of Simulation Tools - Building Controls Virtual Test Bed Michael Wetter. August, 2010

Experiment 6 SIMULINK

Session 3 Introduction to SIMULINK

Introduction to Matlab

SimMechanics Getting Started Guide. R2013b

MathWorks Technology Session at GE Physical System Modeling with Simulink / Simscape

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

Matrix Transformations The position of the corners of this triangle are described by the vectors: 0 1 ] 0 1 ] Transformation:

Pick and Place Robot Simulation

Using RecurDyn. Contents

Master Class: Diseño de Sistemas Mecatrónicos

MATLAB/Simulink 기반의프로그래머블 SoC 설계및검증

Integrated Workflow to Implement Embedded Software and FPGA Designs on the Xilinx Zynq Platform Puneet Kumar Senior Team Lead - SPC

Chrono::Irrlicht demos

Interfacing OpenSim models with MATLAB /Simulink. OpenSim Workshop

Introduction to ARDUINO/SIMULINK

xpc Target Tutorial Control System Design Feb. 15, 2004 For more detailed information, see the xpc target manual at:

QUESTION BANK UNIT I

Dr Richard Greenaway

Experion MX CD Controls R700.1 Software Change Notice

CDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation

Introduction to Matlab

System modeling using Simulink and Simscape

Automated Generation Of Code From Simulink To An Event-Based Simulation Framework

Accelerating Finite Element Analysis in MATLAB with Parallel Computing

Importing Models from Physical Modeling. Tools Using the FMI Standard

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin

Simulation-Based Design of Robotic Systems

Multi-core Simulation of Internal Combustion Engines using Modelica, FMI and xmod

Embedded Target for TI C6000 DSP 2.0 Release Notes

Functional range of the different FluidSIM versions

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

Objectives. Simulink Basics

OpenFresco Framework for Hybrid Simulation: xpc-target Experimental Control Example

Quick Installation Guide: QUARC TM on NI ELVIS III

Vibration Analysis - Ethernet Interface

MatLab Project # 1 Due IN TUTORIAL Wednesday October 30

Quanser Qbot. Set up and Tutorial Guide

Kinematics of the Stewart Platform (Reality Check 1: page 67)

[Sub Track 1-3] FPGA/ASIC 을타겟으로한알고리즘의효율적인생성방법및신기능소개

Lab. Manual. Practical Special Topics (Matlab Programming) (EngE416) Prepared By Dr. Emad Saeid

Lecture 1 Introduction and Basic Usage Simplorer v2014

Physical Modelling with Simscape

Introduction to Control Systems Design

TrueTime PiccSIM integration

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

Eng Marine Production Management. Introduction to Matlab

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras

Generation of Functional Mock-up Units from Causal Block Diagrams

Flow in an Intake Manifold

How to Run an AMESim model with the RT-LAB Platform

PSIM SIMULATION SOFTWARE. TUTORIAL How to use the Simcoupler

Applying Optimal Control Using SLP on a Hydraulic System

Experiment # 5. Introduction to Error Control Codes

VehicleSim Dynamics plugin for Unreal Engine example using VS Connect

An Introduction to MATLAB

Matlab Practice Sessions

Introduction to MATLAB

HOW TO USE I-Cylinder STEP-BY-STEP

Flexible Hardware Mapping for Finite Element Simulations on Hybrid CPU/GPU Clusters

Project Chrono. Overview, structure, capabilities

What's new in MATLAB and Simulink for Model-Based Design

Swapnil Nimse Project 1 Challenge #2

MULTI-LEVEL MODELLING OF A MODULAR DOUBLE SALIENT LINEAR MOTOR

The Avionics System Test Bench, Functional Engineering Simulator: New Developments in Support of Mission and System Verification

Extending Model-Based Design for HW/SW Design and Verification in MPSoCs Jim Tung MathWorks Fellow

Designing and Targeting Video Processing Subsystems for Hardware

Coupled Simulations Using different Tools

Module 1. Introduction to Mechatronics. Fundamentals of Mechatronics (MH501)

Keck-Voon LING School of Electrical and Electronic Engineering Nanyang Technological University (NTU), Singapore

Control Systems Laboratory Manual Hardware and Software Overview. 2 Hardware Equipment. 2.1 Analog Plant Simulator (EE357 Only)

Avnet Speedway Design Workshop

LEARNING TO PROGRAM WITH MATLAB. Building GUI Tools. Wiley. University of Notre Dame. Craig S. Lent Department of Electrical Engineering

AUDIO WEAVER DESIGNER USERS GUIDE

Mechanism Kinematics and Dynamics

Lecture overview. Visualisatie BMT. Vector algorithms. Vector algorithms. Time animation. Time animation

Introduction to Simulink

Implementation of Real Time Simulation of Power Systems with Different Controllers

Simulink Connector Guide. Simulink Connector Guide

MECHATRONICS SYSTEM ENGINEERING FOR CAE/CAD, MOTION CONTROL AND DESIGN OF VANE ACTUATORS FOR WATER ROBOT APPLICATIONS

MB Millenium Single- and Multi-Axis Vibration and Motion Control System

Transcription:

Interfacing Chrono & Matlab Chrono units for MATLAB and SIMULINK

Chrono::MATLAB Module for interfacing Chrono and MATLAB 2

Chrono::MATLAB Chrono::MATLAB is a C++ module that enables communication with MATLAB Features: call Matlab commands from your C++ program, exchange data to/from Matlab Chrono::Engine C++ matrices are converted to MATLAB, MATLAB variables and matrices are converted to Chrono::Engine C++ matrices use the MATLAB visualization tools, to show simulation data in 2D/3D plots, etc. Dependencies: Chrono::Engine main module (required) Chrono::Matlab module MATLAB license 3

Code organization FOLDER src/chrono_matlab src/demos/matlab CONTENT main Chrono::MATLAB library implementation Various demo programs 4

Example Call MATLAB command(s) // This is the object that you can use to access the Matlab engine. ChMatlabEngine matlab_engine; // EXAMPLE 1: execute a Matlab command matlab_engine.eval( "z=peaks(25); \ surf(z); \ colormap(jet); \ pause(4); \ "); 5

Example Pass a Chrono matrix to MATLAB ChMatrixDynamic<> m_time(30, 1); ChMatrixDynamic<> m_sine(30, 1); for (int i = 0; i < 30; i++) { m_time(i, 0) = ((double)i / 30.) * 5.; m_sine(i, 0) = sin(m_time(i, 0) * 2.); } matlab_engine.putvariable(m_time, "m_time"); matlab_engine.putvariable(m_sine, "m_sine"); matlab_engine.eval("figure; plot(m_time,m_sine);"); 6

Example Pass a MATLAB matrix to Chrono matlab_engine.eval("m_matr=[0:0.1:5]';"); ChMatrixDynamic<double> m_matr; matlab_engine.getvariable(m_matr, "m_matr"); 7

Chrono::COSIMULATION Unit for cosimulation between Chrono and SIMULINK 8

Chrono::Cosimulation Used for interfacing to SIMULINK More generally, Chrono::Cosimulation is a C++ module that enables basic cosimulation via TCP/IP sockets Features: C++ functions to send/receive datagrams using TCP/IP sockets from Chrono::Engine Can be used to co simulate with SIMULINK a CEcosimulation.mdl block is provided, to be inserted in your Simulink models as a ready to use interface to Chrono::Engine Dependencies: Chrono::Engine main module (required) Chrono::Matlab and Chrono::Cosimulation MATLAB & Simulink license 9

Code organization FOLDER src/chrono_cosimulation src/demos/cosimulation CONTENT main Chrono::COSIMULATION library implementation Various demo programs 10

Background Two way co simulation draws on two simulation tools which simultaneously simulate (advance in time) the two subsystems in which the original system is partitioned. Once in a while the two solvers (simulation tools) synchronize to exchange data after which they proceed independently until the next synchronization time. TCP/IP sockets are used to exchange data: This periodic data synchronization is necessary because the subsystems are coupled. For tightly coupled subsystems the synchronization happens very often. 11

Background A periodic data synchronization is necessary because the subsystems are coupled. For tightly coupled subsystems the synchronization must happen very often. 12

Example Co simulate of a Chrono mechanism with a SIMULINK pneumatic system 13

Example A typical SIMULINK model of a pneumatic system: 14

Example The SIMULINK model with cosimulated load: 15

Example Set parameters in the cosimulation block: 16

Example In Chrono: receive one variable from Simulink (the hydraulic cylinder force) send two variables to Simulink (the hydraulic cylinder velocity and displacement) First we must open a TCP/IP socket: ChSocketFramework socket_tools; ChCosimulation cosimul_interface(socket_tools, 1, // n.input values from Simulink 2); // n.output values to Simulink // Prepare the two column vectors of data that will be swapped ChMatrixDynamic<double> data_in(1, 1); ChMatrixDynamic<double> data_out(2, 1); // 4) Wait client (Simulink) to connect... int PORTNUM = 50009; cosimul_interface.waitconnection(portnum); matlab_engine.eval("m_matr=[0:0.1:5]';"); 17

Example while (true) { // A) ADVANCE THE Chrono SIMULATION if (dt > 0) my_system.dostepdynamics(dt); mytime += dt; // B) SYNCHRONIZATION // B.1) SEND data // * the velocity of the hydraulic actuator // * the displacement of the hydraulic actuator data_out(0) = my_link_actuator >GetDist_dt(); data_out(1) = my_link_actuator >GetDist() my_link_actuator >Get_SpringRestLength(); cosimul_interface.senddata(mytime, &data_out); // > to Simulink // B.2) RECEIVE data // * the force of the hydraulic actuator cosimul_interface.receivedata(histime, &data_in); // < from Simulink // Update the Chrono system with the force value that we received my_link_actuator >Set_SpringF(data_in(0)); } 18