상담문의

[Prescan] Prescan에서 DMAPI를 활용한, Open scenario import 방법

2025-09-16

 


 이번 게시글에서는 DMAPI를 활용하여 Open scenario import하는 방법을 소개하겠습니다.


1. Prescan GUI에서 새로운 Experiment를 생성합니다. 그리고 build를 실행하고 저장합니다.



2. Prescan Process Manager를 통해 Matlab을 실행하고, 1에서 만든 experiment 경로로 이동합니다.



3. Matlab에서 새 스크립트를 생성하고 experiment 폴더에 저장합니다.



4. 스크립트 내부에서 시나리오 모델링을 시작할 수 있습니다. 사용자는 doc prescan.api 명령어를 사용하여 DMAPI와 모듈에 액세스할 수 있습니다



 아래는 참고용 예제 스크립트 내용입니다.

exp = prescan.api.experiment.Experiment();

 

%% Create a road

road_1 = prescan.api.roads.createRoad(exp);

 

%% Add sections to the road

sectionLength = 250; % [m]

road_1.addStraightSection(sectionLength);

sectionLength = 50;

startCurvature = 0.025;

endCurvature = 0.1;

road_1.addSpiralSection(sectionLength, startCurvature, endCurvature);

%% Once the sections have been added, add lanes to the road

lane1 = road_1.addLeftLane(3.2);

marker = lane1.getLaneMarker('Outer');

marker.setType('Broken');

lane2 = road_1.addLeftLane(3.2);

marker = lane2.getLaneMarker('Outer');

marker.setType('Solid');

lane3 = road_1.addRightLane(3.2);

marker = lane3.getLaneMarker('Outer');

marker.setType('Broken');

lane4 = road_1.addRightLane(3.2);

marker = lane4.getLaneMarker('Outer');

marker.setType('Solid');

 

centerOfLane1 = lane3.poseAtDistance(0.0).position.y;

centerOfLane2 = lane4.poseAtDistance(0.0).position.y;

edgeOfRoadLeft = lane2.poseAtDistance(0.0, 'Outer', 10.0).position.y;

edgeOfRoadRight = lane4.poseAtDistance(0.0, 'Outer', 10.0).position.y;

%% Add objects to the road

vehicleAudi = exp.createObject(exp.objectTypes.Audi_A8_Sedan);

vehicleAudi.name = 'Ego';

 

% Trees

for i = 0:35

    r = -3 + (3+3).*rand(3,1); % Make it random

    xtree = 6 * i + r(1);

    ytree1 = edgeOfRoadLeft + r(2);

    ytree2 = edgeOfRoadRight + r(3);

   

    tree = exp.createObject(exp.objectTypes.Dogwood20y);

    tree.pose.position.x = xtree;

    tree.pose.position.y = ytree1;

   

    tree = exp.createObject(exp.objectTypes.Dogwood20y);

    tree.pose.position.x = xtree;

    tree.pose.position.y = ytree2;

end

 

%% Position the vehicles correctly

vehicleAudi.pose.position.y = centerOfLane2;

 

%% Add a trajectory to the ego vehicle

z = [0, 0];

y = [vehicleAudi.pose.position.y, vehicleAudi.pose.position.y];

x = [vehicleAudi.pose.position.x, 200];

pathAudi = prescan.api.trajectory.createFittedPath(exp, x, y, z);

speedProf = prescan.api.trajectory.createSpeedProfileOfConstantSpeed(exp, 5);

 

trajectoryAudi = prescan.api.trajectory.createTrajectory(vehicleAudi, pathAudi, speedProf);

%% Add a camera to the ego vehicle

cameraAudi = prescan.api.camera.createCameraSensor(vehicleAudi);

 

%% Save the experiment to a file

exp.saveToFile('DMAPI.pb');

 

%% Generate the CS

prescan.api.simulink.generate();

 

%% Run the experiment

prescan.api.simulink.run(exp, 'Regenerate', 'off', 'StopTime', '5')


5. experiment 환경의 변경 사항이 완료되면, 파일을 저장하고 스크립트를 실행합니다.



6. 파일을 Prescan Viewer에 로드하고 API를 사용하여 구축된 experiment를 확인합니다.




댓글 없음

댓글 쓰기

이런자료는 어때요?
캐디언스 시스템
(주) 캐디언스시스템

서울본사 : 서울시 금천구 가산디지털 1로 212, 코오롱디지털타워애스턴 1006호