# My code doesn't work, can I have yours?

**URL:** <https://forum.opencv.org/t/my-code-doesnt-work-can-i-have-yours/12187>\
**Category:** Uncategorized\
**Tags:** programming\
**Created:** [February 28, 2023, 5:14pm UTC](https://forum.opencv.org/t/my-code-doesnt-work-can-i-have-yours/12187 "2023-02-28T17:14:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scp](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@scp](https://forum.opencv.org/u/scp)\
**Post date:** [February 28, 2023, 5:14pm UTC](https://forum.opencv.org/t/my-code-doesnt-work-can-i-have-yours/12187/1 "2023-02-28T17:14:48Z")

</div>

Hello,  
I am currently trying to implement Hand-eye calibration for an XArm vArm6 robot arm equipped with an Intel Realsense D435 camera. I am currently facing errors in the conversion from pose vector to rotation matrix using the Rodrigues function in OpenCV. Do you have any tips on how to get consistent results? Also is it possible for you to share your entire code, it would be really helpful.  
Thanks

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [March 1, 2023, 7:35am UTC](https://forum.opencv.org/t/my-code-doesnt-work-can-i-have-yours/12187/2 "2023-03-01T07:35:32Z")

</div>

> [@scp](#):
>
> I am currently facing errors in the conversion from pose vector to rotation matrix using the Rodrigues function

please show, what you’re doing there (data,code), and highlight, where it fails, no ?

---

<div class="post-metadata">

**Author:** ![Bisma\_Mutiargo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/bisma_mutiargo/32/8859_2.png) [@Bisma\_Mutiargo](https://forum.opencv.org/u/Bisma_Mutiargo)\
**Post date:** [January 29, 2024, 11:27am UTC](https://forum.opencv.org/t/my-code-doesnt-work-can-i-have-yours/12187/3 "2024-01-29T11:27:36Z")

</div>

Hi, I am facing the same issue at the moment.  
i am using UR5 and GoCator scanner. i managed to get the following  
Camera\_to\_object 4x4 matrix, and the pose of the robot in XYZ,Rx,Ry,Rz

UR\_pose\_XYZRxRyRz = [[0.817, 0.577, 0.003, -0.577, 0.817, -0.021, -0.015, 0.015, 1, 0.034816, -0.052201, 0.185832], [0.814, 0.577, 0.073, -0.573, 0.817, -0.071, -0.1, 0.016, 0.995, 0.020529, -0.052133, 0.193793], [0.815, 0.579, 0.012, -0.578, 0.813, 0.065, 0.028, -0.06, 0.998, 0.041913, -0.062817, 0.16366], [0.816, 0.573, -0.075, -0.577, 0.815, -0.057, 0.029, 0.09, 0.996, 0.041482, -0.040058, 0.19812], [0.805, 0.576, 0.143, -0.564, 0.817, -0.119, -0.185, 0.016, 0.983, 0.005647, -0.052365, 0.200626], [0.816, 0.569, 0.103, -0.578, 0.807, 0.12, -0.015, -0.158, 0.987, 0.035283, -0.075217, 0.143927], [0.804, 0.578, -0.137, -0.573, 0.816, 0.079, 0.157, 0.015, 0.987, 0.060851, -0.051865, 0.166305], [0.817, 0.568, -0.096, -0.576, 0.802, -0.158, -0.013, 0.185, 0.983, 0.03446, -0.021988, 0.223045], [0.813, 0.577, 0.083, -0.572, 0.817, -0.078, -0.113, 0.016, 0.993, 0.018423, -0.052187, 0.194877], [0.815, 0.579, 0.013, -0.579, 0.812, 0.077, 0.034, -0.071, 0.997, 0.042947, -0.063973, 0.160415], [0.811, 0.576, 0.099, -0.57, 0.817, -0.089, -0.133, 0.016, 0.991, 0.015019, -0.052297, 0.196541], [0.814, 0.58, 0.015, -0.579, 0.81, 0.097, 0.044, -0.088, 0.995, 0.044519, -0.066091, 0.155218], [0.817, 0.573, -0.065, -0.576, 0.809, -0.115, -0.013, 0.131, 0.991, 0.034496, -0.032159, 0.21191], [0.816, 0.569, -0.104, -0.577, 0.814, -0.069, 0.045, 0.117, 0.992, 0.043855, -0.035598, 0.202356], [0.814, 0.581, 0.018, -0.578, 0.806, 0.127, 0.059, -0.113, 0.992, 0.046969, -0.069002, 0.147202], [0.818, 0.57, -0.082, -0.576, 0.806, -0.139, -0.013, 0.161, 0.987, 0.034451, -0.026646, 0.218155], [0.815, 0.564, -0.131, -0.576, 0.814, -0.081, 0.061, 0.141, 0.988, 0.046171, -0.031307, 0.206127]]  
camera\_to\_object\_4x4 = [array([[0.817, 0.577, 0.003, 0.035],  
[-0.577, 0.817, -0.021, -0.052],  
[-0.015, 0.015, 1. , 0.186],  
[0. , 0. , 0. , 1.]]), array([[0.814, 0.577, 0.073, 0.021],  
[-0.573, 0.817, -0.071, -0.052],  
[-0.1 , 0.016, 0.995, 0.194],  
[0. , 0. , 0. , 1.]]), array([[0.815, 0.579, 0.012, 0.042],  
[-0.578, 0.813, 0.065, -0.063],  
[0.028, -0.06 , 0.998, 0.164],  
[0. , 0. , 0. , 1.]]), array([[0.816, 0.573, -0.075, 0.041],  
[-0.577, 0.815, -0.057, -0.04],  
[0.029, 0.09 , 0.996, 0.198],  
[0. , 0. , 0. , 1.]]), array([[0.805, 0.576, 0.143, 0.006],  
[-0.564, 0.817, -0.119, -0.052],  
[-0.185, 0.016, 0.983, 0.201],  
[0. , 0. , 0. , 1.]]), array([[0.816, 0.569, 0.103, 0.035],  
[-0.578, 0.807, 0.12 , -0.075],  
[-0.015, -0.158, 0.987, 0.144],  
[0. , 0. , 0. , 1.]]), array([[0.804, 0.578, -0.137, 0.061],  
[-0.573, 0.816, 0.079, -0.052],  
[0.157, 0.015, 0.987, 0.166],  
[0. , 0. , 0. , 1.]]), array([[0.817, 0.568, -0.096, 0.034],  
[-0.576, 0.802, -0.158, -0.022],  
[-0.013, 0.185, 0.983, 0.223],  
[0. , 0. , 0. , 1.]]), array([[0.813, 0.577, 0.083, 0.018],  
[-0.572, 0.817, -0.078, -0.052],  
[-0.113, 0.016, 0.993, 0.195],  
[0. , 0. , 0. , 1.]]), array([[0.815, 0.579, 0.013, 0.043],  
[-0.579, 0.812, 0.077, -0.064],  
[0.034, -0.071, 0.997, 0.16],  
[0. , 0. , 0. , 1.]]), array([[0.811, 0.576, 0.099, 0.015],  
[-0.57 , 0.817, -0.089, -0.052],  
[-0.133, 0.016, 0.991, 0.197],  
[0. , 0. , 0. , 1.]]), array([[0.814, 0.58 , 0.015, 0.045],  
[-0.579, 0.81 , 0.097, -0.066],  
[0.044, -0.088, 0.995, 0.155],  
[0. , 0. , 0. , 1.]]), array([[0.817, 0.573, -0.065, 0.034],  
[-0.576, 0.809, -0.115, -0.032],  
[-0.013, 0.131, 0.991, 0.212],  
[0. , 0. , 0. , 1.]]), array([[0.816, 0.569, -0.104, 0.044],  
[-0.577, 0.814, -0.069, -0.036],  
[0.045, 0.117, 0.992, 0.202],  
[0. , 0. , 0. , 1.]]), array([[0.814, 0.581, 0.018, 0.047],  
[-0.578, 0.806, 0.127, -0.069],  
[0.059, -0.113, 0.992, 0.147],  
[0. , 0. , 0. , 1.]]), array([[0.818, 0.57 , -0.082, 0.034],  
[-0.576, 0.806, -0.139, -0.027],  
[-0.013, 0.161, 0.987, 0.218],  
[0. , 0. , 0. , 1.]]), array([[0.815, 0.564, -0.131, 0.046],  
[-0.576, 0.814, -0.081, -0.031],  
[0.061, 0.141, 0.988, 0.206],  
[0. , 0. , 0. , 1.]])]

i am getting:

Tsai Lenz:  
[[1. , 0.008 ,-0.009, -0.066]  
[0.006, -0.979, -0.205, -0.33]  
[-0.01, 0.205, -0.979, 0.698]  
[0. , 0. , 0. , 1.]]  
Park Martin:  
[[1. , 0.001, -0.009, -0.072]  
[0.001, -1. , -0.001, -0.361]  
[-0.009 , 0.001, -1. , 0.682]  
[0. , 0. , 0. , 1.]]  
Horaud:  
[[1. , 0.001, -0.009 ,-0.072]  
[0.001, -1. , -0.001 ,-0.361]  
[-0.009 , 0.001, -1. , 0.682]  
[0. , 0. , 0. , 1.]]  
Danilidis:  
[[1. , 0.013 , -0.009 , -0.07]  
[0.013 , -1. , -0.002 , -0.364]  
[-0.009 , 0.002 , -1. , 0.715]  
[0. , 0. , 0. , 1.]]

while the correct value should be

[[1 , 0.005, -0.011, 0.076416],  
[0.00 , -1 , -0.001, 0.099337],  
[-0.011, 0.001, -1.0 , 0.637711],  
[0 , 0 , 0 , 1]]

what is anyone getting the right result?
