How to convert matlab plot figure into stl file ? Further I Want to use it for my uav scenario .
15 次查看(过去 30 天)
显示 更早的评论
I created a scenario for uav trajectory testing but now i am unable to import the scenario file to my UAV scenario designer .
Here is the code for reference :
scene = uavScenario("UpdateRate", 200 , "StopTime", 2, "ReferenceLocation",[46,42,0]);
>> scene.addInertialFrame("ENU", "MAP", trvec2tform([1 0 0]));
>> scene.addMesh("Polygon",{[-100 0; 100 0; 100 100; -100 100],[-5 0]},[0.3 0.3 0.3]);
>> scene.addMesh("Cylinder",{[20 10 10],[0 30]},[0 1 0]);
>> scene.addMesh("Cylinder",{[46 42 5],[0 20]},[0 1 0],"UseLatLon" , true);
>> traj = waypointTrajectory("Waypoints", [0 -20 -5; 20 -20 -5; 20 0 -5],"TimeOfArrival",[0 1 2]);
>> uavPlat = uavPlatform("UAV",scene,"Trajectory",traj);
>> updateMesh(uavPlat,"quadrotor", {4}, [1 0 0],eul2tform([0 0 pi]));
>> addGeoFence(uavPlat,"Polygon", {[-50 0; 50 0; 50 50; -50 50],[0 100]},true,"ReferenceFrame","ENU");
>> insModel = insSensor();
>> ins = uavSensor("INS",uavPlat,insModel,"MountingLocation",[4 0 0]);
>> ax = show3D(scene);
>> axis(ax,"equal");
>> setup(scene);
>> while advance(scene)
% Update sensor readings
updateSensors(scene);
% Visualize the scenario
show3D(scene,"Parent",ax,"FastUpdate",true);
drawnow limitrate
end
>> addCustomTerrain("CustomTerrain","n39_w106_3arc_v2.dt1");
>> scenario = uavScenario("ReferenceLocation", [39.5 -105.5 0]);
>> addMesh(scenario,"terrain", {"CustomTerrain", [-200 200], [-200 200]}, [0.6 0.6 0.6]);
>> show3D(scenario);
>> buildingCenters = [-50, -50; 100 100];
>> buildingHeights = [30 100];
>> buildingBoundary = [-25 -25; -25 50; 50 50; 50 -25];
>> for idx = 1:size(buildingCenters,1)
buildingVertices = buildingBoundary+buildingCenters(idx,:);
buildingBase = min(terrainHeight(scenario,buildingVertices(:,1),buildingVertices(:,2)));
addMesh(scenario,"polygon", {buildingVertices, buildingBase+[0 buildingHeights(idx)]}, [0.3922 0.8314 0.0745]);
end
>>
show3D(scenario);
>> view([0 ,15])
>> removeCustomTerrain("CustomTerrain")
0 个评论
回答(1 个)
Nadia Shaik
2022-11-22
Hi Karnvir,
I understand that you want to convert mesh data to 'STL' file. To achieve this, you can download some STL file conversion tools from File Exchange:
For example:
etc.
I hope this helps.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!