JP4564255B2 - Simulation device - Google Patents

Simulation device Download PDF

Info

Publication number
JP4564255B2
JP4564255B2 JP2003416847A JP2003416847A JP4564255B2 JP 4564255 B2 JP4564255 B2 JP 4564255B2 JP 2003416847 A JP2003416847 A JP 2003416847A JP 2003416847 A JP2003416847 A JP 2003416847A JP 4564255 B2 JP4564255 B2 JP 4564255B2
Authority
JP
Japan
Prior art keywords
event
equation
program
simulation
continuous system
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Lifetime
Application number
JP2003416847A
Other languages
Japanese (ja)
Other versions
JP2004220577A (en
Inventor
充伸 吉田
浩一 近藤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Toshiba Corp
Original Assignee
Toshiba Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Toshiba Corp filed Critical Toshiba Corp
Priority to JP2003416847A priority Critical patent/JP4564255B2/en
Publication of JP2004220577A publication Critical patent/JP2004220577A/en
Application granted granted Critical
Publication of JP4564255B2 publication Critical patent/JP4564255B2/en
Anticipated expiration legal-status Critical
Expired - Lifetime legal-status Critical Current

Links

Images

Description

本発明は、コンピュータを用いて機械等の挙動のシミュレーションを行うための方法およびプログラムに関し、特に本発明はハイブリッドモデルを用いるものである。   The present invention relates to a method and program for simulating the behavior of a machine or the like using a computer. In particular, the present invention uses a hybrid model.

現在、コンピュータを用いて機械やプラント等の挙動のシミュレーションを行う際に、ハイブリッドモデリングと呼ばれる手法が使われている。ハイブリッドモデルを用いたシミュレーションは「ハイブリッドシミュレーション」と呼ばれている。このようなシミュレーション挙動をするシステムを「ハイブリッドシステム」と呼ぶこともある。   Currently, a technique called hybrid modeling is used when simulating the behavior of a machine or plant using a computer. The simulation using the hybrid model is called “hybrid simulation”. A system having such a simulation behavior is sometimes called a “hybrid system”.

シミュレーションの目的で作成されるハイブリッドモデルは、概念的には常微分方程式や代数方程式を連立させた連立方程式によって表現される連続系モデルと、イベント発生に伴う状態遷移を表現するための状態遷移モデルとを組み合わせたモデルである。ハイブリッドモデルによれば、連続系モデルで表現される状態が外部からのイベントなどにより瞬時に切り替わるシステムを表現することができる。   The hybrid model created for the purpose of simulation is conceptually a continuous system model that is expressed by simultaneous equations that are a combination of ordinary differential equations and algebraic equations, and a state transition model for expressing state transitions associated with event occurrences. It is a model that combines. According to the hybrid model, it is possible to express a system in which the state expressed by the continuous system model is instantaneously switched by an event from the outside.

ハイブリッドモデルを記述するための言語として、米国ゼロックス社(商標)のパロアルト研究所にて創作されたHCC(Hybrid Concurrent Constraint Programming)と呼ばれる言語がある(下記非特許文献1参照)。HCCは発展途上にあり、現在も米国NASAのエイムズ研究所において研究が進められている。HCCは制約処理プログラミング(コンストレイントプログラミング)と呼ばれる技術の一種であり、連続系モデルを表現する常微分方程式や代数方程式を制約として扱い、これら方程式をそのまま順不同で記述することができる。このような制約記述に、状態遷移を制御する記述を付加してHCC言語のハイブリッドモデルは完成される。HCCによれば、方程式をそのまま制約として羅列する(プログラミングする)ことができ、複雑なモデルを記述可能である。   As a language for describing a hybrid model, there is a language called HCC (Hybrid Concurrent Constraint Programming) created by Palo Alto Research Institute of Xerox Corporation (trademark) (see Non-Patent Document 1 below). HCC is in the process of development and is still being studied at the Ames Research Center in NASA. HCC is a kind of technology called constraint processing programming (constraint programming), and treats ordinary differential equations and algebraic equations representing continuous system models as constraints, and these equations can be described in any order as they are. A hybrid model of the HCC language is completed by adding a description for controlling the state transition to such a constraint description. According to HCC, equations can be listed (programmed) as constraints as they are, and complex models can be described.

このようにハイブリッドモデルの技術を用いれば、系の特性を常微分方程式などでモデル表現し、初期状態から時間の推移に従ってどのような挙動を示すかをシミュレーションすることができる。   By using the hybrid model technique in this way, it is possible to simulate the behavior of the system according to the time transition from the initial state by expressing the system characteristics as an ordinary differential equation.

微分方程式などで表現可能な対象や現象を的確にモデル化できるハイブリッドモデルの技術の応用例として、ソフトウェアにより機構が制御されるメカトロニクス機器の機構シミュレーションがある。かかる機構シミュレーションによれば、機構の実機が存在しない状況においても、当該機構を制御する制御ソフトウェアのプロトタイピング、テスト、あるいはデバッグなどが行えるようになる。
インターネット<URL:http://www2.parc.com/spl/projects/mbc/publications.html#cclanguages>
As an application example of a hybrid model technology that can accurately model objects and phenomena that can be expressed by differential equations, there is a mechanism simulation of mechatronics equipment in which the mechanism is controlled by software. According to such a mechanism simulation, prototyping, testing, or debugging of control software for controlling the mechanism can be performed even in a situation where no actual machine is present.
Internet <URL: http://www2.parc.com/spl/projects/mbc/publications.html#cclanguages>

しかし、ハイブリッドモデルを扱うことのできる公知のプログラム言語は、必ずしもメカトロニクス機器の機構シミュレーションに応用することを目的に開発されたものではなく、このため次のような問題点がある。   However, a known programming language that can handle a hybrid model is not necessarily developed for the purpose of applying to a mechanism simulation of a mechatronic device, and therefore has the following problems.

例えば米国ゼロックス社(商標)のHCCは、インタプリタ型のプログラミング言語であり、たとえば制御ソフトウェアが機構に送信するアクチュエータへの動作コマンドなどを、シミュレータの外部から制御信号として受け取るような構成とする場合、外部関数などを個別に定義する必要がある上、プログラミングにおいてかなりの工夫を必要とする。   For example, HCC of Xerox Corporation (trademark) is an interpreted programming language. For example, when it is configured to receive an operation command to the actuator transmitted from the control software to the mechanism as a control signal from the outside of the simulator, It is necessary to define external functions individually, and it requires considerable ingenuity in programming.

具体的には、モデル作成者は外部関数のプログラミングについて例えば以下の作業が必要となる。   Specifically, for example, the model creator needs to perform the following operations for external function programming.

(1)外部関数のプログラムを、HCC言語固有の外部関数記述用APIを利用してC言語などの別の言語で記述する。 (1) An external function program is described in another language such as C language using an external function description API unique to the HCC language.

(2)記述した外部関数のプログラムをC言語のコンパイラによってコンパイルし、例えば実行時にリンク可能なダイナミックリンクライブラリを作成する。 (2) The described external function program is compiled by a C language compiler to create a dynamic link library that can be linked at the time of execution, for example.

(3)HCCのインタプリタが呼び出せるように、HCCのインタプリタがそのパスを特定可能なディレクトリ上に作成されたライブラリを配置する。 (3) Place a library created on a directory where the path can be specified by the HCC interpreter so that the HCC interpreter can call it.

したがって、モデル作成者はHCC言語固有の外部関数記述用APIの習得が必要であるし、シミュレーション実行時には外部関数を別途コンパイルする手間もかかる。   Therefore, the model creator needs to learn the API for describing the external function unique to the HCC language, and it takes time and effort to separately compile the external function when executing the simulation.

また、モデル記述中の外部関数の呼び出し方法に関しても、外部関数の実行をイベントに関連付けて管理しないHCCでは、状態遷移が発生した瞬間に呼び出す場合と、数値積分時に呼び出す場合の両方の記述が可能であることから、モデル作成者は外部関数が実行されるタイミングを把握しにくく、モデル作成に高度な熟練を要する。   In addition, regarding the method of calling an external function in the model description, in the HCC that does not manage the execution of the external function in association with the event, both the case of calling at the moment when the state transition occurs and the case of calling at the time of numerical integration are possible. Therefore, it is difficult for the model creator to grasp the timing at which the external function is executed, and a high level of skill is required for model creation.

本発明はかかる事情を考慮してなされたものであり、ハイブリッドモデルを用いて複雑な機構系を簡便かつ正確にモデル化でき、該機構系を制御する制御ソフトウェアとの連携シミュレーションにも好適なシミュレーション方法およびプログラムを提供することを目的とする。   The present invention has been made in view of such circumstances, and can simulate a complicated mechanism system simply and accurately using a hybrid model, and is also suitable for a cooperative simulation with control software for controlling the mechanism system. An object is to provide a method and a program.

また、外部との連携などに関わる処理を記述するプログラムを直接ハイブリッドモデル記述の一部に含めることを可能にし、シミュレーションの適用範囲を拡大することを目的とする。   Another object of the present invention is to expand the scope of simulation by enabling a program describing processing related to external linkage to be directly included in a part of the hybrid model description.

本発明の一観点に係るシミュレーション方法は、ハイブリッドモデルを利用した記述データに基づいて、対象とする機構の挙動を時間軸に沿ってシミュレーションするシミュレーション方法であって、前記記述データに含まれる連続系方程式の記述、状態遷移に伴う該連続系方程式の切り替えに関する記述、及び前記連続系方程式で表現される処理以外の処理に関する記述を抽出するため、前記記述データを解析する解析ステップと、前記解析ステップにおいて抽出された前記連続系方程式の記述に基づいて、第1のプログラムを生成する第1のプログラム生成ステップと、前記解析ステップにおいて抽出された前記状態遷移に伴う連続系方程式の切り替えに関する記述に基づいて、第2のプログラムを生成する第2のプログラム生成ステップと、前記解析ステップにおいて抽出された前記連続系方程式で表現される処理以外の処理に関する記述に基づいて、第3のプログラムを生成する第3のプログラム生成ステップと、前記第1のプログラムを実行することにより、前記連続系方程式をシミュレーション実行可能なデータ構造に変換する変換ステップと、前記第2のプログラムを実行することにより、イベントの発生に応じて前記連続系方程式の有効・無効を切り替える切り替えステップと、前記切り替えステップにおいて有効とされた前記連続系方程式に対応する前記データ構造を用いて、時間軸に沿った数値積分により該連続系方程式を解いて、前記機構の挙動を表すデータを出力するシミュレーションを実行するシミュレーション実行ステップと、前記第3のプログラムを実行することにより、前記連続系方程式で表現される処理以外の処理を実行する処理実行ステップとを具備する。   A simulation method according to an aspect of the present invention is a simulation method for simulating the behavior of a target mechanism along a time axis based on description data using a hybrid model, and includes a continuous system included in the description data. An analysis step for analyzing the description data in order to extract a description of an equation, a description related to switching of the continuous system equation associated with state transition, and a description related to processing other than the processing expressed by the continuous system equation; and the analysis step Based on the description of the continuous system equation extracted in step 1, the first program generation step of generating a first program, and the description of switching of the continuous system equation accompanying the state transition extracted in the analysis step The second program generation step for generating the second program And a third program generation step for generating a third program based on a description related to processing other than the processing expressed by the continuous system equation extracted in the analysis step, and the first program is executed. A conversion step of converting the continuous system equation into a data structure that can be executed by simulation, and a switching step of switching the validity / invalidity of the continuous system equation according to the occurrence of an event by executing the second program And using the data structure corresponding to the continuous system equation validated in the switching step, solving the continuous system equation by numerical integration along the time axis and outputting data representing the behavior of the mechanism Simulation execution step for executing simulation, and the third program By executing comprises a processing execution step of executing a processing other than the processing represented by the continuous system equation.

本発明によれば、ハイブリッドモデルを用いて複雑な機構系を簡便かつ正確にモデル化でき、該機構系を制御する制御ソフトウェアとの連携シミュレーションにも好適なシミュレーション方法およびプログラムを提供できる。   According to the present invention, a complicated mechanism system can be modeled easily and accurately using a hybrid model, and a simulation method and a program suitable for cooperative simulation with control software for controlling the mechanism system can be provided.

以下、図面を参照しながら本発明の実施形態を説明する。   Hereinafter, embodiments of the present invention will be described with reference to the drawings.

(第1実施形態)
図1は本発明の第1実施形態に係る機構シミュレータの概略構成を示すブロック図である。
(First embodiment)
FIG. 1 is a block diagram showing a schematic configuration of a mechanism simulator according to the first embodiment of the present invention.

本実施形態は、ハイブリッドモデル前処理部201と、ハイブリッドモデルシミュレーション実行部102とにより構成されている。ハイブリッドモデル記述104は、ハイブリッドモデル記述言語等で記述されたソースプログラムであって、本実施形態に係るハイブリッドモデル前処理部201への入力である。ハイブリッドモデルシミュレーション実行部102からの出力は、連続系シミュレーション部103による連続系シミュレーションの結果として得られた変数値の演算結果およびその時間履歴である。この出力は変数値時間履歴記憶部105に記憶される。   The present embodiment includes a hybrid model preprocessing unit 201 and a hybrid model simulation execution unit 102. The hybrid model description 104 is a source program described in a hybrid model description language or the like, and is an input to the hybrid model preprocessing unit 201 according to the present embodiment. The output from the hybrid model simulation execution unit 102 is a variable value calculation result obtained as a result of the continuous system simulation by the continuous system simulation unit 103 and its time history. This output is stored in the variable value time history storage unit 105.

図1に示すように、ハイブリッドモデル前処理部201は、制御情報解析部110を備える。また、ハイブリッドモデルシミュレーション実行部102は、イベント処理部111、方程式構文解析部112、方程式データ記憶部114、連続系方程式切り替え部115、付加処理実行部205、及び連続系シミュレーション部103を備える。なお、本実施形態は一般的なコンピュータを用いて構成することができ、その基本的なハードウェア構成として、図示しないが中央演算ユニット(CPU)、メモリ、外部記録装置、通信インターフェース(I/F)、および表示装置やキーボード、マウス等の入力装置を備える。また、これらのハードウェアを制御するためのオペレーティングシステム(OS)を備える。また、本発明の実施形態に係る機構シミュレータは、このようなオペレーティングシステム上で動作するアプリケーションソフトウェアとして実装することができる。   As shown in FIG. 1, the hybrid model preprocessing unit 201 includes a control information analysis unit 110. The hybrid model simulation execution unit 102 includes an event processing unit 111, an equation syntax analysis unit 112, an equation data storage unit 114, a continuous system equation switching unit 115, an additional process execution unit 205, and a continuous system simulation unit 103. The present embodiment can be configured by using a general computer, and the basic hardware configuration is not shown, but a central processing unit (CPU), a memory, an external recording device, and a communication interface (I / F). ), And input devices such as a display device, a keyboard, and a mouse. In addition, an operating system (OS) for controlling these hardware is provided. The mechanism simulator according to the embodiment of the present invention can be implemented as application software that operates on such an operating system.

このような本実施形態に係る機構シミュレータの構成及びその処理手順について説明する前に、ここではまずハイブリッドモデル記述104がどのように記述されるのか、具体例を挙げて説明する。   Before describing the configuration of the mechanism simulator according to this embodiment and the processing procedure thereof, first, how the hybrid model description 104 is described will be described with a specific example.

図2および図3は、具体例に係るハイブリッドモデルの記述対象である機構を示す図である。この機構は、バルブ301、バネ303、およびピストン302を備えた簡素な構造のシリンダ装置である。   2 and 3 are diagrams showing a mechanism that is a description target of a hybrid model according to a specific example. This mechanism is a cylinder device having a simple structure including a valve 301, a spring 303, and a piston 302.

バルブ301は外部からの指令(イベント)に応じて開閉動作する。これによりシリンダ装置内の空気の流れを図2のように右側に変更するイベントを以下、「Left」と呼び、空気の流れを図3のように左側に変更するイベントを「Right」と呼ぶ。図2は、バルブ301にLeftのイベントが与えられた状態を示しており、ピストン302には紙面右向きの力が作用している。この状態を示す運動方程式はシリンダ装置の下部に示してあるように、「-F=mx''」である。これに対し図3は、バルブ301にRightのイベントが与えられた状態を示しており、空気の流れの向きが変わり、運動方程式は同図のように「F=mx''」に変化している。   The valve 301 opens and closes in response to a command (event) from the outside. Thus, the event of changing the air flow in the cylinder device to the right as shown in FIG. 2 is hereinafter referred to as “Left”, and the event of changing the air flow to the left as shown in FIG. 3 is called “Right”. FIG. 2 shows a state in which the Left event is given to the valve 301, and a rightward force is applied to the piston 302. The equation of motion indicating this state is “−F = mx ″” as shown at the bottom of the cylinder device. On the other hand, FIG. 3 shows a state in which a right event is given to the valve 301, the direction of the air flow changes, and the equation of motion changes to “F = mx” ”as shown in FIG. Yes.

図4は、このような機構の挙動を、状態の遷移とそれぞれの状態に対応する運動方程式とからなる状態遷移図として表現したものである。ハイブリッドモデルは、この図4に示されるような状態遷移と、各状態の記述が微分方程式や代数方程式あるいはそれらの連立方程式(連続系方程式)で表現されるものを指す。図4によれば、状態が2つあって、かかる2つの状態間に状態遷移が存在することがわかる。   FIG. 4 represents the behavior of such a mechanism as a state transition diagram composed of state transitions and equations of motion corresponding to the respective states. The hybrid model indicates a state transition as shown in FIG. 4 and a description of each state expressed by a differential equation, an algebraic equation, or a simultaneous equation (continuous system equation) thereof. According to FIG. 4, it can be seen that there are two states and there is a state transition between the two states.

本発明では、図4の状態遷移図をもとに具体的なハイブリッドモデルの内容をHCC(Hybrid Concurrent Constraint Programming)言語で記述するとともに、連続系方程式で表現される処理以外の処理、例えば、外部との連携などに関わる処理(以下「付加処理」という)を所定のプログラム言語で記述することによりハイブリッドモデル記述104が生成される。   In the present invention, specific hybrid model contents are described in the HCC (Hybrid Concurrent Constraint Programming) language based on the state transition diagram of FIG. 4, and processing other than processing expressed by continuous system equations, for example, external The hybrid model description 104 is generated by describing a process related to the cooperation with the program (hereinafter referred to as “addition process”) in a predetermined program language.

図5は、本発明にかかるハイブリッドモデル記述に相当するプログラムの一例を示す図である。図5において、(ソース)プログラムの論理行番号を仮にL1〜L23とする。L3、L4、およびL8は、上記した機械装置の初期状態やバルブ操作タイミング等の運転条件の記述に相当し、L5およびL6は図4に示した状態遷移の表現記述に相当する。また、L9〜L23は付加処理に係る記述であり、ここでは「現在の状態をファイルに書き込む」という内容の処理が記述されている。なお、module文には"C"と指定されており、該当するL9〜L17はC言語によるプログラム記述となっている。   FIG. 5 is a diagram showing an example of a program corresponding to the hybrid model description according to the present invention. In FIG. 5, the logical line numbers of the (source) program are assumed to be L1 to L23. L3, L4, and L8 correspond to the description of the operating conditions such as the initial state of the mechanical device and the valve operation timing described above, and L5 and L6 correspond to the expression description of the state transition shown in FIG. Further, L9 to L23 are descriptions relating to the additional processing, and here, processing of the content “write current state to file” is described. Note that “C” is specified in the module statement, and the corresponding L9 to L17 are program descriptions in the C language.

HCC言語では、図5のL5およびL6から分かるように、運動方程式をプログラム内でそのまま記述することができる。L5およびL6とでは状態が異なる。また、それぞれの状態において、当該状態へ遷移する条件を前提条件といい、「always if」に続いて記述される。また、当該状態をキャンセルする条件、言い替えれば当該状態から遷移していく条件を遷移条件といい、「watching」に続けて記述される。   In the HCC language, as can be seen from L5 and L6 in FIG. 5, the equation of motion can be described as it is in the program. The state is different between L5 and L6. In each state, a condition for transitioning to the state is called a precondition, and is described after “always if”. Also, a condition for canceling the state, in other words, a condition for transitioning from the state is referred to as a transition condition, which is described after “watching”.

なお、HCCでは、プログラムの記述の順序(例えば図5における論理行番号L1→L8の順序)にそって実行されるわけではない。HCCでは、個別のプログラム記述のうち、シミュレーションを実行する時間軸に沿って成立するものが探索され、実行される。すなわち、論理行番号L1→L8の順序は、実行順序とは関係がない。たとえば、シミュレーションを開始した時点では、L3およびL8のみが有効である。ここで、イベントRight(ev1)がL3により発生するため、L6の前提条件であるRightが有効となり、L6に記述されている運動方程式eq2が有効になる。つまり、図4の左側の状態からシミュレーションが実行されることになる。   In the HCC, the program description is not executed in accordance with the program description order (for example, the order of logical line numbers L1 to L8 in FIG. 5). In the HCC, an individual program description that is established along a time axis for executing a simulation is searched for and executed. That is, the order of the logical line numbers L1 → L8 has nothing to do with the execution order. For example, when the simulation is started, only L3 and L8 are valid. Here, since the event Right (ev1) is generated by L3, Right, which is a precondition for L6, is valid, and the motion equation eq2 described in L6 is valid. That is, the simulation is executed from the state on the left side of FIG.

さらに、時間が50になるとL4が有効となり、イベントLeft(ev2)が発生し、L6の遷移条件(「watching」以下、すなわちLeft)が有効となって、L6の運動方程式eq2が無効となる。これに代わって、L5の前提条件が有効となり、運動方程式eq1が有効となる。   Furthermore, when the time reaches 50, L4 becomes valid, the event Left (ev2) occurs, the transition condition of L6 (below “watching”, ie, Left) becomes valid, and the motion equation eq2 of L6 becomes invalid. Instead, the precondition of L5 becomes effective and the equation of motion eq1 becomes effective.

なお、以上のようなプログラム例は外部からのイベントによって状態が遷移する場合を記述したもの(L5、L6)であったが、勿論、内部の状況によって状態を遷移させてもよい。たとえば、図2においてバルブ301が切り替えられない場合には、移動するピストン302がバネ303に接触し、該バネ303からの反力を受けるようになる。すなわちピストン302の位置に関して、外部からのイベントが無い場合でも状態遷移が起こる場合が存在する。このような場合は、例えばxが正であるかどうかといった内部変数の評価式(不等式)による評価結果に基づいて状態遷移の必要性を判断できる。   In the above example of the program, the case where the state is changed by an external event (L5, L6) is described. Of course, the state may be changed depending on the internal situation. For example, when the valve 301 is not switched in FIG. 2, the moving piston 302 comes into contact with the spring 303 and receives a reaction force from the spring 303. That is, regarding the position of the piston 302, there may be a state transition even when there is no external event. In such a case, the necessity of state transition can be determined based on the evaluation result of the internal variable evaluation expression (inequality expression) such as whether x is positive.

一般的に、ハイブリッドモデルは、常微分方程式や代数方程式を連立させた連立方程式によって表現される連続系モデルと、イベント発生に伴う状態遷移を表現するための状態遷移モデルとを組み合わせたモデルである。ハイブリッドモデルによれば、連続系モデルで表現される状態が外部からのイベントなどにより瞬時に切り替わるシステムを表現することができる。   In general, a hybrid model is a model that combines a continuous system model expressed by simultaneous equations in which ordinary differential equations and algebraic equations are combined, and a state transition model for expressing state transitions accompanying event occurrence. . According to the hybrid model, it is possible to express a system in which the state expressed by the continuous system model is instantaneously switched by an event from the outside.

さらに、時間が100になるとL19が有効となり、イベントE(ev5)が発生し、cPrintという関数が引数xの値とともに呼び出される(L18〜L23)。この記述は、その時点での状態をファイルに保存する付加処理が実行されることを示しており、その具体的な処理の内容は、L9〜L17において例えばC言語で記述されている。   Further, when the time reaches 100, L19 becomes valid, an event E (ev5) occurs, and a function called cPrint is called with the value of the argument x (L18 to L23). This description indicates that an additional process for saving the state at that time in a file is executed, and specific contents of the process are described in, for example, C language in L9 to L17.

行L18〜L23は付加処理(L11〜L16)を制御するハイブリッドモデル記述104の内容である。process(E)cPrint(x)という記述は、イベントEの発生に伴い付加処理すなわちcPrint(x)を実行せよ、という命令構文である。ここで、付加処理の実行制御に関係するイベントは連続系方程式の切り替えに関係するLeftイベント、Rightイベントと同じイベントを使って記述可能である。   Lines L18 to L23 are the contents of the hybrid model description 104 that controls the additional processing (L11 to L16). The description of process (E) cPrint (x) is an instruction syntax for executing additional processing, that is, cPrint (x) when the event E occurs. Here, the event related to the execution control of the additional processing can be described using the same event as the Left event and the Right event related to switching of the continuous system equation.

このような本実施形態によれば、(1)付加処理の内容を、連続系方程式の切り替えを有するハイブリッドモデルに相当する記述と同一のプログラムソース上に記述できる。また、(2)付加処理を呼び出したりする等の制御をハイブリッド記述できる。したがって、分かりやすく簡潔なシミュレーションモデルを記述できる。   According to the present embodiment as described above, (1) the contents of the additional processing can be described on the same program source as the description corresponding to the hybrid model having switching of continuous system equations. Also, (2) control such as calling additional processing can be described in a hybrid manner. Therefore, an easy-to-understand and simple simulation model can be described.

次に、ハイブリッドモデル前処理部201における処理について説明する。ハイブリッドモデル記述104は、まずハイブリッドモデル前処理部201の制御情報解析部110において処理され、モデル方程式登録プログラム202、イベント制御プログラム203、及びシミュレーション実行時付加処理プログラム204が生成される。   Next, processing in the hybrid model preprocessing unit 201 will be described. The hybrid model description 104 is first processed in the control information analysis unit 110 of the hybrid model preprocessing unit 201, and a model equation registration program 202, an event control program 203, and a simulation execution additional processing program 204 are generated.

ハイブリッドモデルシミュレーション実行部102を構成するソフトウェアモジュールとして、モデル方程式の登録を行うための関数及び連続系方程式を切り替えるための関数がAPI(Application Program Interface)関数として提供される。モデル方程式登録プログラム202およびイベント制御プログラム203は、該当する上記API関数を呼び出す記述を、入力されたハイブリッドモデル記述104に沿って適切に組み合わせたプログラムである。この観点から考えると、ハイブリッドモデル前処理部201は、入力をハイブリッドモデル記述104とし、出力を例えばC言語のAPI関数呼び出しの記述を含むCプログラム(ソース)とするような、一種のコンパイラと考えることもできる。このようなモデル方程式登録プログラム202とイベント制御プログラム203は、さらにC言語などのコンパイラによりコンパイルされ、例えば実行時に動的にリンク可能なライブラリが生成される。ハイブリッドモデルシミュレーション実行部102では、シミュレーション実行にあたって、生成された動的リンクライブラリがリンクされ、入力ハイブリッドモデルを忠実に再現するシミュレーションプログラムが完成し、実行可能になる。なお、生成されるこれらのライブラリは必ずしも動的リンクライブラリである必要はなく、静的なライブラリであってもよい。   As software modules constituting the hybrid model simulation execution unit 102, a function for registering model equations and a function for switching continuous system equations are provided as API (Application Program Interface) functions. The model equation registration program 202 and the event control program 203 are programs in which descriptions for calling the corresponding API functions are appropriately combined along with the input hybrid model description 104. From this point of view, the hybrid model preprocessing unit 201 is considered as a kind of compiler in which the input is the hybrid model description 104 and the output is a C program (source) including, for example, a C API function call description. You can also The model equation registration program 202 and the event control program 203 are further compiled by a compiler such as C language, and for example, a library that can be dynamically linked at the time of execution is generated. In the hybrid model simulation execution unit 102, the generated dynamic link library is linked in executing the simulation, and a simulation program that faithfully reproduces the input hybrid model is completed and can be executed. Note that these generated libraries are not necessarily dynamic link libraries, and may be static libraries.

ハイブリッドモデルシミュレーション実行部102のアプリケーションインターフェースを構成する具体的なソフトウェアモジュールの仕様などは様々考えられるが、ここでは説明の都合上、以下の3つのAPI関数が最低定義されているとする。なお、プログラミング言語はC言語とする。

Figure 0004564255
Various specifications of the specific software module constituting the application interface of the hybrid model simulation execution unit 102 can be considered. Here, for convenience of explanation, it is assumed that the following three API functions are defined at the minimum. The programming language is C language.
Figure 0004564255

1つ目のAPI関数XXX_AddEqnDataは、1つの連続系方程式を表す文字列のポインタを引数に指定する。XXX_AddEqnDataは、この連続系方程式を構文解析し、連続系方程式の記述をシミュレーション実行可能なデータ構造(内部データ表現)に変換し、かかる内部データ表現を方程式データ記憶部114に登録する処理を行う。なお、ここの連続系方程式には、ユニークなID番号が割り当てられる。   The first API function XXX_AddEqnData designates a character string pointer representing one continuous system equation as an argument. XXX_AddEqnData parses this continuous system equation, converts the description of the continuous system equation into a data structure (internal data representation) that can be simulated, and registers the internal data representation in the equation data storage unit 114. A unique ID number is assigned to the continuous system equation.

たとえば「ab/cos(a-(c+b))-3c」という式が与えられたと仮定すると、上記内部データ表現として図6のような木構造を生成する。この木構造において、例えば参照数字61は線形多項式の親ノード(節)、62は掛け算のノード、63は割り算のノード、64は外部関数(四則演算以外の意)のノード、65は線形多項式を構成する各項のノードを表している。本例において、木構造の葉に相当するものはすべて変数(a,b,c)であり、これらに実数の係数が加わって線形式となる。線形式はcos などの外部関数の引数になったり、掛け算や割り算の対象となる。変数には、別途、値が確定しているかどうかのフラグが設けられており、またこのような木構造のデータに基づいて該変数の現在の値が保持される。木構造のすべての葉の値(すなわち変数の値)が確定していれば、式の値を計算することができる。方程式データ記憶部114では、式の値の計算などを高速に行うことができるように、予め内部のデータ構造をつなぎ合わせて木構造を構成してある。上記処理において何らかのエラーが発生した場合には、err にエラーコードがセットされる。正常に処理が終了した場合は、登録された方程式のID番号を返り値とする。   For example, assuming that an expression “ab / cos (a− (c + b)) − 3c” is given, a tree structure as shown in FIG. In this tree structure, for example, reference numeral 61 is a parent node (clause) of a linear polynomial, 62 is a multiplication node, 63 is a division node, 64 is a node of an external function (meaning other than four arithmetic operations), and 65 is a linear polynomial. Represents a node for each component. In this example, all the leaves corresponding to the leaves of the tree structure are variables (a, b, c), and a real number coefficient is added to these to form a linear form. The line format can be an argument of an external function such as cos, or it can be subject to multiplication or division. The variable is separately provided with a flag indicating whether or not the value is fixed, and the current value of the variable is held based on such tree-structured data. If the values of all the leaves of the tree structure (ie the values of the variables) are fixed, the value of the expression can be calculated. In the equation data storage unit 114, the internal data structure is connected in advance so that the calculation of the value of the equation can be performed at high speed. If any error occurs in the above process, an error code is set in err. When the process is normally completed, the ID number of the registered equation is used as a return value.

2番目のAPI関数XXX_ActivateEqnは、引数に指定された方程式のID番号に相当する方程式を有効にする。もし、すでに有効となっている方程式が指定されている場合には何もしない。返り値はエラーコードである。   The second API function XXX_ActivateEqn activates the equation corresponding to the ID number of the equation specified as the argument. If an already valid equation is specified, nothing is done. The return value is an error code.

3番目のAPI関数XXX_DeActivateEqnは、XXX_ActivateEqnとは逆に、引数に指定された方程式のID番号に相当する方程式を無効にする。すでに無効となっている方程式が指定された場合には何もしない。   In contrast to XXX_ActivateEqn, the third API function XXX_DeActivateEqn invalidates the equation corresponding to the ID number of the equation specified as the argument. Does nothing if an invalid equation is specified.

制御情報解析部110は、まずXXX_AddEqnDataを必要な方程式について順に呼ぶ関数(InitEqnData)を生成する。これがモデル方程式登録プログラム202(第1のプログラム)に相当する。   The control information analysis unit 110 first generates a function (InitEqnData) that sequentially calls XXX_AddEqnData for necessary equations. This corresponds to the model equation registration program 202 (first program).

また、制御情報解析部110は、シミュレーション実行の際に、時間がΔt進むごとに条件のチェックおよび方程式の変更(入れ替え)を行う関数(ChangeEqn)も生成する。これはイベント制御プログラム203(第2のプログラム)に相当する。   Further, the control information analysis unit 110 also generates a function (ChangeEqn) that performs condition check and equation change (replacement) every time the time advances by Δt during simulation execution. This corresponds to the event control program 203 (second program).

ここで、ChangeEqn関数はLeftイベント、Rightイベント、およびEイベントの発生をGetEvent関数により検知する。ChangeEqn関数はシミュレーション実行時における時間ステップ毎にイベント処理部111から呼び出される。   Here, the ChangeEqn function detects the occurrence of the Left event, the Right event, and the E event by the GetEvent function. The ChangeEqn function is called from the event processing unit 111 at each time step during simulation execution.

ハイブリッドモデルシミュレーション実行部102では、図1から分かるようにイベント処理部111と連続系シミュレーション部103とが分離されている。したがって、イベント制御プログラム203には時間積分などの時間に依存するモジュールは含まれず、これに対応するイベント処理部111は連続系方程式の有効・無効のフラグの切り替えのみを行う。   In the hybrid model simulation execution unit 102, as can be seen from FIG. 1, the event processing unit 111 and the continuous system simulation unit 103 are separated. Therefore, the event control program 203 does not include a time-dependent module such as time integration, and the event processing unit 111 corresponding thereto only switches the valid / invalid flag of the continuous system equation.

このようなシミュレータ構成を採ることにより、外部機器とのインターフェースに係るイベントとハイブリッド記述に係るイベントとを同一の処理(if(GetEvent(イベント)処理)で管理することができる。   By adopting such a simulator configuration, the event related to the interface with the external device and the event related to the hybrid description can be managed by the same processing (if (GetEvent (event) processing)).

また、ハイブリッドモデル前処理部201は、ハイブリッドシミュレーションモデルをいったん付加処理と同一の言語として出力するため、容易にハイブリッドシミュレーション実行プログラムを生成可能である。   Moreover, since the hybrid model preprocessing unit 201 once outputs the hybrid simulation model as the same language as the additional processing, it is possible to easily generate a hybrid simulation execution program.

以上からハイブリッドシミュレーションと外部機器との連携が容易になる。   As described above, cooperation between the hybrid simulation and the external device becomes easy.

さらに、制御情報解析部110は、付加処理の内容記述をハイブリッドモデル記述104から抽出する。かかる記述が、シミュレーション実行部付加処理プログラム204(第3のプログラム)に相当する。シミュレーション実行部付加処理プログラム204はハイブリッドモデル記述104中でもともとC言語などにより記述されたプログラムのソースに相当する。例えば図5に示したハイブリッドモデル記述104中では、module文が参照され、C言語で記述された部分が抽出される。抽出されたシミュレーション実行部付加処理プログラム204は、C言語コンパイラによりコンパイルされ、動的にリンク可能なライブラリが生成される。付加処理実行部205は、この動的にリンク可能なライブラリを呼び出すインターフェースの役割を担う。なお、生成されるライブラリは必ずしも動的リンクライブラリである必要はなく、静的なライブラリであってもよい。また、付加処理の内容を記述する言語はC言語に限定されない。   Further, the control information analysis unit 110 extracts the content description of the additional process from the hybrid model description 104. Such a description corresponds to the simulation execution unit additional processing program 204 (third program). The simulation execution part addition processing program 204 corresponds to the source of a program originally described in the C language or the like in the hybrid model description 104. For example, in the hybrid model description 104 shown in FIG. 5, a module statement is referred to, and a portion described in C language is extracted. The extracted simulation execution unit additional processing program 204 is compiled by a C language compiler to generate a dynamically linkable library. The additional processing execution unit 205 plays a role of an interface for calling this dynamically linkable library. The generated library is not necessarily a dynamic link library, and may be a static library. Further, the language for describing the contents of the additional processing is not limited to the C language.

上記したようなハイブリッドモデル前処理部201における処理により、例えば、図5に示したハイブリッドモデル記述について、以下のようなC言語のソースプログラムが自動生成される。

Figure 0004564255
By the processing in the hybrid model preprocessing unit 201 as described above, for example, the following C language source program is automatically generated for the hybrid model description shown in FIG.
Figure 0004564255

なお、GetEventは、引数に指定された名前(eventname)のイベントが生起しているかどうかをチェックする関数である。   Note that GetEvent is a function that checks whether an event with the name (eventname) specified in the argument has occurred.

以上のプログラムは、上述したようにC言語コンパイラによってコンパイルされ、さらに動的リンクライブラリの形式に整えられ、実行時にリンクされる。   The above programs are compiled by a C language compiler as described above, further arranged in the form of a dynamic link library, and linked at the time of execution.

なお、本実施形態では、プログラム言語としてC言語を用いた例について説明したが、本発明はこれに限定されるものではなく、例えばC++言語、SpecC言語等の他のプログラム言語を用いてもよい。   In this embodiment, an example in which the C language is used as the programming language has been described. However, the present invention is not limited to this, and other programming languages such as a C ++ language and a SpecC language may be used. .

次に、シミュレーションの実行について説明する。シミュレーション実行時においては、ハイブリッドモデルシミュレーション実行部102が起動され、連続系方程式の値を計算することでシミュレーション実行が行われる。このとき、連続系方程式切り替え部115は、イベント処理部111の内部で呼び出され、連続系方程式の切り替えを有効・無効のフラグを用いて実行する。イベント処理部111は前処理において生成されたイベント制御プログラム203(第2のプログラム;ChangeEqn)に対応する。図2の状態では、図5の運動方程式eq1は無効であり、運動方程式eq2が有効になっている。ここで、Leftのイベントが発生した図3の状況においては、図5の運動方程式eq1を有効にし、運動方程式eq2を無効にするようフラグを操作する。これら有効・無効のフラグは方程式データ記憶部114に記憶される方程式それぞれの属性データとして管理される。   Next, simulation execution will be described. At the time of simulation execution, the hybrid model simulation execution unit 102 is activated and the simulation execution is performed by calculating the value of the continuous system equation. At this time, the continuous system equation switching unit 115 is called inside the event processing unit 111 and executes switching of the continuous system equation using the valid / invalid flag. The event processing unit 111 corresponds to the event control program 203 (second program; ChangeEqn) generated in the preprocessing. In the state of FIG. 2, the equation of motion eq1 of FIG. 5 is invalid, and the equation of motion eq2 is valid. Here, in the situation of FIG. 3 in which the Left event has occurred, the flag is operated so that the motion equation eq1 of FIG. 5 is validated and the motion equation eq2 is invalidated. These valid / invalid flags are managed as attribute data of each equation stored in the equation data storage unit 114.

連続系シミュレーション部103は、方程式データ記憶部114を参照し、同記憶部114に木構造の形式で格納されている連続系方程式の内部データ表現を演算対象として、時間ステップづつ数値積分を実行する。シミュレーションは、常微分方程式及び代数多項式の連立からなる非線形連立方程式についての初期値問題である。このため、例えば図2に示される初期状態が与えられている。具体的には、例えば一般によく使われているルンゲクッタアルゴリズムを用いて解の値を計算する。   The continuous system simulation unit 103 refers to the equation data storage unit 114 and executes numerical integration for each time step using the internal data representation of the continuous system equation stored in the storage unit 114 in the form of a tree structure as an operation target. . The simulation is an initial value problem for a non-linear simultaneous equation consisting of a set of ordinary differential equations and algebraic polynomials. For this reason, for example, the initial state shown in FIG. 2 is given. Specifically, for example, a solution value is calculated using a commonly used Runge-Kutta algorithm.

必要なデータは機構シミュレータから出力を行い、さらに連続系方程式切り替え部115の処理に戻り、上記の処理を繰り返すことにより必要な時間のシミュレーションを実行する。シミュレーション結果は、変数値時間履歴記憶部105に保存され、シミュレーション終了後の分析などに利用される。   Necessary data is output from the mechanism simulator, and the process returns to the process of the continuous system equation switching unit 115, and the above process is repeated to execute the simulation for the necessary time. The simulation result is stored in the variable value time history storage unit 105 and used for analysis after the simulation is completed.

図7は、以上説明した本発明の第1実施形態に係る機構シミュレーションにおける一連の処理手順を示すフローチャートである。この処理手順はハイブリッドモデル前処理の段階とシミュレーション実行の段階とに大別できる。   FIG. 7 is a flowchart showing a series of processing procedures in the mechanism simulation according to the first embodiment of the present invention described above. This processing procedure can be roughly divided into a hybrid model preprocessing stage and a simulation execution stage.

まず、ハイブリッドモデル記述104が制御情報解析部110に入力され、ハイブリッドモデルの構文解析が行われる(ステップS1)。制御情報解析部110は図1に示すようにモデル方程式登録プログラム202、イベント制御プログラム203、及びシミュレーション実行時付加処理プログラム204をそれぞれ生成する。シミュレーション実行のための前処理を終えると、ここからシミュレーション実行の段階に移る。   First, the hybrid model description 104 is input to the control information analysis unit 110, and the hybrid model is analyzed (step S1). As shown in FIG. 1, the control information analysis unit 110 generates a model equation registration program 202, an event control program 203, and a simulation execution additional processing program 204, respectively. When the pre-processing for the simulation execution is completed, the process proceeds to the simulation execution stage.

先ず、ハイブリッドモデルシミュレーション実行部102から方程式構文解析部112が呼び出される。方程式構文解析部112はモデル方程式登録プログラム202(第1のプログラム;InitEqnData)に対応し、その内部でAPI関数XXX_AddEqnDataを呼び出す。これにより連続系方程式の記述データがシミュレーション実行可能なデータ構造に変換される。変換されたデータは方程式データ記憶部114に登録される(ステップS2)。   First, the equation syntax analysis unit 112 is called from the hybrid model simulation execution unit 102. The equation syntax analysis unit 112 corresponds to the model equation registration program 202 (first program; InitEqnData), and calls an API function XXX_AddEqnData therein. As a result, the description data of the continuous system equation is converted into a data structure that can be simulated. The converted data is registered in the equation data storage unit 114 (step S2).

ステップS3においてハイブリッドモデル記述104に基づく初期状態が決定されたのち、ステップS4において、イベントが発生したかどうかを検知する。このため、ハイブリッドモデルシミュレーション実行部102はイベント処理部111を呼び出す。イベント処理部111はイベント制御プログラム203(第2のプログラム;ChangeEqn)に対応し、その内部でGetEventを呼び出す。イベントが発生したならば、制御はステップS5に進む。イベントが発生していない場合は、ステップS6に進み、連続系シミュレーション部103が数値積分を実行する。   After the initial state based on the hybrid model description 104 is determined in step S3, it is detected in step S4 whether an event has occurred. Therefore, the hybrid model simulation execution unit 102 calls the event processing unit 111. The event processing unit 111 corresponds to the event control program 203 (second program; ChangeEqn) and calls GetEvent therein. If an event has occurred, control proceeds to step S5. If no event has occurred, the process proceeds to step S6, where the continuous system simulation unit 103 executes numerical integration.

ステップS5において、発生したイベントが付加処理に関連しているか否かを判定する。該イベントが付加処理に関連するものではない場合は、ステップS9において、状態遷移に伴う連続系方程式の切り替えが必要であるか否かを判定する。方程式の切り替えが必要であるならば、ステップS10において、有効無効フラグを操作することにより、アクティブな連続方程式の切り替えを行う。このため、API関数XXX_ActivateEqnまたはXXX_DeActivateEqnが呼び出される。ステップS9又はステップS10の実行の後に、ステップS6において連続系シミュレーション部103が数値積分を実行する。   In step S5, it is determined whether or not the generated event is related to the additional process. If the event is not related to the additional process, it is determined in step S9 whether or not switching of the continuous system equation accompanying the state transition is necessary. If it is necessary to switch equations, in step S10, the active continuous equation is switched by manipulating the valid / invalid flag. For this reason, the API function XXX_ActivateEqn or XXX_DeActivateEqn is called. After execution of step S9 or step S10, the continuous system simulation unit 103 executes numerical integration in step S6.

発生したイベントが付加処理に関連するものである場合は、ステップS11において該当する付加処理を実行する。具体的な付加処理の例としては、画面上に処理の進捗状況を表示したり、シミュレーションに関わるデータをファイルに出力するなどの処理が考えられる。ステップS11にて付加処理が実行された後、ステップS6に進み、連続系シミュレーション部103は数値積分を実行する。   If the generated event is related to the additional process, the corresponding additional process is executed in step S11. As a specific example of the additional process, a process such as displaying the progress of the process on the screen or outputting data related to the simulation to a file can be considered. After the additional processing is executed in step S11, the process proceeds to step S6, and the continuous system simulation unit 103 executes numerical integration.

次に、ステップS7において終了条件の判定をする。ここでは、時間が所定のシミュレーション終了時間に到達したかどうかを判定する。シミュレーション終了時間に到達したらシミュレーション実行を終了する。それまではステップS8にて時間を1ステップ進めてステップS4に戻り、同様の処理手順を繰り返す。   Next, the end condition is determined in step S7. Here, it is determined whether or not the time has reached a predetermined simulation end time. When the simulation end time is reached, the simulation execution is terminated. Until then, the time is advanced by one step in step S8, the process returns to step S4, and the same processing procedure is repeated.

以上の処理を図5に示したハイブリッドモデル記述について実行した場合の時系列的な流れを図8に示す。t=0は初期状態を示し、t=0でイベントLeftが発生し連続系方程式が切り替えられ、t=100でイベントEが発生し付加処理が実行される。かかるイベント間は連続系のシミュレーションが実行されている。   FIG. 8 shows a time-series flow when the above processing is executed for the hybrid model description shown in FIG. t = 0 indicates an initial state, an event Left is generated at t = 0, the continuous system equation is switched, an event E is generated at t = 100, and additional processing is executed. A continuous simulation is performed between such events.

ハイブリッドモデルシミュレーション実行部102が機構制御ソフトウェアシミュレータと連携し、全体として効率的にシミュレーションが実行されるためには、該シミュレーションを構成する各ステップの実行順序が適切かつ効率的に制御されなければならない。   In order for the hybrid model simulation execution unit 102 to cooperate with the mechanism control software simulator and execute the simulation efficiently as a whole, the execution order of the steps constituting the simulation must be appropriately and efficiently controlled. .

既に述べたように従来では、ハイブリッドモデル記述言語(例えばHCC言語)の特性(どの行が最初に実行されるか分からない)に起因し、上記実行順序を適切かつ効率的に制御するようプログラミングするには、極めて高度なテクニックを要し、難易度の高い作業である。また、単なる変数の値を扱うのではなく、外部から得られた情報を変数に代入してからハイブリッドモデルの処理を行う場合もある。この場合、外部とのインターフェースに関わる特別な外部関数などを用意し、これらをモデルの作成者が記述しなければならなかった。   As described above, conventionally, programming is performed to appropriately and efficiently control the execution order due to the characteristics of the hybrid model description language (eg, HCC language) (which line is not executed first). Is a very difficult task that requires extremely advanced techniques. In addition, instead of simply handling the value of a variable, the hybrid model may be processed after substituting information obtained from the outside into the variable. In this case, special external functions related to the interface with the outside must be prepared and the model creator had to describe them.

これに対し、本発明の実施形態は、図7に示した一連の処理に従いハイブリッドモデルシミュレーション実行部102を構築し、シミュレーション実行するよう構成されていることから、上記のような問題を回避できる。すなわち、機構制御ソフトウェアシミュレータ等の外部(プロセス)との間の通信に相当するソフトウェア部分をハイブリッドモデルの中にC言語などのプログラム言語で付加処理として記述でき、その機能が自動的にシミュレーションの実行に組み込まれる。   On the other hand, the embodiment of the present invention is configured to construct the hybrid model simulation execution unit 102 according to the series of processing shown in FIG. That is, a software part corresponding to communication with the outside (process) such as a mechanism control software simulator can be described as an additional process in a program language such as C language in the hybrid model, and the function automatically executes the simulation. Incorporated into.

本発明の実施形態によれば、複雑なシミュレーションの手順を柔軟にモデル化およびプログラミングすることが可能になる。具体的には、本実施形態は外部との連携などに関わる付加処理の記述をハイブリッドモデル記述の一部に含めることを可能にする。したがって、高度で多様なシミュレーションモデルを簡単に構築可能になることから、シミュレーションの適用範囲を拡大することができる。   According to the embodiments of the present invention, it is possible to flexibly model and program a complicated simulation procedure. Specifically, the present embodiment makes it possible to include a description of additional processing related to cooperation with the outside as part of the hybrid model description. Therefore, it is possible to easily construct a variety of advanced simulation models, so that the application range of simulation can be expanded.

(第2実施形態)
本発明の第2実施形態は機構制御ソフトウェアもしくは機構制御ソフトウェアのシミュレータとの連携に係わる。図9は本発明の第2実施形態に係る機構シミュレータの概略構成を示すブロック図である。本実施形態の機構シミュレータは、第1実施形態と同様に、ハイブリッドモデル前処理部201と、ハイブリッドモデルシミュレーション実行部102とにより構成されている。同図に示す制御信号106は機構制御ソフトウェアもしくは機構制御ソフトウェアのシミュレータとハイブリッドモデルシミュレーション実行部102の付加処理実行部205との間でポートを介して入出力される。
(Second Embodiment)
The second embodiment of the present invention relates to cooperation with mechanism control software or a simulator of mechanism control software. FIG. 9 is a block diagram showing a schematic configuration of a mechanism simulator according to the second embodiment of the present invention. Similar to the first embodiment, the mechanism simulator of the present embodiment includes a hybrid model preprocessing unit 201 and a hybrid model simulation execution unit 102. The control signal 106 shown in the figure is input / output between the mechanism control software or the simulator of the mechanism control software and the additional process execution unit 205 of the hybrid model simulation execution unit 102 via a port.

本実施形態においては、制御信号106の入出力を付加処理とし、その記述をハイブリッドモデル記述2104に含めることが可能である。   In this embodiment, the input / output of the control signal 106 can be an additional process, and the description can be included in the hybrid model description 2104.

図10は、第2実施形態におけるハイブリッドモデル記述2104の内容の一例を示す図である。outport関数は外部の制御系に対し、そのいずれかのポートIDにデータを書き込むためのAPI関数である。inport関数はポートIDからデータを読み込むAPI関数である。ここでは、外部の制御系は機構制御ソフトウェアもしくは機構制御ソフトウェアのシミュレータに相当する。   FIG. 10 is a diagram showing an example of the contents of the hybrid model description 2104 in the second embodiment. The outport function is an API function for writing data to one of the port IDs for an external control system. The inport function is an API function that reads data from a port ID. Here, the external control system corresponds to mechanism control software or a simulator of mechanism control software.

11行目から18行目はC言語で記述されている。setDataToCtrlは引数num,dataをoutport関数にセットする関数である。GetDataFromCtrl関数は引数num番目のIDをinport関数にセットし、取得したデータを戻り値として返す関数である。   The 11th to 18th lines are described in C language. setDataToCtrl is a function that sets the arguments num and data to the outport function. The GetDataFromCtrl function is a function that sets the ID of the argument num-th in the import function and returns the acquired data as a return value.

23,26行目ではsetDataToCtrl関数とgetDataFromCtrl関数がそれぞれイベントE1,E2に関連付けられている。イベントE1が発生したときにsetDataToCtrl関数が実行され、イベントE2が発生したとき、getDataFromCtrl関数が実行される。   In the 23rd and 26th lines, the setDataToCtrl function and the getDataFromCtrl function are associated with the events E1 and E2, respectively. The setDataToCtrl function is executed when the event E1 occurs, and the getDataFromCtrl function is executed when the event E2 occurs.

24行目では、制御ID番号1に対してデータxが整数型に型変換され、セットされる。27行目では、データxに、制御信号106から取得されたデータを強制的に設定している。   On the 24th line, data x is converted into an integer type for control ID number 1 and set. On the 27th line, the data acquired from the control signal 106 is forcibly set in the data x.

以上のようにこのハイブリッドシミュレーションでは、シミュレーション中に外部の制御対象と連携をとるための記述を同一のソース上に簡便に記述することができる。当然ながら、制御対象の状態に応じてシミュレーション結果は異なるものとなる。   As described above, in this hybrid simulation, it is possible to simply describe a description for linking with an external control target on the same source during the simulation. Naturally, the simulation result differs depending on the state of the controlled object.

図11は本発明の第2実施形態に係わる機構シミュレータの動作を示すフローチャートである。イベントが発生したら、その種類を特定し、イベントの種類に応じて処理を振り分ける点では第1実施形態と同様である。本実施形態はハイブリッドモデルにおける状態遷移のみならず、外部制御対象とのインターフェースに係わる処理についてもイベントを通じて統一的に制御する点で第1実施形態と異なっており、これにより外部制御系(例えば機構制御ソフトウェア等)との連携シミュレーションに係わる構成が簡潔になるという利点がある。   FIG. 11 is a flowchart showing the operation of the mechanism simulator according to the second embodiment of the present invention. When an event occurs, it is the same as in the first embodiment in that the type is specified and the processing is distributed according to the type of event. This embodiment is different from the first embodiment in that not only the state transition in the hybrid model but also the processing related to the interface with the external control target is controlled uniformly through the event. There is an advantage that the configuration related to the cooperative simulation with the control software is simplified.

まず、図11に示すように、ハイブリッドモデル記述2104が制御情報解析部110に入力され、ハイブリッドモデルの構文解析が行われる(ステップS1)。制御情報解析部110はモデル方程式登録プログラム202、イベント制御プログラム203、及びシミュレーション実行時付加処理プログラム204をそれぞれ生成する。モデル方程式登録プログラム202に基づく方程式構文解析部112により、連続系方程式の記述データはシミュレーション実行可能なデータ構造に変換されると共に、方程式データ記憶部114に登録される(ステップS2)。   First, as shown in FIG. 11, the hybrid model description 2104 is input to the control information analysis unit 110, and the syntactic analysis of the hybrid model is performed (step S1). The control information analysis unit 110 generates a model equation registration program 202, an event control program 203, and a simulation execution additional processing program 204, respectively. The equation syntax analysis unit 112 based on the model equation registration program 202 converts the description data of the continuous system equations into a data structure that can be simulated and registered in the equation data storage unit 114 (step S2).

以上でシミュレーション実行のための前処理を終え、ここからシミュレーション実行の段階に移る。   Thus, the pre-processing for the simulation execution is completed, and the simulation execution stage is started from here.

ステップS4において、イベントが発生したかどうかを検知する。イベントが発生したならば、制御はステップS5に進む。イベントが発生していない場合はステップS6に進む。   In step S4, it is detected whether an event has occurred. If an event has occurred, control proceeds to step S5. If no event has occurred, the process proceeds to step S6.

ステップS5において、発生したイベントの種類を判定する。イベントの種類が連続系方程式に関係するイベントであるならば、ステップS9において、状態遷移に伴う連続系方程式の切り替えが必要であるか否かを判定する。方程式の切り替えが必要であるならば、ステップS10において、有効無効フラグを操作することにより、アクティブな連続方程式の切り替えを行う。方程式の切り替えは不要である場合、制御はステップS6に進む。   In step S5, the type of event that has occurred is determined. If the event type is an event related to the continuous system equation, it is determined in step S9 whether or not switching of the continuous system equation accompanying the state transition is necessary. If it is necessary to switch equations, in step S10, the active continuous equation is switched by manipulating the valid / invalid flag. If switching of equations is not necessary, control proceeds to step S6.

発生したイベントの種類がデータ送信に関係するイベントであるならば、ステップS11において外部制御対象にデータを送信する。この送信データは、対象とする機構に装着されたセンサーのステータス情報等が想定される。また、発生したイベントの種類がデータ受信に関係するイベントであるならば、ステップS12において外部制御対象からデータを受信する。   If the type of event that has occurred is an event related to data transmission, data is transmitted to the external control target in step S11. The transmission data is assumed to be status information of a sensor attached to the target mechanism. If the type of event that occurred is an event related to data reception, data is received from the external control target in step S12.

ステップS6において、連続系シミュレーション部103は数値積分を実行する。   In step S6, the continuous system simulation unit 103 performs numerical integration.

次に、ステップS7において終了条件の判定をする。ここでは、時間が所定のシミュレーション終了時間に到達したかどうかを判定する。シミュレーション終了時間に到達したらシミュレーション実行を終了する。それまではステップS8にて時間を1ステップ進めてステップS4に戻り、同様の処理手順を繰り返す。   Next, the end condition is determined in step S7. Here, it is determined whether or not the time has reached a predetermined simulation end time. When the simulation end time is reached, the simulation execution is terminated. Until then, the time is advanced by one step in step S8, the process returns to step S4, and the same processing procedure is repeated.

なお、本発明は上記実施形態そのままに限定されるものではなく、実施段階ではその要旨を逸脱しない範囲で構成要素を変形して具体化できる。また、上記実施形態に開示されている複数の構成要素の適宜な組み合わせにより、種々の発明を形成できる。例えば、実施形態に示される全構成要素から幾つかの構成要素を削除してもよい。さらに、異なる実施形態にわたる構成要素を適宜組み合わせてもよい。   Note that the present invention is not limited to the above-described embodiment as it is, and can be embodied by modifying the constituent elements without departing from the scope of the invention in the implementation stage. In addition, various inventions can be formed by appropriately combining a plurality of constituent elements disclosed in the embodiment. For example, some components may be deleted from all the components shown in the embodiment. Furthermore, constituent elements over different embodiments may be appropriately combined.

本発明の第1実施形態に係る機構シミュレータの概略構成を示すブロック図。The block diagram which shows schematic structure of the mechanism simulator which concerns on 1st Embodiment of this invention. ハイブリッドモデル記述を説明するための具体例に係るシリンダ装置のある状態を示す図。The figure which shows the state with the cylinder apparatus which concerns on the specific example for demonstrating a hybrid model description. ハイブリッドモデル記述を説明するための具体例に係るシリンダ装置の別の状態を示す図。The figure which shows another state of the cylinder apparatus which concerns on the specific example for demonstrating a hybrid model description. ハイブリッドモデル記述を説明するための具体例に係るシリンダ装置の状態遷移を示す図。The figure which shows the state transition of the cylinder apparatus which concerns on the specific example for demonstrating a hybrid model description. ハイブリッドモデル記述の内容を示す図。The figure which shows the content of a hybrid model description. 1つの連続系方程式を構文解析した結果得られる内部データ表現の説明図。Explanatory drawing of internal data expression obtained as a result of parsing one continuous system equation. 本発明の第1実施形態に係る機構シミュレーションの処理手順を示すフローチャート。The flowchart which shows the process sequence of the mechanism simulation which concerns on 1st Embodiment of this invention. 機構シミュレーションの時系列的な流れの説明図。Explanatory drawing of the time-sequential flow of mechanism simulation. 本発明の第2実施形態に係る機構シミュレータの概略構成を示すブロック図。The block diagram which shows schematic structure of the mechanism simulator which concerns on 2nd Embodiment of this invention. 本発明の第2実施形態に係るハイブリッドモデル記述の内容を示す図。The figure which shows the content of the hybrid model description which concerns on 2nd Embodiment of this invention. 機構シミュレーションの処理手順を示すフローチャート。The flowchart which shows the process sequence of a mechanism simulation.

符号の説明Explanation of symbols

104…ハイブリッドモデル記述、201…ハイブリッドモデル前処理部、110…制御情報解析部、102…ハイブリッドモデルシミュレーション実行部、103…連続系シミュレーション部、111…イベント処理部、112…方程式構文解析部、115…連続系方程式切り替え部、205…付加処理実行部、105…変数値時間履歴記憶部 DESCRIPTION OF SYMBOLS 104 ... Hybrid model description 201 ... Hybrid model pre-processing part 110 ... Control information analysis part 102 ... Hybrid model simulation execution part 103 ... Continuous system simulation part 111 ... Event processing part 112 ... Equation syntax analysis part 115 ... continuous system equation switching unit, 205 ... addition processing execution unit, 105 ... variable value time history storage unit

Claims (2)

第1及び第2のイベントの生起、該第1のイベントの生起に伴い有効又は無効とされる連続系方程式、及び該第2のイベントの生起に伴う付加処理のそれぞれを含むハイブリッドモデルのソースプログラムに基づいて、対象とする機構の挙動を時間軸に沿ってシミュレーションするシミュレーション装置であって、
連続系方程式の内部データ表現を方程式データ記憶部に登録するための関数を呼び出すモデル方程式登録プログラムを、前記ハイブリッドモデルのソースプログラムにおける連続系方程式のソースプログラム記述に基づいて生成する第1生成手段と、
前記第1のイベント又は前記第2のイベントが生起したか否かを判定し、前記第1のイベントの生起に伴い前記方程式データ記憶部に登録されている特定の連続系方程式の有効・無効を切り替える関数を呼び出し、前記第2のイベントの生起に伴い前記付加処理を呼び出すイベント制御プログラムを、前記ハイブリッドモデルのソースプログラムにおける第1及び第2のイベントに関するソースプログラム記述に基づいて生成する第2生成手段と、
前記イベント制御プログラムから呼び出し可能な付加処理プログラムを、前記ハイブリッドモデルのソースプログラムにおける付加処理のソースプログラム記述に基づいて生成する第3生成手段と、
シミュレーション開始時に、前記第1生成手段により生成されたモデル方程式登録プログラムを読み出して実行する方程式構文解析部と、
前記第2生成手段により生成されたイベント制御プログラムを読み出し、シミュレーションステップ毎に該イベント制御プログラムを実行するイベント制御部と、
前記イベント制御プログラムから呼び出され、前記第1のイベントの生起に伴い前記特定の連続的方程式の有効・無効を切り替える連続系方程式切り替え部と、
前記連続系方程式切り替え部により有効なものに切り替えられた連続系方程式の内部データ表現を用いて時間軸に沿った数値積分により該連続系方程式を解いて、前記機構の挙動を表すデータを出力するシミュレーションを実行するシミュレーション実行と、
前記第3生成手段により生成された付加処理プログラムを読み出し、前記イベント制御プログラムにおいて前記付加処理が呼び出されたならば該付加処理プログラムを実行する付加処理実行部とを具備するハイブリッドシミュレーション装置。
A hybrid model source program that includes the occurrence of first and second events, a continuous system equation that is enabled or disabled as a result of the occurrence of the first event, and additional processing that accompanies the occurrence of the second event. Is a simulation device for simulating the behavior of the target mechanism along the time axis,
A first generating means for generating a model equation registration program for calling a function for registering an internal data representation of a continuous system equation in an equation data storage unit based on a source program description of the continuous system equation in the hybrid model source program; ,
It is determined whether or not the first event or the second event has occurred, and the validity / invalidity of a specific continuous system equation registered in the equation data storage unit with the occurrence of the first event is determined. call the switch function, the second event the additional processing calls the event control program with the occurrence of the produce on the basis of the first and source program descriptions of the second event in the source program of the hybrid model Two generation means;
A third generation means for generating an additional processing program that can be called from the event control program based on a source program description of the additional processing in the source program of the hybrid model ;
An equation syntax analysis unit that reads and executes the model equation registration program generated by the first generation unit at the start of simulation;
An event control unit that reads the event control program generated by the second generation unit and executes the event control program for each simulation step;
A continuous equation switching unit that is called from the event control program and switches between valid / invalid of the specific continuous equation with the occurrence of the first event ;
Using the internal data representation of the continuous system equation switched to an effective one by the continuous system equation switching unit , solve the continuous system equation by numerical integration along the time axis and output data representing the behavior of the mechanism A simulation execution unit for executing a simulation;
The third read additional processing program generated by the generating means, the additional processing hybrid simulation apparatus comprising the additional processing execution unit for executing the Save if the additional program is invoked in the event control program.
前記付加処理プログラムは、前記機構を制御する機構制御ソフトウェアを含む外部との間で入出力ポートを介して制御信号を入出力するための処理を含むことを特徴とする請求項1に記載のシミュレーション装置。 The simulation according to claim 1, wherein the additional processing program includes processing for inputting / outputting a control signal to / from an outside including mechanism control software for controlling the mechanism via an input / output port. apparatus.
JP2003416847A 2002-12-26 2003-12-15 Simulation device Expired - Lifetime JP4564255B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003416847A JP4564255B2 (en) 2002-12-26 2003-12-15 Simulation device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
JP2002376210 2002-12-26
JP2003416847A JP4564255B2 (en) 2002-12-26 2003-12-15 Simulation device

Publications (2)

Publication Number Publication Date
JP2004220577A JP2004220577A (en) 2004-08-05
JP4564255B2 true JP4564255B2 (en) 2010-10-20

Family

ID=32911114

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003416847A Expired - Lifetime JP4564255B2 (en) 2002-12-26 2003-12-15 Simulation device

Country Status (1)

Country Link
JP (1) JP4564255B2 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008243042A (en) * 2007-03-28 2008-10-09 Toshiba Corp Simulation device, method, and program for hybrid model
CN102004632A (en) * 2009-09-01 2011-04-06 阿里巴巴集团控股有限公司 Method and device for setting time information
JP5208891B2 (en) * 2009-09-07 2013-06-12 株式会社東芝 Hybrid model simulation apparatus and method
WO2011036768A1 (en) * 2009-09-25 2011-03-31 株式会社 東芝 Simulation device
CN102667781B (en) * 2010-10-06 2014-11-26 艺术系统软件有限责任公司 Method and process computer for calculating the state variables of a hybrid differential-algebraic process model
WO2012045321A1 (en) * 2010-10-06 2012-04-12 Art Systems Software Gmbh Method for calculating the state variables of a hybrid differential-algebraic process model in real time
EP3792810A1 (en) 2019-09-12 2021-03-17 Kompetenzzentrum - Das virtuelle Fahrzeug Forschungsgesellschaft mbH Method of generating an operation procedure for a simulation of a mechatronic system

Also Published As

Publication number Publication date
JP2004220577A (en) 2004-08-05

Similar Documents

Publication Publication Date Title
EP3745256B1 (en) External code integrations within a computing environment
Rouson et al. Scientific software design: the object-oriented way
JP3940665B2 (en) Hybrid simulation apparatus and program
EP1307828A1 (en) Xml-robot
US8046202B1 (en) Generation of intermediate representations based on user specified elements in a graphical model that enable simulation, propagation and code generation
Feldman et al. Simulating rhapsody SysML blocks in hybrid models with FMI
Denil et al. Explicit semantic adaptation of hybrid formalisms for FMI co-simulation
CN100498817C (en) Simulation method
JP2004220566A (en) Mechanism simulation method and mechanism simulation program
Anureev et al. Two-step deductive verification of control software using Reflex
Giorgidze et al. Mixed-level embedding and JIT compilation for an iteratively staged DSL
JP4564255B2 (en) Simulation device
US20220019414A1 (en) Method for merging architecture data
CN104778323B (en) The complex equipment work flow emulation mode of integrated multi-source performance analysis data
US20210096830A1 (en) Incremental code generation method
US9841954B1 (en) Method and system for automatic code generation
Hansen et al. Co-simulation at different levels of expertise with Maestro2
Denckla et al. Stream-and state-based semantics of hierarchy in block diagrams
Lu et al. Simulation and visualization tool design for robot software
Oda et al. Specifying abstract user interface in VDM-SL
Anureev et al. Dedicative verification of Reflex programs
Cleaveland Programming is modeling
Bjarnason Interactive Tool Support for Domain-Specific Languages
JP2008243042A (en) Simulation device, method, and program for hybrid model
WO2011036768A1 (en) Simulation device

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20050209

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20070821

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20071022

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20071113

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20080115

A911 Transfer to examiner for re-examination before appeal (zenchi)

Free format text: JAPANESE INTERMEDIATE CODE: A911

Effective date: 20080226

A912 Re-examination (zenchi) completed and case transferred to appeal board

Free format text: JAPANESE INTERMEDIATE CODE: A912

Effective date: 20080328

A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20100730

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130806

Year of fee payment: 3

R151 Written notification of patent or utility model registration

Ref document number: 4564255

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151

FPAY Renewal fee payment (event date is renewal date of database)

Free format text: PAYMENT UNTIL: 20130806

Year of fee payment: 3

S111 Request for change of ownership or part of ownership

Free format text: JAPANESE INTERMEDIATE CODE: R313113

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

R250 Receipt of annual fees

Free format text: JAPANESE INTERMEDIATE CODE: R250

EXPY Cancellation because of completion of term