Skip to content

Commit

Permalink
updated matlab doc for new toolbox update
Browse files Browse the repository at this point in the history
  • Loading branch information
WouterJansen committed Oct 2, 2024
1 parent 7a46969 commit 08f6120
Showing 1 changed file with 30 additions and 46 deletions.
76 changes: 30 additions & 46 deletions docs/matlab.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ When starting with this wrapper, first try to make a connection to the Cosys\-Ai

```matlab
vehicle_name = "airsimvehicle";
airSimClient = AirSimClient(IsDrone=false, ApiControl=false, IP="127.0.0.1", port=41451, vehicleName=vehicle_name);
airSimClient = AirSimClient(IsDrone=false, IP="127.0.0.1", port=41451);
```

Now the client object can be used to run API methods from. All functions have some help text written for more information on them.
Expand Down Expand Up @@ -57,7 +57,7 @@ Do note the test script requires next to the toolboxes listed above in the Prere
%Define client
vehicle_name = "airsimvehicle";
airSimClient = AirSimClient(IsDrone=false, ApiControl=false, IP="127.0.0.1", port=41451, vehicleName=vehicle_name);
airSimClient = AirSimClient(IsDrone=false, ApiControl=false, IP="127.0.0.1", port=41451);
```
### Groundtruth labels
Expand All @@ -77,23 +77,15 @@ groundtruthLUT = airSimClient.getInstanceSegmentationLUT();
poses = airSimClient.getAllObjectPoses(false, false);
% Get vehicle pose
vehiclePoseLocal = airSimClient.getVehiclePose();
vehiclePoseLocal = airSimClient.getVehiclePose(vehicle_name);
vehiclePoseWorld = airSimClient.getObjectPose(vehicle_name, false);
% Get an random object pose or choose if you know the name of one
useChosenObject = false;
% Choose the object to get the pose from (this one is in the Blocks env)
chosenObject = "Cylinder3";
if useChosenObject
finalName = chosenObject;
else
randomIndex = randi(size(groundtruthLUT, 1), 1);
randomName = groundtruthLUT.name(randomIndex);
finalName = randomName;
end
objectPoseLocal = airSimClient.getObjectPose(finalName, true);
objectPoseWorld = airSimClient.getObjectPose(finalName, false);
% Get its pose
objectPoseLocal = airSimClient.getObjectPose(chosenObject, true);
objectPoseWorld = airSimClient.getObjectPose(chosenObject, false);
figure;
subplot(1, 2, 1);
Expand All @@ -111,35 +103,35 @@ plotTransforms([vehiclePoseWorld.position; objectPoseWorld.position], [vehiclePo
axis equal;
grid on;
xlabel("X (m)")
%% Set vehicle pose
airSimClient.setVehiclePose(airSimClient.getVehiclePose().position + [1 1 0], airSimClient.getVehiclePose().orientation)
ylabel("Y (m)")
zlabel("Z (m)")
title("World Plot")
drawnow
```

![figure_0.png](images/matlab/figure_0.png)

```matlab
drawnow
%% Set vehicle pose
airSimClient.setVehiclePose(airSimClient.getVehiclePose().position + [1 1 0], airSimClient.getVehiclePose().orientation)
airSimClient.setVehiclePose(airSimClient.getVehiclePose(vehicle_name).position + [1 1 0], airSimClient.getVehiclePose(vehicle_name).orientation, false, vehicle_name)
```

### IMU sensor Data
```matlab
imuSensorName = "imu";
[imuData, imuTimestamp] = airSimClient.getIMUData(imuSensorName);
[imuData, imuTimestamp] = airSimClient.getIMUData(imuSensorName, vehicle_name)
```

### Echo sensor data
```matlab
% Example plots passive echo pointcloud
% and its reflection directions as 3D quivers
echoSensorName = "echo";
enablePassive = true;
[activePointCloud, activeData, passivePointCloud, passiveData , echoTimestamp, echoSensorPose] = airSimClient.getEchoData(echoSensorName, enablePassive);
[activePointCloud, activeData, passivePointCloud, passiveData , echoTimestamp, echoSensorPose] = airSimClient.getEchoData(echoSensorName, enablePassive, vehicle_name);
figure;
subplot(1, 2, 1);
Expand Down Expand Up @@ -173,21 +165,18 @@ zlabel("Z (m)")
xlim([0 10])
ylim([-10 10])
zlim([-10 10])
drawnow
```

![figure_1.png](images/matlab/figure_1.png)

```matlab
drawnow
```
### LiDAR sensor data
```matlab
% Example plots lidar pointcloud and getting the groundtruth labels
lidarSensorName = "lidar";
enableLabels = true;
[lidarPointCloud, lidarLabels, LidarTimestamp, LidarSensorPose] = airSimClient.getLidarData(lidarSensorName, enableLabels);
[lidarPointCloud, lidarLabels, LidarTimestamp, LidarSensorPose] = airSimClient.getLidarData(lidarSensorName, enableLabels, vehicle_name);
figure;
if ~isempty(lidarPointCloud)
Expand All @@ -202,21 +191,19 @@ zlabel("Z (m)")
xlim([0 10])
ylim([-10 10])
zlim([-10 10])
drawnow
```

![figure_2.png](images/matlab/figure_2.png)

```matlab
drawnow

```
### GPU LiDAR sensor data
```matlab
% Example plots GPU lidar pointcloud with its RGB segmentation colors
Example plots GPU lidar pointcloud with its RGB segmentation colors
gpuLidarSensorName = "gpulidar";
enableLabels = true;
[gpuLidarPointCloud, gpuLidarTimestamp, gpuLidarSensorPose] = airSimClient.getGPULidarData(gpuLidarSensorName);
[gpuLidarPointCloud, gpuLidarTimestamp, gpuLidarSensorPose] = airSimClient.getGPULidarData(gpuLidarSensorName, vehicle_name);
figure;
if ~isempty(gpuLidarPointCloud)
Expand All @@ -231,29 +218,25 @@ zlabel("Z (m)")
xlim([0 10])
ylim([-10 10])
zlim([-10 10])
drawnow
```

![figure_3.png](images/matlab/figure_3.png)

```matlab
drawnow
```
### Cameras
```matlab
%% Get camera info
cameraSensorName = "frontcamera";
[intrinsics, cameraSensorPose] = airSimClient.getCameraInfo(cameraSensorName);
[intrinsics, cameraSensorPose] = airSimClient.getCameraInfo(cameraSensorName, vehicle_name);
%% Get single camera images
% Get images sequentially
cameraSensorName = "front_center";
[rgbImage, rgbCameraIimestamp] = airSimClient.getCameraImage(cameraSensorName, AirSimCameraTypes.Scene);
[segmentationImage, segmentationCameraIimestamp] = airSimClient.getCameraImage(cameraSensorName, AirSimCameraTypes.Segmentation);
[depthImage, depthCameraIimestamp] = airSimClient.getCameraImage(cameraSensorName, AirSimCameraTypes.DepthPlanar);
[annotationImage, annotationCameraIimestamp] = airSimClient.getCameraImage(cameraSensorName, AirSimCameraTypes.Annotation, "TextureTestDirect");
[rgbImage, rgbCameraIimestamp] = airSimClient.getCameraImage(cameraSensorName, AirSimCameraTypes.Scene, vehicle_name);
[segmentationImage, segmentationCameraIimestamp] = airSimClient.getCameraImage(cameraSensorName, AirSimCameraTypes.Segmentation,vehicle_name);
[depthImage, depthCameraIimestamp] = airSimClient.getCameraImage(cameraSensorName, AirSimCameraTypes.DepthPlanar,vehicle_name);
[annotationImage, annotationCameraIimestamp] = airSimClient.getCameraImage(cameraSensorName, AirSimCameraTypes.Annotation, vehicle_name, "TextureTestDirect");
figure;
subplot(4, 1, 1);
imshow(rgbImage)
Expand All @@ -267,19 +250,19 @@ title("Depth Camera Image")
subplot(4, 1, 4);
imshow(annotationImage)
title("Annotation Camera Image")
drawnow
```

![figure_4.png](images/matlab/figure_4.png)

```matlab
%% Get synced camera images
% By combining the image requests they will be synced
% and taken in the same frame
% By combining the image requests they will be synced and taken in the same frame
cameraSensorName = "front_center";
[images, cameraIimestamp] = airSimClient.getCameraImages(cameraSensorName, ...
[AirSimCameraTypes.Scene, AirSimCameraTypes.Segmentation, AirSimCameraTypes.DepthPlanar, AirSimCameraTypes.Annotation], ...
["", "", "", "GreyscaleTest"]);
vehicle_name, ["", "", "", "TextureTestDirect"]);
figure;
subplot(4, 1, 1);
imshow(images{1})
Expand All @@ -293,6 +276,7 @@ title("Synced Depth Camera Image")
subplot(4, 1, 4);
imshow(images{4})
title("Synced Annotation Camera Image")
drawnow
```

![figure_5.png](images/matlab/figure_5.png)
Expand Down

0 comments on commit 08f6120

Please sign in to comment.