API を使用して RoadRunner シミュレーションから​アクター軌跡をエクス​ポートするにはどうす​ればよいですか。

RoadRunner API を使用して、RoadRunner シナリオ内の Sedan アクターの軌跡をエクスポートしたいと考えています。以下のワークフローを使用しました。
rrApp = roadrunner(projectFolder);
rrApi = roadrunnerAPI(rrApp);
openScene(rrApp, sceneFile);
openScenario(rrApp, scenarioFile);
rrSim = createSimulation(rrApp);
set(rrSim、「MaxSimulationTime」、10);
set(rrSim、「SimulationCommand」、「Start);
(15)
exportActorTrajectoryToCSV(rrApp, 'FolderPath', outputFolderPath, 'FolderName', outputFolderName);
シミュレーション自体は実行されますが、エクスポート時に次のエラーが発生します。
Unable to export CSV file. Set the value of 'enable_runtime_log' field of the 'SimulateScenario' method to 'true' to enable simulation logging.
また、"simulateScenario(rrApp,'EnableLogging',true)" によってロギングを有効にすることも試しましたが、"set" コマンドで指定した "MaxSimulationTime" を無効にしてしまいます。

 Respuesta aceptada

MathWorks Support Team
MathWorks Support Team hace alrededor de 6 horas

0 votos

"exportActorTrajectoryToCSV"を使用するには、シミュレーション開始前にシミュレーションロギングを有効にしておく必要があります。ロギングが有効になっていない場合、エクスポートコマンドは実行時の軌跡データにアクセスできません。ただし、"simulateScenario"による有効化はこのワークフローには適していません。
この目的には、実用的な方法が 3 つあります。
1. シミュレーションロギング後に組み込みの CSV エクスポートを使う方法
"createSimulation"を使用し、明示的にロギングを有効にしてからシミュレーションを実行し、終了を待って"exportActorTrajectoryToCSV"を呼び出します。組み込みのエクスポート機能で軌跡データを CSV に出力したい場合には、これが最も直接的な方法です。
rrApp = roadrunner(projectfolder);
openScenario(rrApp, "TrajectoryCutIn");
rrSim = createSimulation(rrApp);
set(rrSim, "Logging", "On");
set(rrSim, "SimulationCommand", "Start");
while strcmp(get(rrSim,"SimulationStatus"),"Running")
pause(1);
end
exportActorTrajectoryToCSV(rrApp);
2. SimulationLog から時刻付き軌跡を独自にエクスポートする方法
より細かい制御が必要な場合は、ロギングを有効にしてシミュレーションを実行し、"SimulationLog"を取得して、姿勢データと時刻データを取り出し、CSV を手動で書き出します。この方法は、経路情報とタイムスタンプの両方を独自形式で出力したい場合に有効です。
rrApp = roadrunner(projectfolder);
openScenario(rrApp, "TrajectoryCutIn");
rrSim = createSimulation(rrApp);
set(rrSim, "Logging", "On");
set(rrSim, "SimulationCommand", "Start");
while strcmp(get(rrSim,"SimulationStatus"),"Running")
pause(1);
end
rrLog = get(rrSim, "SimulationLog");
t = [poseTimeSeries.Time].';
P = reshape([poseTimeSeries.Pose], 4, 4, []);
xyz = squeeze(P(1:3, 4, :)).';
T = table(t, xyz(:,1), xyz(:,2), xyz(:,3), ...
'VariableNames', {'Time','X','Y','Z'});
writetable(T, 'actor1_pose.csv');
3. roadrunnerAPI で静的なルート点を取得する方法
アクターの経路だけが必要で、シミュレーション時刻が不要な場合は、roadrunnerAPI を使用してシナリオからアクターのルートを直接読み取ります。この方法ではシミュレーションを実行する必要はありません。
rrApp = roadrunner(projectfolder);
openScenario(rrApp, "TrajectoryCutIn");
rrApi = roadrunnerAPI(rrApp);
actor1 = rrApi.Scenario.Actors(1);
xyz = actor1.InitialPoint.Route.PositionSamples;
T = array2table(xyz, 'VariableNames', {'X','Y','Z'});
writetable(T, 'points.csv')

Más respuestas (0)

Preguntada:

el 1 de Sept. de 2026 a las 0:00

Respondida:

el 1 de Sept. de 2026 a las 1:08

Community Treasure Hunt

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

Start Hunting!