どのような処理を行っ​ているのか分からない​ので、教えていただき​たいです。

5 visualizaciones (últimos 30 días)
NAGATA SOICHIRO
NAGATA SOICHIRO el 1 de Dic. de 2021
Comentada: Atsushi Ueno el 2 de Dic. de 2021
以下のURLのマルチステージの非線形モデル予測制御のコードを読んでいて分からない部分があるので、教えていただきたいです。
理解することができなかったコードは以下の部分です。
file_path = [char(proj.RootFolder), filesep, 'gen_script', filesep, 'calc_Ac.m'];
matlabFunction(Ac, 'File', file_path);
file_path = [char(proj.RootFolder), filesep, 'gen_script', filesep, 'calc_Bc.m'];
matlabFunction(Bc, 'File', file_path);
start_pos = [-1.0, 0.0, -pi];
goal_pos = [14, -2.25, 0];
pthObj = plan_MobileRobotPaths_using_RRT(Ts, path_Tf, start_pos, goal_pos);

Respuesta aceptada

Atsushi Ueno
Atsushi Ueno el 1 de Dic. de 2021
上記"Nonlinear MPC Controller"(multi stageじゃない方)には、目的について詳細な説明もありました。
file_path = [char(proj.RootFolder), filesep, 'gen_script', filesep, 'calc_Ac.m'];
matlabFunction(Ac, 'File', file_path);
file_path = [char(proj.RootFolder), filesep, 'gen_script', filesep, 'calc_Bc.m'];
matlabFunction(Bc, 'File', file_path);
目的は「車両のモデル化:ヨー角ベースの状態方程式をクオータニオンに置き換えながら、状態空間モデルをSymbolic Math Toolbox™で定式化⇒それをmファイルに保存する」事で、Ac,BcはMPC制御に必要な状態方程式(ヤコビアンモデル)の形との事です。
上記のmatlabFunction関数の実行により'mpc_implementation_example/MPC_imple_PJ/gen_script/calc_Ac.m'等のファイルが出力されます。matlabFunction関数はシンボリック式をmファイルに変換しています。下記に入力の二乗を返す入力例と出力ファイルを示します。システムモデルがこれらの関数(車両の動特性)を取り込むのだと想定します。
syms x
matlabFunction(x^2,'File','myfile');
type myfile.m
function out1 = myfile(x) %MYFILE % OUT1 = MYFILE(X) % This function was generated by the Symbolic Math Toolbox version 9.0. % 01-Dec-2021 13:12:53 out1 = x.^2;
start_pos = [-1.0, 0.0, -pi];
goal_pos = [14, -2.25, 0];
pthObj = plan_MobileRobotPaths_using_RRT(Ts, path_Tf, start_pos, goal_pos);
上記は同じmpc_implementation_example/MPC_imple_PJ/Nonlinear/フォルダにあるplan_MobileRobotPaths_using_RRT.mを実行しています。その中ではplan関数が実行されており、入力されたplannerRRTオブジェクト及びスタート・ゴール位置から最適なパスプランの導出及び表示を行っています。
  2 comentarios
NAGATA SOICHIRO
NAGATA SOICHIRO el 2 de Dic. de 2021
理解することができました。丁寧に説明していただきありがとうございます。
Atsushi Ueno
Atsushi Ueno el 2 de Dic. de 2021
回答に追記致します。
開始時に実行するスクリプトstart_pj_script.mの中で、proj = currentProjectと設定し、後にproj.RootFolderでプロジェクトのルートフォルダパスを取得しています。currentProject関数は現在のプロジェクト情報を取得します。
試しにexampleプロジェクトを開いて、そのプロジェクト情報を取得してみます。
matlab.project.example.timesTable
proj = currentProject
proj =
Project with properties: RootFolder: "/users/mss.system.vN2Epb/Projects/examples/TimesTableApp" Name: "Times Table App" Description: "This example project contains the source code and tests for a simple educational app. ↵↵Use the "Project Shortcuts" toolstrip tab to find ways of getting started with this project." SourceControlIntegration: "Git" TopLevel: 1 ReadOnly: 0 Files: [1×15 matlab.internal.project.api.ProjectFile] StartupFiles: [1×0 string] ShutdownFiles: [1×0 string] ProjectPath: [1×3 matlab.internal.project.api.PathFolder] ProjectReferences: [1×0 matlab.internal.project.api.ProjectReference] Shortcuts: [1×4 matlab.internal.project.api.Shortcut] Categories: [1×1 matlab.internal.project.api.Category] Dependencies: [1×1 digraph] ProjectStartupFolder: "/users/mss.system.vN2Epb/Projects/examples/TimesTableApp" SimulinkCacheFolder: "" SimulinkCodeGenFolder: ""
上記のプロジェクト情報からプロジェクトのルートフォルダを抽出し、保存したいフォルダおよびファイル名を連結します。filesepはOS間で異なるファイル区切り文字を得る為の関数です。String型を文字ベクトルに変換するのは他の文字ベクトルと連結する為です。(String型でも連結はできます)
因みに表示されたルートフォルダパスはこのスクリプトを実行しているサーバのものです
file_path = [char(proj.RootFolder), filesep, 'gen_script', filesep, 'calc_Ac.m']
file_path = '/users/mss.system.vN2Epb/Projects/examples/TimesTableApp/gen_script/calc_Ac.m'

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre デバッグと解析 en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!