Calibration¶
The calibration module provides tools for geometric calibration of robots,
including the reporting & verification suite
(print_quality_report(), export_html_report(), verify(),
export_verification_report()) attached directly to BaseCalibration.
base_calibration¶
Base calibration class for FIGAROH examples.
This module provides the BaseCalibration abstract class extracted from the FIGAROH library for use in the examples. It implements a comprehensive framework for robot kinematic calibration.
BaseCalibration(robot, config_file, del_list=None)
¶
Bases: ABC
Abstract base class for robot kinematic calibration.
This class provides a comprehensive framework for calibrating robot kinematic parameters using measurement data. It implements the Template Method pattern, providing common functionality while allowing robot-specific implementations of the cost function.
The calibration process follows these main steps: 1. Parameter initialization from configuration files 2. Data loading and validation 3. Parameter identification using base regressor analysis 4. Robust optimization with outlier detection and removal 5. Solution evaluation and validation 6. Results visualization and export
Key Features: - Automatic parameter identification using QR decomposition - Robust optimization with iterative outlier removal - Unit-aware measurement weighting for position/orientation data - Comprehensive solution evaluation and quality metrics - Extensible framework for different robot types
Attributes:
| Name | Type | Description |
|---|---|---|
STATUS |
str
|
Current calibration status ("NOT CALIBRATED" or "CALIBRATED") |
LM_result |
str
|
Optimization result from scipy.optimize.least_squares |
var_ |
ndarray
|
Calibrated parameter values |
evaluation_metrics |
dict
|
Solution quality metrics |
std_dev |
list
|
Standard deviations of calibrated parameters |
std_pctg |
list
|
Standard deviation percentages |
PEE_measured |
ndarray
|
Measured end-effector poses/positions |
q_measured |
ndarray
|
Measured joint configurations |
calib_config |
dict
|
Calibration parameters and configuration |
model |
Robot kinematic model (Pinocchio) |
|
data |
Robot data structure (Pinocchio) |
Example
Create robot-specific calibration¶
class MyRobotCalibration(BaseCalibration): ... def cost_function(self, var): ... PEEe = calc_updated_fkm(self.model, self.data, var, ... self.q_measured, self.calib_config) ... # Use body-frame position (or position_frame="world" for world frame) ... residuals = self._compute_logmap_residuals( ... self.PEE_measured, PEEe, position_frame="body") ... return self.apply_measurement_weighting(residuals) ...
Run calibration¶
calibrator = MyRobotCalibration(robot, "config.yaml") calibrator.initialize() calibrator.solve() print(f"RMSE: {calibrator.evaluation_metrics['rmse']:.6f}")
Notes
- Derived classes should implement robot-specific cost_function()
- Default cost_function is provided but issues performance warning
- Configuration files must follow FIGAROH parameter structure
- Supports both "full_params" and "joint_offset" calibration models
See Also
- TiagoCalibration: TIAGo robot implementation
- UR10Calibration: Universal Robots UR10 implementation
- calc_updated_fkm: Forward kinematics computation function
- apply_measurement_weighting: Unit-aware weighting utility
Initialize robot calibration framework.
Sets up the calibration environment by loading robot model, configuration parameters, and preparing internal data structures for optimization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
robot
|
Robot object containing kinematic model and data structures. Must have 'model' and 'data' attributes compatible with Pinocchio library. |
required | |
config_file
|
str
|
Path to YAML configuration file containing calibration parameters, data paths, and settings. |
required |
del_list
|
list
|
Indices of bad/outlier samples to exclude from calibration data. Defaults to []. |
None
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If config_file does not exist |
KeyError
|
If required parameters missing from configuration |
ValueError
|
If configuration parameters are invalid |
CalibrationError
|
If robot or configuration is invalid |
Side Effects
- Loads and validates configuration parameters
- Sets initial calibration status to "NOT CALIBRATED"
- Calculates number of calibration variables
- Resolves absolute path to measurement data file
Example
robot = load_robot_model("tiago.urdf") calibrator = TiagoCalibration(robot, "tiago_config.yaml", ... del_list=[5, 12, 18])
Source code in src/figaroh/calibration/base_calibration.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
initialize()
¶
Initialize calibration data and parameters.
Performs the initialization phase of calibration by: 1. Loading measurement data from files 2. Creating parameter list through base regressor analysis 3. Identifying calibratable parameters using QR decomposition
This method must be called before solve() to prepare the calibration problem. It handles data validation, parameter identification, and sets up the optimization problem structure.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If measurement data file not found |
ValueError
|
If data format is invalid or incompatible |
AssertionError
|
If required data dimensions don't match |
CalibrationError
|
If initialization fails |
Side Effects
- Populates self.PEE_measured with measurement data
- Populates self.q_measured with joint configuration data
- Updates self.calib_config["param_name"] with identified parameters
- Validates data consistency and dimensions
Example
calibrator = TiagoCalibration(robot, "config.yaml") calibrator.initialize() print(f"Loaded {calibrator.calib_config['NbSample']} samples") print(f"Calibrating {len(calibrator.calib_config['param_name'])} " ... f"parameters")
Source code in src/figaroh/calibration/base_calibration.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
solve(method='lm', max_iterations=3, outlier_threshold=None, enable_logging=True, plotting=False, save_results=False, html_report=False)
¶
Execute the complete calibration process.
This is the main entry point for calibration that: 1. Runs the optimization algorithm via solve_optimisation() 2. Optionally generates visualization plots if enabled 3. Optionally saves results to files if enabled
The method serves as a high-level orchestrator for the calibration workflow, delegating the actual optimization to solve_optimisation() and handling visualization based on user preferences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_iterations
|
Maximum number of fits; between fits, samples
whose position error exceeds |
3
|
|
outlier_threshold
|
Position error [m] above which a sample is
excluded; |
None
|
|
html_report
|
If True, also export an HTML diagnostic report
(see :meth: |
False
|
Side Effects
- Updates calibration parameters through optimization
- Sets self.STATUS to "CALIBRATED" when the solver converged
and to "FAILED" when it did not (the fit stage is then
failedand the export paths refuse, see :meth:require_exportable) - May display plots if self.calib_config["PLOT"] is True
See Also
solve_optimisation: Core optimization implementation plot: Visualization and analysis plotting export_html_report: Visual counterpart of the terminal report
Source code in src/figaroh/calibration/base_calibration.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
plot_results()
¶
Generate comprehensive visualization plots for calibration results.
Creates multiple visualization plots to analyze calibration quality: 1. Error distribution plots showing residual patterns 2. 3D pose visualizations comparing measured vs predicted poses 3. Joint configuration analysis (currently commented)
This method provides essential visual feedback for calibration assessment, helping users understand solution quality and identify potential issues with the calibration process.
Prerequisites
- Calibration must be completed (solve() called)
- Measurement data must be loaded
- Matplotlib backend must be configured
Side Effects
- Displays plots using plt.show()
- May block execution until plots are closed
See Also
plot_errors_distribution: Individual error analysis plots plot_3d_poses: 3D pose comparison visualization
Source code in src/figaroh/calibration/base_calibration.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 | |
load_param(config_file, setting_type='calibration')
¶
Load calibration parameters from YAML configuration file.
Only the unified configuration format is supported; a legacy flat
config raises an error naming figaroh.utils.config_migration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_file
|
str
|
Path to a unified configuration file |
required |
setting_type
|
str
|
Configuration section to load |
'calibration'
|
Source code in src/figaroh/calibration/base_calibration.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | |
create_param_list(q=None)
¶
Initialize calibration parameter structure and validate setup.
This method sets up the fundamental parameter structure for calibration by computing kinematic regressors and ensuring proper frame naming conventions. It serves as a critical initialization step that must be called before optimization begins.
The method performs several key operations: 1. Computes base kinematic regressors for parameter identification 2. Adds default names for unknown base and tip frames 3. Validates the parameter structure for calibration readiness
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
array_like
|
Joint configuration for regressor computation. If None, uses empty list which may limit regressor accuracy |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
Always returns True to indicate successful completion |
Side Effects
- Updates self.calib_config with frame names if not known
- Computes and caches kinematic regressors
- May modify parameter structure for calibration compatibility
Raises:
| Type | Description |
|---|---|
ValueError
|
If robot model is not properly initialized |
AttributeError
|
If required calibration parameters are missing |
CalibrationError
|
If parameter creation fails |
Example
calibrator = BaseCalibration(robot) calibrator.load_param("config.yaml") calibrator.create_param_list() # Basic setup
Or with specific joint configuration¶
q_nominal = np.zeros(robot.nq) calibrator.create_param_list(q_nominal)
See Also
calculate_base_kinematics_regressor: Core regressor computation add_base_name: Base frame naming utilities add_pee_name: End-effector frame naming utilities
Source code in src/figaroh/calibration/base_calibration.py
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | |
initial_frame_guess()
¶
Closed-form guess for the unknown base and tip frames.
See :func:estimate_frames_closed_form. Empty when the frames are
known or the measurement does not determine them (partial position
measurability, several markers, camera anchor).
Source code in src/figaroh/calibration/base_calibration.py
580 581 582 583 584 585 586 587 588 589 590 591 592 593 | |
eliminate_absorbed_parameters(tol=0.0001)
¶
Drop joint parameters that the base/tip frames absorb on this data.
The structural selection in :func:calculate_base_kinematics_regressor
uses the joint regressor alone. When the base and tip frames are also
estimated, some retained joint parameters are combinations of frame
parameters (e.g. a vertical prismatic or revolute first joint against
the base's z translation and yaw), so the problem is rank deficient.
This builds the full measurement Jacobian at the measured
configurations, with the configured measurability, evaluated at the
closed-form frame guess, and drops every joint parameter whose
unit-normalised column is a combination of the frame columns and the
joint columns kept before it (:func:select_identifiable_parameters).
Frame parameters are always kept.
Set calib_config["eliminate_absorbed_parameters"] = False to skip.
Returns:
| Name | Type | Description |
|---|---|---|
list |
List[str]
|
Names of the dropped parameters (also stored in |
List[str]
|
|
Source code in src/figaroh/calibration/base_calibration.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | |
load_data_set()
¶
Load experimental measurement data for calibration.
Reads measurement data from the specified data path and processes it for calibration use. This includes both pose measurements and corresponding joint configurations, with optional data filtering based on the deletion list.
The method handles data preprocessing, validation, and formatting to ensure compatibility with the calibration algorithms. It serves as the primary data ingestion point for the calibration process.
Side Effects
- Sets self.PEE_measured with processed pose measurements
- Sets self.q_measured with corresponding joint configurations
- Applies data filtering if self.del_list_ is specified
Prerequisites
- self._data_path must be set to valid measurement data location
- Robot model must be initialized
- Calibration parameters must be loaded
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If data files are not found at _data_path |
ValueError
|
If data format is incompatible or corrupted |
AttributeError
|
If required attributes are not initialized |
CalibrationError
|
If data loading fails |
See Also
load_data: Core data loading and processing function
Source code in src/figaroh/calibration/base_calibration.py
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 | |
get_pose_from_measure(res_)
¶
Calculate forward kinematics with calibrated parameters.
Computes robot end-effector poses using the updated kinematic model with calibrated parameters. This method applies the calibration results to predict poses for the measured joint configurations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
res_
|
ndarray
|
Calibrated parameter vector containing kinematic corrections (geometric parameters, base transform, tool transform, etc.) |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
ndarray
|
Predicted end-effector poses corresponding to the measured joint configurations. Shape depends on the number of measurements and pose representation format. |
Prerequisites
- Joint configurations must be loaded (q_measured available)
- Calibration parameters must be initialized
- Robot model must be properly configured
Example
After calibration¶
calibrated_params = calibrator.LM_result.x predicted_poses = calibrator.get_pose_from_measure( ... calibrated_params)
Compare with measured poses¶
errors = predicted_poses - calibrator.PEE_measured
See Also
calc_updated_fkm: Core forward kinematics computation function
Source code in src/figaroh/calibration/base_calibration.py
885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 | |
cost_function(var)
¶
Calculate cost function for optimization.
This method provides a default implementation but should be overridden
by derived classes to define robot-specific cost computation with
appropriate weighting. Regularise with priors
(estimation.method: map, #120), not rows appended here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
ndarray
|
Parameter vector to evaluate |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
ndarray
|
Residual vector |
Warning
Using default cost function. Consider implementing robot-specific cost function for optimal performance.
Example implementations:
Body-frame position (default, geometrically correct):
>>> raw_residuals = self._compute_logmap_residuals(
... self.PEE_measured, PEEe, position_frame="body")
World-frame position (more interpretable):
>>> raw_residuals = self._compute_logmap_residuals(
... self.PEE_measured, PEEe, position_frame="world")
Then apply weighting:
>>> weighted_residuals = self.apply_measurement_weighting(
... raw_residuals, pos_weight=1000.0, orient_weight=100.0)
Source code in src/figaroh/calibration/base_calibration.py
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 | |
apply_measurement_weighting(residuals, pos_weight=None, orient_weight=None)
¶
Apply measurement weighting to handle position/orientation units.
This utility method can be used by derived classes to properly weight position (meter) and orientation (radian) measurements for equivalent influence in the cost function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
residuals
|
ndarray
|
Raw residual vector |
required |
pos_weight
|
float
|
Weight for position residuals. If None, uses 1/position_std |
None
|
orient_weight
|
float
|
Weight for orientation residuals. If None, uses 1/orientation_std |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
ndarray
|
Weighted residual vector |
Example
In derived class cost_function:¶
raw_residuals = self._compute_logmap_residuals( ... self.PEE_measured, PEEe, ... position_frame="body") # or "world" for world-frame position weighted_residuals = self.apply_measurement_weighting( ... raw_residuals, pos_weight=1000.0, orient_weight=100.0)
Source code in src/figaroh/calibration/base_calibration.py
1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 | |
solve_optimisation(var_init=None, method='lm', max_iterations=3, outlier_threshold=None, enable_logging=False)
¶
Solve calibration optimization with robust outlier handling.
This method implements a comprehensive optimization strategy: 1. Sets up logging for progress tracking 2. Excludes samples above the outlier threshold and refits 3. Evaluates solution quality with detailed metrics 4. Stores results for further analysis
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var_init
|
ndarray
|
Initial parameter guess. If None, uses zero initialization. |
None
|
max_iterations
|
int
|
Maximum number of fits |
3
|
outlier_threshold
|
float
|
Position error [m] above
which a sample is excluded; |
None
|
enable_logging
|
bool
|
Whether to enable terminal logging |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If optimization fails completely |
AssertionError
|
If required data is not loaded |
CalibrationError
|
If optimization fails |
Side Effects
- Updates self.LM_result with optimization results
- Updates self.STATUS to "CALIBRATED" on success
- Creates self.evaluation_metrics with quality metrics
- Sets up logging if enabled
Source code in src/figaroh/calibration/base_calibration.py
1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 | |
calc_stddev(result)
¶
Calculate parameter uncertainty statistics from optimization results.
Computes standard deviation and percentage uncertainty for each calibrated parameter using the covariance matrix derived from the Jacobian at the optimal solution. This provides confidence intervals and parameter reliability metrics.
The calculation uses the linearized uncertainty propagation: σ²(θ) = σ²(residuals) * (J^T J)^-1
Where J is the Jacobian matrix and σ²(residuals) is the residual variance estimate.
Prerequisites
- Calibration optimization must be completed
- Jacobian matrix must be available from optimization
Side Effects
- Sets self.std_dev with parameter standard deviations
- Sets self.std_pctg with percentage uncertainties
Raises:
| Type | Description |
|---|---|
CalibrationError
|
If calibration has not been performed |
LinAlgError
|
If Jacobian matrix is singular or ill-conditioned |
Example
calibrator.solve() calibrator.calc_stddev() print(f"Parameter uncertainties: {calibrator.std_dev}") print(f"Percentage errors: {calibrator.std_pctg}")
Source code in src/figaroh/calibration/base_calibration.py
1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 | |
redistribute_parameters()
¶
Joint corrections with standard deviations, for export.
structuralmethod: the fitted base parameters are lifted onto every joint parameter by a weighted minimum-norm lift (:func:figaroh.calibration.estimation.lift_structural, figaroh-plus#111): among all joint corrections that reproduce the fit, the most plausible under the expected error sizes (calib_config["estimation"]["priors"], defaults inestimation.DEFAULT_PRIORS). Rows the base frame carries and rows the fit dropped are held at 0, so the lifted model predicts what the fit predicts, and the result does not depend on which representative the QR chose.std_devis conditional on that choice of lift: it propagates the fitted uncertainty and is 0 in directions the data does not see.- other methods (figaroh-plus#113): the fitted joint parameters directly; candidates left out of the fit are 0.
Tool-point and base-frame parameters are not included.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
|
dict
|
joint parameter of the calibration level. |
Raises:
| Type | Description |
|---|---|
CalibrationError
|
If |
Source code in src/figaroh/calibration/base_calibration.py
1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 | |
require_exportable(allow_failed_fit=False)
¶
Refuse to export a calibration whose fit stage failed.
The gateway of every calibration export (:meth:joint_corrections,
hence the URDF export, and export_geometric_calibration_yaml).
A failed fit records stage export as failed and raises
:class:CalibrationError. allow_failed_fit=True is the explicit
override for a diagnostic export: it logs a warning, records stage
export as fallback and notes the override in the run
provenance. A successful fit is unaffected.
Source code in src/figaroh/calibration/base_calibration.py
1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 | |
joint_corrections(lift=True, drop_unsupported=False, allow_failed_fit=False)
¶
Joint parameter values to write into a URDF (export_urdf).
lift=True: :meth:redistribute_parameters (the weighted lift
for structural; the fitted values otherwise), so the URDF and
the PAL export carry the same corrections. lift=False: the
fitted joint parameters as estimated (for structural, one
representative per dependent group and the rest at 0). Either way
the reloaded URDF, with :meth:metrology_frames applied outside
it, reproduces the calibrated forward kinematics (figaroh-plus#62).
Frame parameters are never included; see :meth:metrology_frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lift
|
bool
|
see above. |
True
|
drop_unsupported
|
bool
|
leave out fitted parameters a URDF cannot
carry (elastic |
False
|
allow_failed_fit
|
bool
|
export although the solver failed, for
diagnosis only; see :meth: |
False
|
Raises:
| Type | Description |
|---|---|
CalibrationError
|
if the |
Source code in src/figaroh/calibration/base_calibration.py
1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 | |
metrology_frames()
¶
Fitted base frame and tool point: the measurement setup.
base_* places the robot base in the measurement frame (mocap
world, camera); pEE*/phiEE* place the measured point on the
tool. They describe this setup, not the robot, so they are never in
:meth:joint_corrections and export_urdf does not write them.
To reproduce the calibrated measurements from an exported URDF,
apply them outside it, e.g. calc_updated_fkm(reloaded_model, ...,
values, q, dict(calib_config, param_name=list(frames))).
Frames given as known (known_baseframe/known_tipframe) are
not fitted and not returned.
Raises:
| Type | Description |
|---|---|
CalibrationError
|
If |
Source code in src/figaroh/calibration/base_calibration.py
2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 | |
plot_errors_distribution()
¶
Plot error distribution analysis for calibration assessment.
Creates bar plots showing pose error magnitudes across all samples and markers. This visualization helps identify problematic measurements, assess calibration quality, and detect outliers in the dataset.
The plots display error magnitudes (in meters) for each sample, with separate subplots for each marker when multiple markers are used.
Prerequisites
- Calibration must have run (STATUS "CALIBRATED", or "FAILED" to inspect a fit that did not converge)
- Error analysis must be computed (self._PEE_dist available)
Side Effects
- Creates matplotlib figure with error distribution plots
- Figure remains open until explicitly closed or plt.show() called
Raises:
| Type | Description |
|---|---|
CalibrationError
|
If calibration has not been performed |
AttributeError
|
If error analysis data is not available |
See Also
plot_3d_poses: 3D visualization of pose comparisons calc_stddev: Error statistics computation
Source code in src/figaroh/calibration/base_calibration.py
2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 | |
plot_3d_poses(INCLUDE_UNCALIB=False)
¶
Plot 3D poses comparing measured vs estimated poses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
INCLUDE_UNCALIB
|
bool
|
Whether to include uncalibrated poses |
False
|
Source code in src/figaroh/calibration/base_calibration.py
2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 | |
plot_joint_configurations()
¶
Plot joint configurations within range bounds.
Source code in src/figaroh/calibration/base_calibration.py
2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 | |
save_results(output_dir='results')
¶
Save calibration results using unified results manager.
Source code in src/figaroh/calibration/base_calibration.py
2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 | |
export_html_report(output_path=None, output_dir='results')
¶
Export the calibration quality report as a self-contained HTML
file — the visual counterpart of :meth:print_quality_report.
Renders the same metrics (convergence, per-DOF residuals,
parameter uncertainty, correlation, validation) already computed
during :meth:solve, plus an auto-generated "insights" section
flagging ill-conditioning, poorly identified parameters, and
strongly correlated pairs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
str
|
Explicit file path for the report. If omitted,
defaults to |
None
|
output_dir
|
str
|
Directory used when |
'results'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The path the report was written to. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If called before :meth: |
Source code in src/figaroh/calibration/base_calibration.py
2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 | |
verify(thresholds=None, scope='prediction')
¶
Return scoped acceptance evidence with explicit incomplete states.
scope="execution" checks finite numerical fit outputs;
it does not certify prediction, physical parameters or export.
scope="prediction" (default) additionally requires independent validation
and explicit application error limits. No universal improvement,
correlation, conditioning or prediction-error gate is imposed.
thresholds maps metric names to threshold, comparison
(min/max), and optional required (default True). Missing required
evidence produces not_evaluated, not PASS. Nonfinite evidence fails.
passed is True only when all required checks in scope pass.
Source code in src/figaroh/calibration/base_calibration.py
2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 | |
export_verification_report(output_path=None, output_dir='results', thresholds=None, scope='prediction')
¶
Write this calibration's :meth:verify verdict as JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
str
|
Explicit file path. If omitted, defaults to
|
None
|
output_dir
|
str
|
Directory used when |
'results'
|
thresholds
|
Optional[Dict[str, Dict[str, Any]]]
|
Forwarded to :meth: |
None
|
scope
|
str
|
Forwarded to :meth: |
'prediction'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The path the JSON verdict was written to. |
Source code in src/figaroh/calibration/base_calibration.py
2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 | |
print_quality_report()
¶
Print a formatted calibration quality report to the terminal.
Reports convergence, per-DOF residual statistics, validation metrics (if available), parameter uncertainty, and correlations.
Source code in src/figaroh/calibration/base_calibration.py
2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 | |
calibration_tools¶
Calibration tools and algorithms for robot kinematic calibration.
This module contains the implementation of calibration algorithms including: - Forward kinematics update functions - Levenberg-Marquardt optimization - Base regressor calculation - Data loading and processing utilities
unified_to_legacy_config(robot, unified_calib_config)
¶
Convert unified configuration format to legacy calib_config format.
Maps the unified configuration structure to the calib_config dict the
calibration classes consume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
robot
|
RobotWrapper
|
Robot instance containing model and data |
required |
unified_calib_config
|
dict
|
Configuration from create_task_config |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Calibration configuration dict ( |
Raises:
| Type | Description |
|---|---|
KeyError
|
If required fields are missing from unified config |
AssertionError
|
If frame validation fails |
Example
unified_config = create_task_config(robot, parsed_config, ... "calibration") legacy_config = unified_to_legacy_config(robot, unified_config)
Source code in src/figaroh/calibration/config.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
get_sup_joints(model, start_frame, end_frame)
¶
Get list of supporting joints between two frames in kinematic chain.
Finds all joints that contribute to relative motion between start_frame and end_frame by analyzing their support branches in the kinematic tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model |
required |
start_frame
|
str
|
Name of starting frame |
required |
end_frame
|
str
|
Name of ending frame |
required |
Returns:
| Type | Description |
|---|---|
|
list[int]: Joint IDs ordered from start to end frame, handling cases: 1. Branch entirely contained in another branch 2. Disjoint branches with fixed root 3. Partially overlapping branches |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If end frame appears before start frame in chain |
Note
Excludes "universe" joints from returned list since they don't contribute to relative motion.
Source code in src/figaroh/calibration/config.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
get_joint_offset(model, joint_names)
¶
Get dictionary of joint offset parameters.
Maps joint names to their offset parameters, handling special cases for different joint types and multiple DOF joints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Pinocchio robot model |
required | |
joint_names
|
List of joint names from model.names |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Mapping of joint offset parameter names to initial zero values. Keys have format: "{offset_type}_{joint_name}" |
Example
offsets = get_joint_offset(robot.model, robot.model.names[1:]) print(offsets["offsetRZ_joint1"]) 0.0
Source code in src/figaroh/calibration/parameter.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
get_fullparam_offset(joint_names)
¶
Get dictionary of geometric parameter variations.
Creates mapping of geometric offset parameters for each joint's position and orientation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
joint_names
|
List of joint names from robot model |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Mapping of geometric parameter names to initial zero values. Keys have format: "d_{param}_{joint_name}" where param is: - px, py, pz: Position offsets - phix, phiy, phiz: Orientation offsets |
Example
geo_params = get_fullparam_offset(robot.model.names[1:]) print(geo_params["d_px_joint1"]) 0.0
Source code in src/figaroh/calibration/parameter.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
add_base_name(calib_config)
¶
Add base frame parameters to parameter list.
Updates calib_config["param_name"] with base frame parameters depending on calibration model type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
calib_config
|
Parameter dictionary containing: - calib_model: "full_params" or "joint_offset" - param_name: List of parameter names to update |
required |
Side Effects
Modifies calib_config["param_name"] in place by: - For full_params: Replaces first 6 entries with base parameters - For joint_offset: Prepends base parameters to list
Source code in src/figaroh/calibration/parameter.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
add_pee_name(calib_config)
¶
Add end-effector marker parameters to parameter list.
Adds parameters for each active measurement DOF of each marker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
calib_config
|
Parameter dictionary containing: - NbMarkers: Number of markers - measurability: List of booleans for active DOFs - param_name: List of parameter names to update |
required |
Side Effects
Modifies calib_config["param_name"] in place by appending marker parameters in format: "{param_type}_{marker_num}"
Source code in src/figaroh/calibration/parameter.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
add_eemarker_frame(frame_name, p, rpy, model, data)
¶
Add a new frame attached to the end-effector.
Creates and adds a fixed frame to the robot model at the end-effector location, typically used for marker or tool frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame_name
|
str
|
Name for the new frame |
required |
p
|
ndarray
|
3D position offset from parent frame |
required |
rpy
|
ndarray
|
Roll-pitch-yaw angles for frame orientation |
required |
model
|
Model
|
Robot model to add frame to |
required |
data
|
Data
|
Robot data structure |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
ID of newly created frame |
Note
Currently hardcoded to attach to "arm_7_joint". This should be made configurable in future versions.
Source code in src/figaroh/calibration/parameter.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |
read_config_data(model, path_to_file)
¶
Read joint configurations from CSV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model containing joint information |
required |
path_to_file
|
str
|
Path to CSV file containing joint configurations |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
Matrix of shape (n_samples, n_joints-1) containing joint positions |
Source code in src/figaroh/calibration/data_loader.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
load_data(path_to_file, model, calib_config, del_list=[])
¶
Load joint configuration and marker data from CSV file.
Reads marker positions/orientations and joint configurations from a CSV file. Handles data validation, bad sample removal, and conversion to numpy arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_to_file
|
str
|
Path to CSV file containing recorded data |
required |
model
|
Model
|
Robot model containing joint information |
required |
calib_config
|
dict
|
Parameter dictionary containing: - NbMarkers: Number of markers to load - measurability: List indicating which DOFs are measured - actJoint_idx: List of active joint indices - config_idx: Configuration vector indices - q0: Default configuration vector |
required |
del_list
|
list
|
Indices of bad samples to remove. Defaults to []. |
[]
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Note
CSV file must contain columns: - For each marker i: [xi, yi, zi, phixi, phiyi, phizi] - Joint names matching model.names for active joints
Raises:
| Type | Description |
|---|---|
KeyError
|
If required columns are missing from CSV |
Side Effects
- Prints joint headers
- Updates calib_config["NbSample"] with number of valid samples
Source code in src/figaroh/calibration/data_loader.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
get_idxq_from_jname(model, joint_name)
¶
Get index of joint in configuration vector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model |
required |
joint_name
|
str
|
Name of joint to find index for |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
Index of joint in configuration vector q |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If joint name does not exist in model |
Source code in src/figaroh/calibration/data_loader.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
cartesian_to_SE3(X)
¶
Convert cartesian coordinates to SE3 transformation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
ndarray
|
(6,) array with [x,y,z,rx,ry,rz] coordinates |
required |
Returns:
| Type | Description |
|---|---|
|
pin.SE3: SE3 transformation with: - translation from X[0:3] - rotation matrix from RPY angles X[3:6] |
Source code in src/figaroh/calibration/calibration_tools.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
xyzquat_to_SE3(xyzquat)
¶
Convert XYZ position and quaternion orientation to SE3 transformation.
Takes a 7D vector containing XYZ position and WXYZ quaternion and creates an SE3 transformation matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xyzquat
|
ndarray
|
(7,) array containing: - xyzquat[0:3]: XYZ position coordinates - xyzquat[3:7]: WXYZ quaternion orientation |
required |
Returns:
| Type | Description |
|---|---|
|
pin.SE3: Rigid body transformation with: - Translation from XYZ position - Rotation matrix from normalized quaternion |
Example
pos_quat = np.array([0.1, 0.2, 0.3, 1.0, 0, 0, 0]) transform = xyzquat_to_SE3(pos_quat)
Source code in src/figaroh/calibration/calibration_tools.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
get_rel_transform(model, data, start_frame, end_frame)
¶
Get relative transformation between two frames.
Calculates the transform from start_frame to end_frame in the kinematic chain. Assumes forward kinematics has been updated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model |
required |
data
|
Data
|
Robot data |
required |
start_frame
|
str
|
Starting frame name |
required |
end_frame
|
str
|
Target frame name |
required |
Returns:
| Type | Description |
|---|---|
|
pin.SE3: Relative transformation sMt from start to target frame |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If frame names don't exist in model |
Source code in src/figaroh/calibration/calibration_tools.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
get_rel_kinreg(model, data, start_frame, end_frame, q, backend=None)
¶
Calculate relative kinematic regressor between frames.
Computes frame Jacobian-based regressor matrix mapping small joint displacements to spatial velocities.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model |
required |
data
|
Data
|
Robot data |
required |
start_frame
|
str
|
Starting frame name |
required |
end_frame
|
str
|
Target frame name |
required |
q
|
ndarray
|
Joint configuration vector |
required |
backend
|
DynamicsBackend
|
If provided, routes forward kinematics calls through the backend abstraction. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
(6, 6n) regressor matrix for n joints |
Source code in src/figaroh/calibration/calibration_tools.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
get_rel_jac(model, data, start_frame, end_frame, q, backend=None)
¶
Calculate relative Jacobian matrix between two frames.
Computes the difference between Jacobians of end_frame and start_frame, giving the differential mapping from joint velocities to relative spatial velocity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model |
required |
data
|
Data
|
Robot data |
required |
start_frame
|
str
|
Starting frame name |
required |
end_frame
|
str
|
Target frame name |
required |
q
|
ndarray
|
Joint configuration vector |
required |
backend
|
DynamicsBackend
|
If provided, routes forward kinematics and Jacobian calls through the backend abstraction. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
(6, n) relative Jacobian matrix where: - Rows represent [dx,dy,dz,wx,wy,wz] spatial velocities - Columns represent joint velocities - n is number of joints |
Note
Updates forward kinematics before computing Jacobians
Source code in src/figaroh/calibration/calibration_tools.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |
initialize_variables(calib_config, mode=0, seed=0)
¶
Initialize variables for Levenberg-Marquardt optimization.
Creates initial parameter vector either as zeros or random values within bounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
calib_config
|
dict
|
Parameter dictionary containing: - param_name: List of parameter names to initialize |
required |
mode
|
int
|
Initialization mode: - 0: Zero initialization - 1: Random uniform initialization. Defaults to 0. |
0
|
seed
|
float
|
Range [-seed,seed] for random init. Defaults to 0. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Example
var, n = initialize_variables(params, mode=1, seed=0.1) print(var.shape) (42,)
Source code in src/figaroh/calibration/calibration_tools.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | |
calc_updated_fkm(model, data, var, q, calib_config, verbose=0, backend=None)
¶
Update forward kinematics with world frame transformations.
Single, unified FK-update function for calibration: composes the full chain of transformations::
wMf = wMo * oMee * eeMf
where
wMo: world (measurement) frame to the kinematic chain's start frame. Estimated directly whenBASE_TPLparams are present inparam_name(unknown base frame, e.g.known_baseframe=False), estimated via a known camera/ref-frame anchor whencalib_config["base_to_ref_frame"]/"ref_frame"are set (e.g. eye-hand calibration), or identity otherwise.oMee: start frame to end frame, through the updated kinematic chain (full_params/joint_offsetgeometric error parameters), optionally including joint elasticity whencalib_config["non_geom"]is set — a per-joint compliance parameter (ELAS_TPL) that adds a gravity-torque-proportional deflection about that joint's own motion axis, then reverts it, on every sample.eeMf: end frame to the measured marker frame (EE_TPLparams), or identity if not estimated. With several markers (NbMarkers> 1, e.g. the points of one rigid body), each markerkhas its owneeMf_k(pEEx_k...phiEEz_k) on the same tool frame, and its rows follow markerk - 1's (figaroh-plus#119).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model to update |
required |
data
|
Data
|
Robot data |
required |
var
|
ndarray
|
Parameter vector matching calib_config["param_name"] |
required |
q
|
ndarray
|
Joint configurations matrix (n_samples, n_joints) |
required |
calib_config
|
dict
|
Calibration parameters containing: - calib_model: "full_params" or "joint_offset" - start_frame, end_frame: Frame names - base_to_ref_frame, ref_frame: Optional camera-style known chain anchor (eye-hand calibration); None to disable - non_geom: Whether to apply joint elasticity - actJoint_idx: Active joint indices - measurability: Active DOFs - NbMarkers: Number of markers on the tool frame |
required |
verbose
|
int
|
Print update info. Defaults to 0. |
0
|
backend
|
DynamicsBackend
|
If provided, routes forward kinematics and gravity calls through the backend abstraction. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
Flattened marker measurements in world frame, ordered |
|
|
marker, then measured component, then sample (as |
Notes
- Requires base or end-effector parameters in param_name to estimate wMo / eeMf; otherwise they default to identity.
- Validates all parameters in param_name are consumed exactly once.
Source code in src/figaroh/calibration/calibration_tools.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | |
update_joint_placement(model, joint_idx, xyz_rpy)
¶
Apply a full_params placement error in the joint frame.
M <- M * SE3(exp3(xyz_rpy[3:6]), xyz_rpy[0:3]): the translation is
expressed in the joint frame and the rotation is a rotation vector. This
is the convention of Pinocchio's kinematic regressor
(computeFrameKinematicRegressor(..., LOCAL)), from which the base
parameters and the base-mapping matrix are derived, so the fitted model
has exactly the dependencies that selection assumed (figaroh-plus#110).
Earlier versions added the translation in the parent frame and the
rotation to the placement's RPY angles, which disagrees with the
regressor wherever the nominal placement is rotated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model to modify |
required |
joint_idx
|
int
|
Index of joint to update |
required |
xyz_rpy
|
ndarray
|
(6,) |
required |
Returns:
| Type | Description |
|---|---|
|
pin.Model: Updated robot model |
Side Effects
Modifies model.jointPlacements[joint_idx] in place
Source code in src/figaroh/calibration/calibration_tools.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | |
apply_joint_offset(model, joint_idx, offset)
¶
Offset a joint about its own axes (joint-angle / joint-position offset).
Composes the offset on the child side of the joint placement,
M <- M * SE3(R(offset[3:6]), offset[0:3]), so that it is expressed in
the joint frame. For a revolute joint about z, offset[5] = d is then
exactly the configuration q + d; for a prismatic joint along x,
offset[0] = d is q + d. This is the meaning of the
offset{PX,PY,PZ,RX,RY,RZ}_<joint> parameters (JOINT_OFFSETTPL,
axis taken from the joint's shortname()) and of the elastic
deflections (ELAS_TPL).
:func:update_joint_placement composes on the same side for the
full_params (d_p*, d_phi*) placement errors, with all three
rotation components as one rotation vector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model to modify |
required |
joint_idx
|
int
|
Index of joint to update |
required |
offset
|
ndarray
|
(6,) translation (x, y, z) and rotation (roll, pitch, yaw) offsets, expressed in the joint frame |
required |
Returns:
| Type | Description |
|---|---|
|
pin.Model: Updated robot model |
Side Effects
Modifies model.jointPlacements[joint_idx] in place
Source code in src/figaroh/calibration/calibration_tools.py
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | |
calculate_kinematics_model(q_i, model, data, calib_config, backend=None)
¶
Calculate Jacobian and kinematic regressor for single configuration.
Computes frame Jacobian and kinematic regressor matrices for tool frame at given joint configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q_i
|
ndarray
|
Joint configuration vector |
required |
model
|
Model
|
Robot model |
required |
data
|
Data
|
Robot data |
required |
calib_config
|
dict
|
Parameters containing "IDX_TOOL" frame index |
required |
backend
|
DynamicsBackend
|
If provided, routes forward kinematics and Jacobian calls through the backend abstraction. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Source code in src/figaroh/calibration/calibration_tools.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | |
calculate_identifiable_kinematics_model(q, model, data, calib_config, backend=None)
¶
Calculate identifiable Jacobian and regressor matrices.
Builds aggregated Jacobian and regressor matrices from either: 1. Given set of configurations, or 2. Random configurations if none provided
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
ndarray
|
Joint configurations matrix. If empty, uses random configs. |
required |
model
|
Model
|
Robot model |
required |
data
|
Data
|
Robot data |
required |
calib_config
|
dict
|
Parameters containing: - NbSample: Number of configurations - calibration_index: Number of active DOFs - start_frame, end_frame: Frame names - calib_model: Model type |
required |
backend
|
DynamicsBackend
|
If provided, routes random configuration and forwards backend to called functions. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
Either: - Joint offset case: Frame Jacobian matrix - Full params case: Kinematic regressor matrix |
Note
Removes rows corresponding to inactive DOFs and zero elements
Source code in src/figaroh/calibration/calibration_tools.py
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | |
calculate_base_kinematics_regressor(q, model, data, calib_config, tol_qr=TOL_QR, backend=None)
¶
Calculate base regressor matrix for calibration parameters.
Identifies base (identifiable) parameters by: 1. Computing regressors with random/given configurations 2. Eliminating unidentifiable parameters 3. Finding independent regressor columns
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
ndarray
|
Joint configurations matrix |
required |
model
|
Model
|
Robot model |
required |
data
|
Data
|
Robot data |
required |
calib_config
|
dict
|
Contains calibration settings: - free_flyer: Whether base is floating - calib_model: Either "joint_offset" or "full_params" |
required |
tol_qr
|
float
|
QR decomposition tolerance. Defaults to TOL_QR. |
TOL_QR
|
backend
|
DynamicsBackend
|
If provided, forwards backend to called functions for backend-aware computation. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Side Effects
- Updates calib_config["param_name"] with identified base parameters
- Prints regressor matrix shapes
Source code in src/figaroh/calibration/calibration_tools.py
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 | |
random_joint_configuration(model, rng)
¶
Draw a configuration uniformly within joint limits from rng.
One-DoF joints are drawn within their position limits, or within
[-pi, pi] when the limits are missing or wider than a turn; other joints
stay at the neutral configuration. Unlike pin.randomConfiguration,
the draw depends only on rng, not on Pinocchio's global generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model |
required |
rng
|
Generator
|
Random generator |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
(nq,) configuration |
Source code in src/figaroh/calibration/calibration_tools.py
889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 | |
estimate_frames_closed_form(model, data, q, PEE, calib_config, n_iter=50)
¶
Closed-form initial guess for the unknown base and tip frames.
With nominal joint parameters, the measured marker satisfies
P_i = R_b (p_i + R_i t_tip) + t_b (and R_meas_i = R_b R_i R_tip
when orientation is measured), where (R_i, p_i) is the nominal
start-to-end frame transform. Rotations are estimated by Kabsch
(positions) or chordal averaging (orientations), alternated with a linear
least-squares solve for t_b and t_tip.
With several markers (NbMarkers > 1, points of one rigid body,
figaroh-plus#119), each has its own t_tip_k and the base frame is
fitted to all of them; orientations, if measured, are not used then and
tip rotations are guessed as zero.
Only applies to markers whose position is fully measured, with the
base frame estimated directly (base_* parameters, no camera
base_to_ref_frame anchor). Otherwise returns an empty dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model (nominal joint placements) |
required |
data
|
Data
|
Robot data |
required |
q
|
ndarray
|
(NbSample, nq) joint configurations |
required |
PEE
|
ndarray
|
Flattened DOF-major measurements, as from |
required |
calib_config
|
dict
|
Calibration configuration |
required |
n_iter
|
int
|
Alternation iterations |
50
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Initial values keyed by the |
|
|
names present in |
Source code in src/figaroh/calibration/calibration_tools.py
931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 | |
measurement_jacobian(model, data, var, q, calib_config, step=1e-06)
¶
Central-difference Jacobian of calc_updated_fkm w.r.t. var.
Rows follow the flattened, DOF-major measurement vector; columns follow
calib_config["param_name"].
Source code in src/figaroh/calibration/calibration_tools.py
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 | |
select_identifiable_parameters(jacobian, names, always_keep=(), tol=0.0001)
¶
Split parameters into identifiable and absorbed ones, deterministically.
Columns are normalised to unit length (so units do not matter) and taken
in order: first always_keep (e.g. base and tip frames), then the rest
of names in order. A column is kept when its component orthogonal to
the columns already kept exceeds tol; otherwise it is a combination of
them and is reported as absorbed. always_keep columns are never
dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jacobian
|
ndarray
|
(n_meas, n_params) measurement Jacobian |
required |
names
|
list
|
Parameter names, one per column |
required |
always_keep
|
iterable
|
Names kept unconditionally and tested first |
()
|
tol
|
float
|
Threshold on the orthogonal residual of a unit column. Exact dependencies give ~1e-10 (finite-difference noise); the default 1e-4 also drops near-dependencies whose column alone would have a condition number above 1e4 (a direction the data barely excites). |
0.0001
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
(kept names in original order, absorbed names in original order) |
Source code in src/figaroh/calibration/calibration_tools.py
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 | |
drop_calibration_parameters(calib_config, dropped)
¶
Remove parameters from param_name, keeping the base mapping aligned.
A dropped name inside base_mapping_slice also loses its row of
base_mapping_matrix / base_mapping_row_names; names before the
slice shift it left.
Source code in src/figaroh/calibration/calibration_tools.py
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 | |
estimation¶
Parameter selection and estimation methods; see Calibration estimation methods.
Choosing which calibration parameters to estimate, and how (#113).
calib_config["estimation"]["method"] selects one of:
structural (default)
The structural base parameters from random configurations, then the
data-level elimination of frame-absorbed parameters (#102). Unchanged
behaviour.
excitation
Start from every joint parameter of the calibration level, drop exact
dependencies on the measured postures, then remove, one at a time, the
parameter whose predicted standard error is largest relative to its
expected size, while that ratio exceeds excitation_k. Kept
parameters are estimated freely.
map
Estimate every joint parameter with a zero-mean Gaussian prior of the
given expected sizes (priors). Weakly excited directions stay near
nominal; nothing is dropped.
map_cv
map with the prior sizes scaled by a factor chosen by k-fold
cross-validation over the training postures (optionally one factor per
parameter group). Needs no robot-specific sizes.
cv_subset
Nested parameter sets in the excitation removal order; the set size
is chosen by k-fold cross-validation over the training postures.
The base and tool frames are always estimated freely (no prior). Noise is
noise_std in the units of the cost function's measurement residuals
(metres for position unless the robot's cost function weights them), or,
when None, estimated from a free fit of the identifiable parameters.
Selection runs once, in :meth:BaseCalibration.create_param_list; the
choices and diagnostics are stored in calib_config["estimation_report"].
See the guide docs/source/concepts/calibration_estimation.md.
EstimationError
¶
Bases: ValueError
Invalid estimation settings or data for the chosen method.
settings(calib_config)
¶
calib_config["estimation"] merged over :data:DEFAULTS.
Source code in src/figaroh/calibration/estimation.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
joint_candidates(model, calib_config)
¶
Every joint parameter of the calibration level, in joint order.
Source code in src/figaroh/calibration/estimation.py
122 123 124 125 126 127 128 129 | |
prior_group(name, model)
¶
Prior group of a parameter name; None for frame parameters.
Source code in src/figaroh/calibration/estimation.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
prior_std(names, model, priors)
¶
Expected size per parameter; inf for frame parameters.
Source code in src/figaroh/calibration/estimation.py
160 161 162 163 164 165 166 | |
identifiable(calib, names, frames, tol)
¶
Drop exact dependencies on the measured postures (frames kept).
Source code in src/figaroh/calibration/estimation.py
246 247 248 249 250 251 252 253 254 | |
excitation_order(J, names, frames, prior, noise, k=None)
¶
Backward elimination by predicted standard error / expected size.
Returns (kept, removed in order, ratio at removal). With k None the
elimination runs until only frames remain.
Source code in src/figaroh/calibration/estimation.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
configure(calib)
¶
Set param_name and prior weights for a non-structural method.
Source code in src/figaroh/calibration/estimation.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
lift_structural(calib, priors=None, refine_iterations=3)
¶
Weighted minimum-norm lift of fitted base parameters to joint corrections.
The structural method estimates one representative per group of
dependent joint parameters; which one is a numerical accident. Among all
joint corrections that reproduce the fit, return the most plausible
under the expected sizes priors (default: the estimation priors):
theta = argmin theta' P^-1 theta subject to M_full theta = t
M_full is the base mapping before any row was dropped; t holds
the fitted value of every kept joint row, and 0 on the rows the base
frame carries (base_frame_row_names) and on the rows the fit
dropped (held at 0). The result does not depend on which
representatives were chosen.
M is a first-order (structural) map, so with corrections of tens of
mrad the lifted model drifts from the fit by up to ~0.1 mm. When the
measured postures are available, refine_iterations Gauss-Newton
steps then make the lifted model reproduce the fitted predictions at
those postures, each step taking the smallest correction in the same
prior-weighted norm.
Returns:
| Type | Description |
|---|---|
(names, theta, cov)
|
joint parameter names |
|
( |
|
|
conditional on this lift (propagated from the fitted base |
|
|
parameters; directions the data does not see have zero variance |
|
|
here, not their prior). |
Source code in src/figaroh/calibration/estimation.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
config¶
Configuration parsing and parameter management for robot calibration.
This module handles all configuration-related functionality including: - YAML configuration file parsing - Unified to legacy config format conversion - Parameter extraction and validation - Frame and joint configuration management
regularization_coefficient(value)
¶
coeff_regularize from a config value; a non-zero value is an error.
The coefficient weighted sqrt(c) * theta rows that robot cost
functions appended for every joint parameter, so a metre and a radian
were penalised alike (#120). It was deprecated in 0.6.0 and removed in
1.0: estimation.method: map replaces it with priors of physical size
per parameter group. Zero or absent is accepted and passed through.
Raises:
| Type | Description |
|---|---|
ConfigurationError
|
|
Source code in src/figaroh/calibration/config.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
get_sup_joints(model, start_frame, end_frame)
¶
Get list of supporting joints between two frames in kinematic chain.
Finds all joints that contribute to relative motion between start_frame and end_frame by analyzing their support branches in the kinematic tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model |
required |
start_frame
|
str
|
Name of starting frame |
required |
end_frame
|
str
|
Name of ending frame |
required |
Returns:
| Type | Description |
|---|---|
|
list[int]: Joint IDs ordered from start to end frame, handling cases: 1. Branch entirely contained in another branch 2. Disjoint branches with fixed root 3. Partially overlapping branches |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If end frame appears before start frame in chain |
Note
Excludes "universe" joints from returned list since they don't contribute to relative motion.
Source code in src/figaroh/calibration/config.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
unified_to_legacy_config(robot, unified_calib_config)
¶
Convert unified configuration format to legacy calib_config format.
Maps the unified configuration structure to the calib_config dict the
calibration classes consume.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
robot
|
RobotWrapper
|
Robot instance containing model and data |
required |
unified_calib_config
|
dict
|
Configuration from create_task_config |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Calibration configuration dict ( |
Raises:
| Type | Description |
|---|---|
KeyError
|
If required fields are missing from unified config |
AssertionError
|
If frame validation fails |
Example
unified_config = create_task_config(robot, parsed_config, ... "calibration") legacy_config = unified_to_legacy_config(robot, unified_config)
Source code in src/figaroh/calibration/config.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
parameter¶
Parameter management utilities for robot calibration.
This module contains functions for creating and managing calibration parameter dictionaries, including: - Joint offset parameters - Geometric parameter offsets - Base frame parameters - End-effector marker parameters - Frame management utilities
get_joint_offset(model, joint_names)
¶
Get dictionary of joint offset parameters.
Maps joint names to their offset parameters, handling special cases for different joint types and multiple DOF joints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Pinocchio robot model |
required | |
joint_names
|
List of joint names from model.names |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Mapping of joint offset parameter names to initial zero values. Keys have format: "{offset_type}_{joint_name}" |
Example
offsets = get_joint_offset(robot.model, robot.model.names[1:]) print(offsets["offsetRZ_joint1"]) 0.0
Source code in src/figaroh/calibration/parameter.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
get_fullparam_offset(joint_names)
¶
Get dictionary of geometric parameter variations.
Creates mapping of geometric offset parameters for each joint's position and orientation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
joint_names
|
List of joint names from robot model |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Mapping of geometric parameter names to initial zero values. Keys have format: "d_{param}_{joint_name}" where param is: - px, py, pz: Position offsets - phix, phiy, phiz: Orientation offsets |
Example
geo_params = get_fullparam_offset(robot.model.names[1:]) print(geo_params["d_px_joint1"]) 0.0
Source code in src/figaroh/calibration/parameter.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
add_base_name(calib_config)
¶
Add base frame parameters to parameter list.
Updates calib_config["param_name"] with base frame parameters depending on calibration model type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
calib_config
|
Parameter dictionary containing: - calib_model: "full_params" or "joint_offset" - param_name: List of parameter names to update |
required |
Side Effects
Modifies calib_config["param_name"] in place by: - For full_params: Replaces first 6 entries with base parameters - For joint_offset: Prepends base parameters to list
Source code in src/figaroh/calibration/parameter.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
add_pee_name(calib_config)
¶
Add end-effector marker parameters to parameter list.
Adds parameters for each active measurement DOF of each marker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
calib_config
|
Parameter dictionary containing: - NbMarkers: Number of markers - measurability: List of booleans for active DOFs - param_name: List of parameter names to update |
required |
Side Effects
Modifies calib_config["param_name"] in place by appending marker parameters in format: "{param_type}_{marker_num}"
Source code in src/figaroh/calibration/parameter.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
add_eemarker_frame(frame_name, p, rpy, model, data)
¶
Add a new frame attached to the end-effector.
Creates and adds a fixed frame to the robot model at the end-effector location, typically used for marker or tool frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame_name
|
str
|
Name for the new frame |
required |
p
|
ndarray
|
3D position offset from parent frame |
required |
rpy
|
ndarray
|
Roll-pitch-yaw angles for frame orientation |
required |
model
|
Model
|
Robot model to add frame to |
required |
data
|
Data
|
Robot data structure |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
ID of newly created frame |
Note
Currently hardcoded to attach to "arm_7_joint". This should be made configurable in future versions.
Source code in src/figaroh/calibration/parameter.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |
data_loader¶
Data loading and processing utilities for robot calibration.
This module provides functions for loading and processing calibration data from various file formats, including: - CSV file reading for joint configurations - Marker position/orientation data loading - Data validation and cleanup - Configuration vector management
get_idxq_from_jname(model, joint_name)
¶
Get index of joint in configuration vector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model |
required |
joint_name
|
str
|
Name of joint to find index for |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
Index of joint in configuration vector q |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If joint name does not exist in model |
Source code in src/figaroh/calibration/data_loader.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
read_config_data(model, path_to_file)
¶
Read joint configurations from CSV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Model
|
Robot model containing joint information |
required |
path_to_file
|
str
|
Path to CSV file containing joint configurations |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ndarray |
Matrix of shape (n_samples, n_joints-1) containing joint positions |
Source code in src/figaroh/calibration/data_loader.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
load_data(path_to_file, model, calib_config, del_list=[])
¶
Load joint configuration and marker data from CSV file.
Reads marker positions/orientations and joint configurations from a CSV file. Handles data validation, bad sample removal, and conversion to numpy arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_to_file
|
str
|
Path to CSV file containing recorded data |
required |
model
|
Model
|
Robot model containing joint information |
required |
calib_config
|
dict
|
Parameter dictionary containing: - NbMarkers: Number of markers to load - measurability: List indicating which DOFs are measured - actJoint_idx: List of active joint indices - config_idx: Configuration vector indices - q0: Default configuration vector |
required |
del_list
|
list
|
Indices of bad samples to remove. Defaults to []. |
[]
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
|
Note
CSV file must contain columns: - For each marker i: [xi, yi, zi, phixi, phiyi, phizi] - Joint names matching model.names for active joints
Raises:
| Type | Description |
|---|---|
KeyError
|
If required columns are missing from CSV |
Side Effects
- Prints joint headers
- Updates calib_config["NbSample"] with number of valid samples
Source code in src/figaroh/calibration/data_loader.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |