Skip to content

Conversation

@doronhi
Copy link
Contributor

@doronhi doronhi commented Jan 8, 2019

python.cpp: Add binding of motion_frame.

@doronhi doronhi changed the title Development add python binding of frame to motion_frame Jan 8, 2019

header_size = header.size()
data_size = 37*4 + 96
size_of_buffer = header_size + data_size # according to table "D435 IMU Calib Table" in "https://sharepoint.ger.ith.intel.com/sites/3D_project/Shared%20Documents/Arch/D400/FW/D435i_IMU_Calibration_eeprom_0_52.xlsx"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this be made public?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually do not release internal design documents directly. These get translated to white-papers and published on realsense.intel.com but it takes long time.
However, most of the information is already public inside ds5-motion.cpp.
The relevant table is structured this way:
screen shot 2019-01-09 at 15 34 14
This specific table is completely ignored by the firmware. If the calibration tool uses above table format, librealsense will automatically pick-up the values and apply them to the raw IMU data. In this case the calibration tool is this python script with linear regression along 6 known orientations.

Advanced user could implement a completely different calibration method and persist the calibration results on the device. In this case, librealsense will simply ignore it and pass raw IMU data to the application.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the insight. Looking forward to trying this out.

## Description
D435i cameras arrive from the factory without IMU calibration. Hence the values may be slightly off.
In order to improve accuracy, a calibration procedure should be done.
The rs-calibration tool walks you through the calibration steps and saves the calibration coefficient to the EEPROM, to be used applied automatically by the driver.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coefficients,...
used (xor) applied

dmirota and others added 3 commits January 10, 2019 08:22
* rs-calibration.py:  Updated direction order and added direction
labels as well as clarified prompts

* rs-calibration.py: Added newline to status message
@doronhi
Copy link
Contributor Author

doronhi commented Jan 10, 2019

@ev-mp
Thanks. Fixed.

@dorodnic dorodnic changed the title add python binding of frame to motion_frame D435i IMU calibration script Jan 10, 2019
@barnjamin
Copy link
Contributor

Using Anaconda Python3 distribution I had to make a couple modifications to the script for it to complete.

I'm not sure if Python3 is officially supported so just including the diff below.

diff --git a/tools/rs-imu-calibration/rs-imu-calibration.py b/tools/rs-imu-calibration/rs-imu-calibration.py
index 0ed3173b..9ff8ec42 100644
--- a/tools/rs-imu-calibration/rs-imu-calibration.py
+++ b/tools/rs-imu-calibration/rs-imu-calibration.py
@@ -193,7 +193,7 @@ class imu_wrapper:
             return False
         self.imu_sensor.stop()
         self.imu_sensor.close()
-        self.imu_sensor.open(active_imu_profiles)
+        self.imu_sensor.open(list(active_imu_profiles))
         self.imu_start_loop_time = time.time()
         self.imu_sensor.start(self.imu_callback)

The above was because the call to dict.values returns a non list type

@@ -354,7 +354,7 @@ def write_eeprom_to_camera(eeprom, serial_no=''):
     DC_MM_EEPROM_SIZE = eeprom.size
     DS5_CMD_LENGTH = 24
 
-    MMEW_Cmd_bytes = '\x14\x00\xab\xcd\x50\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
+    MMEW_Cmd_bytes = b'\x14\x00\xab\xcd\x50\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
 
 
     buffer = np.ones([DC_MM_EEPROM_SIZE + DS5_CMD_LENGTH, ], dtype = np.uint8) * 255

The above is because struct.unpack expects a 'bytes-like object'

@@ -491,7 +491,7 @@ def main():
         measurements, gyro = imu.get_measurements(buckets, buckets_labels)
         con_mm = np.concatenate(measurements)
 
-        header = raw_input('\nWould you like to save the raw data? Enter footer for saving files (accel_<footer>.txt and gyro_<footer>.txt)\nEnter nothing to not save raw data to disk. >')
+        header = input('\nWould you like to save the raw data? Enter footer for saving files (accel_<footer>.txt and gyro_<footer>.txt)\nEnter nothing to not save raw data to disk. >')
         if header:
             accel_file = 'accel_%s.txt' % header
             gyro_file = 'gyro_%s.txt' % header
@@ -564,7 +564,7 @@ def main():
     with open(os.path.join(directory,"calibration.bin"), 'wb') as outfile:
         outfile.write(eeprom.astype('f').tostring())
 
-    is_write = raw_input('Would you like to write the results to the camera\'s eeprom? (Y/N)')
+    is_write = input('Would you like to write the results to the camera\'s eeprom? (Y/N)')
     is_write = 'Y' in is_write.upper()
     if is_write:
         print('Writing calibration to device.')

raw_input now just input in python3

@dorodnic
Copy link
Contributor

@barnjamin / @doronhi - we might need to add python3 in a separate PR, since I'd like to include this in the upcoming release.

@ev-mp ev-mp merged commit 3f0c86d into realsenseai:development Jan 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants