Skip to content

Commit

Permalink
Update for 2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nesnes committed Apr 24, 2018
1 parent 9af7a52 commit 1fe85cd
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 16 deletions.
2 changes: 1 addition & 1 deletion svo recording/export/README.md
@@ -1,4 +1,4 @@
# Stereolabs ZED - SVO Export
# Stereolabs ZED - SVO Recording utilities

This sample demonstrates how to read a SVO file and convert it into an AVI file (LEFT + RIGHT) or (LEFT + DEPTH_VIEW).

Expand Down
4 changes: 2 additions & 2 deletions svo recording/playback/README.md
@@ -1,4 +1,4 @@
# Stereolabs ZED - SVO Playback
# Stereolabs ZED - SVO Playback utilities

This sample demonstrates how to read a SVO video file.
We use OpenCV to display the video.
Expand Down Expand Up @@ -40,4 +40,4 @@ Open a terminal in build directory and execute the following command:

Example :

./ZED_SVO_Recording "./mysvo.svo"
./ZED_SVO_Recording "./mysvo.svo"
2 changes: 1 addition & 1 deletion svo recording/recording/README.md
@@ -1,4 +1,4 @@
# Stereolabs ZED - SVO Recording
# Stereolabs ZED - SVO Recording utilities

This sample shows how to record video in Stereolabs SVO format.
SVO video files can be played with the ZED API and used with its different modules.
Expand Down
2 changes: 1 addition & 1 deletion tutorials/tutorial 4 - positional tracking/CMakeLists.txt
Expand Up @@ -9,7 +9,7 @@ endif(COMMAND cmake_policy)

SET(EXECUTABLE_OUTPUT_PATH ".")

find_package(ZED 2 REQUIRED)
find_package(ZED 2.3 REQUIRED)
find_package(CUDA ${ZED_CUDA_VERSION} EXACT REQUIRED)

include_directories(${CUDA_INCLUDE_DIRS})
Expand Down
39 changes: 33 additions & 6 deletions tutorials/tutorial 4 - positional tracking/README.md
Expand Up @@ -22,17 +22,19 @@ We assume that you have followed previous tutorials.

Open a terminal in the sample directory and execute the following command:

```bash
mkdir build
cd build
cmake ..
make

```

# Code overview
## Create a camera

As in previous tutorials, we create, configure and open the ZED.

```
```c++
// Create a ZED camera object
Camera zed;

Expand All @@ -52,7 +54,7 @@ if (err != SUCCESS)
Once the camera is opened, we must enable the positional tracking module in order to get the position and orientation of the ZED.
```
```c++
// Enable positional tracking with default parameters
sl::TrackingParameters tracking_parameters;
err = zed.enableTracking(tracking_parameters);
Expand All @@ -70,7 +72,7 @@ The camera position is given by the class sl::Pose. This class contains the tran
A pose is always linked to a reference frame. The SDK provides two reference frame : REFERENCE_FRAME_WORLD and REFERENCE_FRAME_CAMERA.<br/> It is not the purpose of this tutorial to go into the details of these reference frame. Read the documentation for more information.<br/>
In the example, we get the device position in the World Frame.

```
```c++
// Track the camera position during 1000 frames
int i = 0;
sl::Pose zed_pose;
Expand All @@ -90,7 +92,32 @@ while (i < 1000) {
}
```

This will loop until the ZED has been tracked for 1000 frames. We display the camera translation (in meters) in the console window and close the camera before exiting the application.
### Inertial Data

If a ZED Mini is open, we can have access to the inertial data from the integrated IMU

```c++
bool zed_mini = (zed.getCameraInformation().camera_model == MODEL_ZED_M);
```

First, we test that the opened camera is a ZED Mini, then, we display some useful IMU data, such as the quaternion and the linear acceleration.

```c++
if (zed_mini) { // Display IMU data

// Get IMU data
zed.getIMUData(imu_data, TIME_REFERENCE_IMAGE); // Get the data

// Filtered orientation quaternion
printf("IMU Orientation: Ox: %.3f, Oy: %.3f, Oz: %.3f, Ow: %.3f\n", imu_data.getOrientation().ox,
imu_data.getOrientation().oy, imu_data.getOrientation().oz, zed_pose.getOrientation().ow);
// Raw acceleration
printf("IMU Acceleration: x: %.3f, y: %.3f, z: %.3f\n", imu_data.linear_acceleration.x,
imu_data.linear_acceleration.y, imu_data.linear_acceleration.z);
}
```

This will loop until the ZED has been tracked during 1000 frames. We display the camera translation (in meters) in the console window and close the camera before exiting the application.

```
// Disable positional tracking and close the camera
Expand All @@ -99,4 +126,4 @@ zed.close();
return 0;
```

You can now use the ZED as an inside-out positional tracker. You can also read on the next tutorial to learn how to use Spatial Mapping.
You can now use the ZED as an inside-out positional tracker. You can now read the next tutorial to learn how to use the Spatial Mapping.
29 changes: 24 additions & 5 deletions tutorials/tutorial 4 - positional tracking/main.cpp
Expand Up @@ -19,7 +19,7 @@
///////////////////////////////////////////////////////////////////////////


#include <sl/Camera.hpp>
#include <sl_zed/Camera.hpp>

using namespace sl;

Expand All @@ -41,27 +41,46 @@ int main(int argc, char **argv) {
exit(-1);

// Enable positional tracking with default parameters
sl::TrackingParameters tracking_parameters;
TrackingParameters tracking_parameters;
err = zed.enableTracking(tracking_parameters);
if (err != SUCCESS)
exit(-1);


// Track the camera position during 1000 frames
int i = 0;
sl::Pose zed_pose;
Pose zed_pose;

// Check if the camera is a ZED M and therefore if an IMU is available
bool zed_mini = (zed.getCameraInformation().camera_model == MODEL_ZED_M);
IMUData imu_data;

while (i < 1000) {
if (zed.grab() == SUCCESS) {
zed.getPosition(zed_pose, REFERENCE_FRAME_WORLD); // Get the pose of the left eye of the camera with reference to the world frame

// Display the translation and timestamp
printf("Translation: Tx: %.3f, Ty: %.3f, Tz: %.3f, Timestamp: %llu\n", zed_pose.getTranslation().tx,
printf("\nTranslation: Tx: %.3f, Ty: %.3f, Tz: %.3f, Timestamp: %llu\n", zed_pose.getTranslation().tx,
zed_pose.getTranslation().ty, zed_pose.getTranslation().tz, zed_pose.timestamp);

// Display the orientation quaternion
printf("Orientation: Ox: %.3f, Oy: %.3f, Oz: %.3f, Ow: %.3f\n\n", zed_pose.getOrientation().ox,
printf("Orientation: Ox: %.3f, Oy: %.3f, Oz: %.3f, Ow: %.3f\n", zed_pose.getOrientation().ox,
zed_pose.getOrientation().oy, zed_pose.getOrientation().oz, zed_pose.getOrientation().ow);


if (zed_mini) { // Display IMU data

// Get IMU data
zed.getIMUData(imu_data, TIME_REFERENCE_IMAGE);

// Filtered orientation quaternion
printf("IMU Orientation: Ox: %.3f, Oy: %.3f, Oz: %.3f, Ow: %.3f\n", imu_data.getOrientation().ox,
imu_data.getOrientation().oy, imu_data.getOrientation().oz, zed_pose.getOrientation().ow);
// Raw acceleration
printf("IMU Acceleration: x: %.3f, y: %.3f, z: %.3f\n", imu_data.linear_acceleration.x,
imu_data.linear_acceleration.y, imu_data.linear_acceleration.z);
}

i++;
}
}
Expand Down

0 comments on commit 1fe85cd

Please sign in to comment.