Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tm2 calibration write api #4650

Merged

Conversation

honpong
Copy link
Contributor

@honpong honpong commented Aug 16, 2019

Adding 5 libRS API in rs_device.hpp for writing T265 calibration:

tm2::set_intrinsics(...)
tm2::set_extrinsics(...)
tm2::set_motion_device_intrinsics(...)
tm2::reset_to_factory_calibration(...)
tm2::write_calibration(...)

And a C++ example rs-tm2-calibration-write can be found in another branch:
https://github.com/honpong/librealsense/tree/tm2-calibration-write-example

Copy link
Contributor

@dorodnic dorodnic left a comment

Choose a reason for hiding this comment

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

Very nicely implemented @honpong
One quick point - communicating success / failure via bool return code goes somewhat against librealsense convention. I would recommend throwing from tm2_sensor level and changing all return types to void. The exception would propagate through the hourglass layer and will be rethrown in C++.

@dorodnic dorodnic added the T260 series Intel® T265 library label Aug 19, 2019
@honpong
Copy link
Contributor Author

honpong commented Aug 20, 2019

@dorodnic I changed all return to void after force-push

@honpong
Copy link
Contributor Author

honpong commented Aug 20, 2019

@cchen6, @harville, @schmidtp1, I checked-in a C++ example to test write/read/reset the OEM calibration. It needs custom FW from @cchen6, please get it from our Slack channel. It works for me in Windows.

@schmidtp1, @bfulkers-i I haven't yet tested in python. If you have time, please go ahead without me, while I will try on my end soon.

* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return 0 if the operation is completed successfully.
*/
void rs2_set_tm2_intrinsics(const rs2_device* device, int sensor_id, const rs2_intrinsics* intr, rs2_error** error);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The functions shouldn't include "tm2" as there is nothing tm2-specific in the signature.
Additionally, these functions shall later be reused for other devices, so the APIs shall remain generic

Copy link
Contributor Author

@honpong honpong Aug 20, 2019

Choose a reason for hiding this comment

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

@ev-mp, I can't be sure these set functions signature are good for non-tm2. I'll wait for your internal discussion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now all removed and move to use rs2_sensor* and rs2_stream_profile*, more aligned with the existing get interfaces

void rs2_set_tm2_intrinsics(const rs2_device* device, int sensor_id, const rs2_intrinsics* intr, rs2_error** error);

/**
* Set tm2 camera extrinsics
Copy link
Collaborator

Choose a reason for hiding this comment

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

All instances of "tm2" to be omitted int the public API, see above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All gone now

* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return 0 if the operation is completed successfully.
*/
void rs2_reset_tm2_to_factory_calibration(const rs2_device* device, rs2_error** e);
Copy link
Collaborator

Choose a reason for hiding this comment

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

PLs consider renaming to rs2_reset_device_to factory_calibration or similar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

* \param[out] error If non-null, receives any error that occurs during this call, otherwise, errors are ignored
* \return 0 if the operation is completed successfully.
*/
void rs2_set_tm2_extrinsics(const rs2_device* device, rs2_stream stream_type, int stream_index, const rs2_extrinsics* extr, rs2_error** error);
Copy link
Collaborator

@ev-mp ev-mp Aug 20, 2019

Choose a reason for hiding this comment

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

What are the constrains of the API - can it be applied at any time or during idle state only?
Is it a persistent change or will it reset to internally-stored values after device power cycle?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ev-mp as far as I know, those set functions will modify the virtual table of the device. So it won't affect run time result until the device being reset.
Even said that, we don't recommend the change those parameters during run-time.
@cchen6 @bfulkers-i, any comment?

Copy link
Contributor

Choose a reason for hiding this comment

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

They will take effect once you start device/play which will load calibration. It doesn't make sense to call these functions during play.

Copy link
Collaborator

@ev-mp ev-mp left a comment

Choose a reason for hiding this comment

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

we'll discuss it internally

@honpong
Copy link
Contributor Author

honpong commented Aug 20, 2019

@ev-mp @dorodnic let me know if you still want me remove the tm2 in the function names, and/or your suggested API. You may also discuss with @bfulkers-i.

@honpong honpong closed this Aug 24, 2019
@honpong honpong reopened this Aug 24, 2019
* \param[in] from_stream only support RS2_STREAM_FISHEYE
* \param[in] from_id only support left fisheye = 1
* \param[in] to_stream only support RS2_STREAM_FISHEYE
* \param[in] to_id only support left fisheye = 2
Copy link
Contributor

@schmidtp1 schmidtp1 Aug 26, 2019

Choose a reason for hiding this comment

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

RIGHT fisheye = 2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we only support set_extrinsics(fe1, fe2, extr) in the first merge, aren't we?

Copy link
Contributor

Choose a reason for hiding this comment

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

@honpong, I think @schmidtp1 is saying that the documentation should say right not left

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bfulkers-i thanks for the catch. I will fix it in next PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in #4741

rs2_extrinsics dst;
auto dst_rotation = dst.rotation;
for (auto i : { 0,3,6,1,4,7,2,5,8 }) { *dst_rotation++ = dst.rotation[i]; }
for (auto i : { 0,1,2 }) { dst.translation[i] = -src.translation[i]; }
Copy link
Contributor

Choose a reason for hiding this comment

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

this is missing rotation (by R^T)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

auto H_fe1_pose = get_extrinsics(from_profile, reference_sensor_id);
//H_fe2_pose = H_fe2_fe1 * H_fe1_pose
auto H_fe2_pose = mult(inv(H_fe1_fe2), H_fe1_pose);
set_extrinsics_to_ref(RS2_STREAM_FISHEYE, 2, H_fe2_pose);
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this could be more generic:
you could get the transformation of any sensor w.r.t. the pose (frame).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

let's focus on getting the basic set_extrinsic(fe1,fe2,extr) version merged first, we can improve in future PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bug fixed in #4741

@dorodnic dorodnic merged commit 9abeba9 into IntelRealSense:development Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T260 series Intel® T265 library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants