Hand-Eye Calibration API
Using the Hand-Eye Calibration API
To perform hand-eye calibration using the API, the user than either import a project which is exported from the toolbox or configure the calibration parameters from scratch.
The following code snippet shows an example of how to set up a project by importing from a .xml file.
1Dim project1 As New HandEyeCalibration
2project1.importFromXML("C:\..\Fanuc_IntelRealSense_BWSphere.xml")
3project1.calculate()
4Dim result1() As Double = project1.ResultInBwFormat
5Dim error1 As Double = project1.CalibrationError
6Console.WriteLine(String.Format("The result is: " + vbCrLf + "{0}", String.Join(", ", result1)))
7Console.WriteLine(String.Format("The error is {0} mm", error1))
1HandEyeCalibration project1 = new HandEyeCalibration();
2project1.importFromXML("C:\\..\\Fanuc_IntelRealSense_BWSphere.xml");
3project1.calculate();
4Double[] result1 = project1.ResultInBwFormat;
5Double error1 = project1.CalibrationError;
6Console.WriteLine("The result is: \n{0}", String.Join(", ", result1));
7Console.WriteLine("The error is {0} mm", error1);
The following code snippet shows an example of how to set up a project by configuring each parameters.
1Dim project2 As New HandEyeCalibration
2project2.RobotConvention = 1 ' Using a Fanuc or Motoman robot
3project2.SensorType = True ' snapshot sensor
4project2.SensorMount = True ' moving sensor
5project2.CalibrationTarget = 1 ' Using BWsphere as the calibration target
6project2.addRobotPose({-103.956, 467.351, 713.18, -177.639, 41.607, -89.681})
7project2.addRobotPose({229.449, 480.299, 484.947, -101.478, 45.847, 38.901})
8project2.addRobotPose({168.772, 966.084, 607.55, 135.971, 33.43, -24.529})
9project2.addRobotPose({-306.446, 591.091, 699.784, -134.6, 14.57919598, -57.526})
10project2.addRobotPose({268.557, 518.736, 429.881, 92.391, 64.447, -126.947})
11project2.addRobotPose({-179.668, 492.719, 654.584, -125.728, -1.362, -14.176})
12project2.addRobotPose({-159.039, 383.95, 488.094, 120.934, -53.75125122, 144.645})
13project2.addMeas({4.769, -46.182, 272.426})
14project2.addMeas({15.785, -14.783, 304.55})
15project2.addMeas({-13.366, -49.585, 223.649})
16project2.addMeas({17.529, 14.712, 238.01})
17project2.addMeas({-10.831, 7.988, 308.798})
18project2.addMeas({8.253, -7.6, 223.837})
19project2.addMeas({2.925, 51.503, 250.031})
20project2.calculate()
21Dim result2() As Double = project1.ResultInBwFormat
22Dim error2 As Double = project1.CalibrationError
23Console.WriteLine(String.Format("The result is: " + vbCrLf + "{0}", String.Join(", ", result2)))
24Console.WriteLine(String.Format("The error is {0} mm", error2))
1HandEyeCalibration project2 = new HandEyeCalibration();
2project2.RobotConvention = 1; // Using a Fanuc or Motoman robot
3project2.SensorType = true; // snapshot sensor
4project2.SensorMount = true; // moving sensor
5project2.CalibrationTarget = 1; // Using BWsphere as the calibration target
6project2.addRobotPose(new double[] { -103.956, 467.351, 713.18, -177.639, 41.607, -89.681});
7project2.addRobotPose(new double[] { 229.449, 480.299, 484.947, -101.478, 45.847, 38.901});
8project2.addRobotPose(new double[] { 168.772, 966.084, 607.55, 135.971, 33.43, -24.529});
9project2.addRobotPose(new double[] { -306.446, 591.091, 699.784, -134.6, 14.57919598, -57.526});
10project2.addRobotPose(new double[] { 268.557, 518.736, 429.881, 92.391, 64.447, -126.947});
11project2.addRobotPose(new double[] { -179.668, 492.719, 654.584, -125.728, -1.362, -14.176});
12project2.addRobotPose(new double[] { -159.039, 383.95, 488.094, 120.934, -53.75125122, 144.645});
13project2.addMeas(new double[] { 4.769, -46.182, 272.426});
14project2.addMeas(new double[] { 15.785, -14.783, 304.55});
15project2.addMeas(new double[] { -13.366, -49.585, 223.649});
16project2.addMeas(new double[] { 17.529, 14.712, 238.01});
17project2.addMeas(new double[] { -10.831, 7.988, 308.798});
18project2.addMeas(new double[] { 8.253, -7.6, 223.837});
19project2.addMeas(new double[] { 2.925, 51.503, 250.031});
20project2.calculate();
21Double[] result2 = project2.ResultInBwFormat;
22double error2 = project2.CalibrationError;
Constructors
- HandEyeCalibration()
Initializes a new instance of the HandEyeCalibration class.
- HandEyeCalibration(oAngConvByRbt, oIsSnapshotSensor, oIsMovingSensor, oCalibTarget, oLstPose, oLstMeas)
Initializes a new instance of the HandEyeCalibration class with parameters.
oAngConvByRbt
Format convention of robot pose.0 for ABB
1 for Fanuc_or_Motoman
2 for KUKA
3 for UR_RPY_Deg
4 for UR_RPY_Rad
5 for UR_RotVec_Deg
6 for UR_RotVec_Rad
oIsSnapshotSensor
Sensor type. true for snapshot sensor and false for profile sensor.oIsMovingSensor
Sensor mount. true for moving sensor and false for fixed sensor.oCalibTarget
Type of calibration target.0 for BWSphere
1 for Sphere
2 for PyramidSmall
3 for PyramidMedium
4 for PyramidLarge
5 for Other
oLstPose
List of robot poses in Double(). The length of Double() should be 7 for quaternion format and 6 for others, where the first 3 elements represent the position and the rest represent the rotation.oLstMeas
List of measurements in Double(). The length of Double() should be 3 to represent XYZ position or 6 to represent XYZWPR pose.
- HandEyeCalibration(oAngConvByRbt, oIsSnapshotSensor, oIsMovingSensor, oCalibTarget, oTargetRadius, oLstPose, oLstMeasXYZ)
Initializes a new instance of the HandEyeCalibration class with parameters.
oAngConvByRbt
Format convention of robot pose. Refer to here for detailed definition.oIsSnapshotSensor
Sensor type. true for snapshot sensor and false for profile sensor.oIsMovingSensor
Sensor mount. true for moving sensor and false for fixed sensor.oCalibTarget
Type of calibration target. Refer to here for detailed definition.oTargetRadius
Radius of sphere if calibration target is a sphere.oLstPose
List of robot poses in Double(). The length of Double() should be 6 or 7, where the first 3 elements represent the position and the rest represent the rotation.oLstMeasXYZ
List of measurements in Double(). The length of Double() should be 3 in case theoTargetRadius
is used as a parameter.
Properties
- RobotConvention
Gets or sets the format convention of robot pose. Refer to here for detailed definition.
- SensorType
Gets or sets the sensor type. true for snapshot sensor and false for profile sensor.
- SensorMount
Gets or sets the sensor mount. true for moving sensor and false for fixed sensor.
- SphereRadius
Gets or sets the radius of sphere if calibration target is a sphere.
- RobotPoseCount
(Read-only) Gets the total number of robot poses.
- MeasCount
(Read-only) Gets the total number of measurements.
- ResultInBwFormat
(Read-only) Gets the calibration result in BW format.
- ResultInRobotFormat
(Read-only) Gets the calibration result in robot format, which is the same as the format convention of robot pose.
- CalibrationError
(Read-only) Gets the overall calibration error.
- ErrorAtEachPose
(Read-only) Gets the calibration error at each pose.
Methods
- addRobotPose(pose() as double)
Adds a robot pose
pose
.
- removeRobotPoseAt(i As Integer)
Removes the
i
th robot pose
- clearAllRobotPose()
Clears all robot poses.
- setRobotPoseAt(pose() As Double, i As Integer)
Sets the
i
th robot pose topose
.
- getRobotPoseAt(i As Integer) As Double()
Returns the
i
th robot pose.
- addMeas(meas() As Double)
Adds a measurement
meas
.
- removeMeasAt(i As Integer)
Removes the
i
th measurement.
- clearAllMeas()
Clears all measurements.
- setMeasAt(meas() As Double, i As Integer)
Sets the
i
th measurement tomeas
.
- getMeasAt(i As Integer) As Double()
Returns the
i
th measurement.
- importFromXML(fileName As String)
Imports a project file (.xml) from file
fileName
.
- exportToXML(fileName As String)
Exports the project to a file (.xml) to
fileName
.
- calculate()
Calcualtes the hand-eye result and save the results and error to
ResultInBwFormat
,ResultInRobotFormat
,CalibrationError
, andErrorAtEachPose
Transformation Calculator API
Using the Transformation Calculator API
To perform an alignment using the API, the user than either import a project which is exported from the toolbox or configure the alignment parameters from scratch.
The following code snippet shows an example of how to set up an alignment project by importing from a .xml file.
1Dim project1 As New TfCalculation
2project1.importFromXML("C:\..\Transformation_Calculator_Best_Fit_By_Point_Example.xml")
3project1.configureAllBestFitByPoint(({True, True, True, True}).ToList)
4project1.calculate()
5Dim result1() As Double = project1.ResultRef2Tar
6Dim error1 As Double = project1.AlignError
7Console.WriteLine(String.Format("The result is: " + vbCrLf + "{0}", String.Join(", ", result1)))
8Console.WriteLine(String.Format("The error is {0} mm", error1))
1TfCalculation project1 = new TfCalculation();
2project1.importFromXML("C:\\..\Transformation_Calculator_Best_Fit_By_Point_Example.xml");
3project1.configureAllBestFitByPoint(new List<bool> { true, true, true, true });
4project1.calculate();
5Double[] result1 = project1.ResultRef2Tar;
6Double error1 = project1.AlignError;
7Console.WriteLine("The result is: \n{0}", String.Join(", ", result1));
8Console.WriteLine("The error is {0} mm", error1);
The following code snippet shows an example of how to set up an alignment project using Best-Fit by Point.
1Dim project2 As New TfCalculation
2project2.AlignMethod = 1 ' Best-Fit by Point
3project2.addRef({-423.88, 101.5, 92.88})
4project2.addRef({-423.88, -145, 92.88})
5project2.addRef({80, -170, -25})
6project2.addRef({-406, 132, -181.45})
7project2.addTar({899.847, -282.736, -293.078})
8project2.addTar({1085.585, -426.958, -366.741})
9project2.addTar({1374.169, -309.402, 47.232})
10project2.addTar({1023.745, -42.017, -349.738})
11project2.configureAllBestFitByPoint(({True, True, True, True}).ToList)
12project2.calculate()
13Dim result2() As Double = project2.ResultRef2Tar
14Dim error2 As Double = project2.AlignError
15Console.WriteLine(String.Format("The result is: " + vbCrLf + "{0}", String.Join(", ", result2)))
16Console.WriteLine(String.Format("The error is {0} mm", error2))
1TfCalculation project2 = new TfCalculation();
2project2.AlignMethod = 1; // Best-Fit by Point
3project2.addRef(new double[] { -423.88, 101.5, 92.88});
4project2.addRef(new double[] { -423.88, -145, 92.88});
5project2.addRef(new double[] { 80, -170, -25});
6project2.addRef(new double[] { -406, 132, -181.45});
7project2.addTar(new double[] { 899.847, -282.736, -293.078});
8project2.addTar(new double[] { 1085.585, -426.958, -366.741});
9project2.addTar(new double[] { 1374.169, -309.402, 47.232});
10project2.addTar(new double[] { 1023.745, -42.017, -349.738});
11project2.configureAllBestFitByPoint(new List<bool> {true, true, true, true});
12project2.calculate();
13Double[] result2 = project2.ResultRef2Tar;
14Double error2 = project2.AlignError;
15Console.WriteLine("The result is: \n{0}", String.Join(", ", result2));
16Console.WriteLine("The error is {0} mm", error2);
The following code snippet shows an example of how to set up an alignment project using Best-Fit by Axis.
1Dim project2 As New TfCalculation
2project2.AlignMethod = 2 ' Best-Fit by Axis
3project2.addRef({-423.88, 101.5, 92.88})
4project2.addRef({-423.88, -145, 92.88})
5project2.addRef({80, -170, -25})
6project2.addRef({-406, 132, -181.45})
7project2.addTar({899.847, -282.736, -293.078})
8project2.addTar({1085.585, -426.958, -366.741})
9project2.addTar({1374.169, -309.402, 47.232})
10project2.addTar({1023.745, -42.017, -349.738})
11Dim use As New List(Of Boolean())
12For i As Integer = 0 To 3
13 use.Add({True, True, True})
14Next
15project2.configureAllBestFitByAxis(use)
16project2.calculate()
17Dim result2() As Double = project2.ResultRef2Tar
18Dim error2 As Double = project2.AlignError
19Console.WriteLine(String.Format("The result is: " + vbCrLf + "{0}", String.Join(", ", result2)))
20Console.WriteLine(String.Format("The error is {0} mm", error2))
1TfCalculation project2 = new TfCalculation();
2project2.AlignMethod = 2; // Best-Fit by Axis
3project2.addRef(new double[] { -423.88, 101.5, 92.88 });
4project2.addRef(new double[] { -423.88, -145, 92.88 });
5project2.addRef(new double[] { 80, -170, -25 });
6project2.addRef(new double[] { -406, 132, -181.45 });
7project2.addTar(new double[] { 899.847, -282.736, -293.078 });
8project2.addTar(new double[] { 1085.585, -426.958, -366.741 });
9project2.addTar(new double[] { 1374.169, -309.402, 47.232 });
10project2.addTar(new double[] { 1023.745, -42.017, -349.738 });
11List<bool[]> use = new List<bool[]>();
12for (int i = 0; i < 4; i++)
13{
14 use.Add(new bool[] { true, true, true});
15}
16project2.configureAllBestFitByAxis(use);
17project2.calculate();
18Double[] result2 = project2.ResultRef2Tar;
19Double error2 = project2.AlignError;
20Console.WriteLine("The result is: \n{0}", String.Join(", ", result2));
21Console.WriteLine("The error is {0} mm", error2);
The following code snippet shows an example of how to set up an alignment project using 3-2-1 Alignment.
1Dim project2 As New TfCalculation
2project2.AlignMethod = 3 ' 3-2-1 Alignment
3project2.addRef({-0.9059, 1.8839, 1.4628})
4project2.addRef({-0.3528, -0.4718, 1.9731})
5project2.addRef({2.0527, 0.0345, 1.703})
6project2.addRef({0.1065, 1.4756, 2.3687})
7project2.addRef({0.3007, 0.6483, 2.5479})
8project2.addRef({-0.9285, 1.8018, 1.1081})
9project2.addTar({-0.6909, -3.5788, 2.8062})
10project2.addTar({-0.1136, -4.3455, 2.4007})
11project2.addTar({0.7861, -3.6854, 2.9138})
12project2.addTar({-0.6375, -3.3163, 1.8573})
13project2.addTar({-0.6726, -3.9218, 1.537})
14project2.addTar({-0.6152, -2.2206, 2.0165})
15project2.configure321Alignment({1, 2, 3, 4, 5, 6})
16project2.calculate()
17Dim result2() As Double = project2.ResultRef2Tar
18Dim error2 As Double = project2.AlignError
19Console.WriteLine(String.Format("The result is: " + vbCrLf + "{0}", String.Join(", ", result2)))
20Console.WriteLine(String.Format("The error is not available for 3-2-1 alignment", error2))
1TfCalculation project2 = new TfCalculation();
2project2.AlignMethod = 3; // 3-2-1 Alignment
3project2.addRef(new double[] { -0.9059, 1.8839, 1.4628 });
4project2.addRef(new double[] { -0.3528, -0.4718, 1.9731});
5project2.addRef(new double[] { 2.0527, 0.0345, 1.703});
6project2.addRef(new double[] { 0.1065, 1.4756, 2.3687});
7project2.addRef(new double[] { 0.3007, 0.6483, 2.5479});
8project2.addRef(new double[] { -0.9285, 1.8018, 1.1081});
9project2.addTar(new double[] { -0.6909, -3.5788, 2.8062});
10project2.addTar(new double[] { -0.1136, -4.3455, 2.4007});
11project2.addTar(new double[] { 0.7861, -3.6854, 2.9138});
12project2.addTar(new double[] { -0.6375, -3.3163, 1.8573});
13project2.addTar(new double[] { -0.6726, -3.9218, 1.537});
14project2.addTar(new double[] { -0.6152, -2.2206, 2.0165});
15project2.configure321Alignment(new int[] { 1, 2, 3, 4, 5, 6 });
16project2.calculate();
17Double[] result2 = project2.ResultRef2Tar;
18Double error2 = project2.AlignError;
19Console.WriteLine("The result is: \n{0}", String.Join(", ", result2));
20Console.WriteLine("The error is {0} mm", error2);
Constructors
- TfCalculation()
Initializes a new instance of the TfCalculation class.
Properties
- AlignMethod
Gets or sets the alignment method.
0 for None
1 for Best-Fit by Point
2 for Best-Fit by Axis
3 for 3-2-1 Alignment
- RefCount
(Read-only) Gets the total number of reference points.
- TarCount
(Read-only) Gets the total number of target points.
- Configured
(Read-only) Gets if the points and method have been fully configured and ready to calculate.
- ResultRefToTar
(Read-only) Gets the alignment result that transforms reference points to target points.
- ResultTarToRef
(Read-only) Gets the alignment result that transforms target points to reference points.
- AlignError
(Read-only) Gets the overall alignment error.
Methods
- addRef(pt() as double)
Adds a reference piont
pt()
. The length ofpt()
must be 3.
- removeRefAt(i As Integer)
Removes the
i
th reference piont.
- clearAllRef()
Clears all reference piont.
- setRefAt(pt() As Double, i As Integer)
Sets the
i
th reference piont topt()
.
- getRefAt(i As Integer) As Double()
Returns the
i
th reference piont.
- addTar(pt() As Double)
Adds a target point
pt()
. The length ofpt()
must be 3.
- removeTarAt(i As Integer)
Removes the
i
th target point.
- clearAllTar()
Clears all target points.
- setTarAt(pt() As Double, i As Integer)
Sets the
i
th target point topt()
.
- getTarAt(i As Integer) As Double()
Returns the
i
th target point.
- configureAllBestFitByPoint(use As List(Of Boolean))
Only use when the alignment method is Best-Fit by Point.
use
is a list of boolean variables indicating whether each point is being used or not.
- configureAllBestFitByAxis(use As List(Of Boolean()))
Only use when the alignment method is Best-Fit by Axis.
use
is a list of boolean arrays indicating whether each axis of a point is being used or not.
- configure321Alignment(arr() As Integer)
Only use when the alignment method is 3-2-1 Alignment. The length of
arr()
must be 6, wherearr(0)
toarr(2)
are used as plane points,arr(3)
andarr(4)
are used as line points, andarr(5)
is used as a point.
- Calculate()
Calculate the alignment result if
Configured
is true, and save the results toResultRef2Tar
,ResultTar2Ref
, andAlignError
.
- importFromXML(fileName As String)
Imports a project file (.xml) from file
fileName
.
- exportToXML(fileName As String)
Exports the project to a file (.xml) to
fileName
.