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
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 185 | |
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
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 212 213 214 215 216 217 218 219 220 221 222 223 | |
solve(method='lm', max_iterations=3, outlier_threshold=3.0, 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 |
|---|---|---|---|
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" on successful completion
- 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
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 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 289 290 291 292 293 294 295 296 297 | |
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
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 | |
load_param(config_file, setting_type='calibration')
¶
Load calibration parameters from YAML configuration file.
This method supports both legacy YAML format and the new unified configuration format. It automatically detects the format type and applies the appropriate parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_file
|
str
|
Path to configuration file (legacy or unified) |
required |
setting_type
|
str
|
Configuration section to load |
'calibration'
|
Source code in src/figaroh/calibration/base_calibration.py
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 | |
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
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 | |
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
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 | |
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
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 | |
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 and regularization.
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 and regularization:
>>> 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
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 | |
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
871 872 873 874 875 876 877 878 879 880 881 882 883 884 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 921 922 923 924 925 926 927 928 929 | |
solve_optimisation(var_init=None, method='lm', max_iterations=3, outlier_threshold=3.0, 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. Iteratively removes outliers and re-optimizes 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 outlier removal iterations |
3
|
outlier_threshold
|
float
|
Outlier detection threshold (std devs) |
3.0
|
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
1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 | |
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
1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 | |
redistribute_parameters()
¶
Minimum-norm redistribution of fitted base-parameter values (and their covariance) onto the full standard-parameter set.
create_param_list()'s QR reduction keeps only a maximal
linearly-independent subset of the 6-per-joint candidate
parameters (the "base" parameters actually solved for); every
other candidate is an exact linear combination of that subset and
is implicitly left at its nominal value (0) when only
calib_config["param_name"] is deployed. This method instead
spreads each fitted base-parameter value across its full
redundant group via the Moore-Penrose pseudoinverse of the
base-mapping matrix M (phi_base = M @ theta_r), plus the
corresponding covariance propagation — see
:func:figaroh.tools.qrdecomposition.redistribute_min_norm /
:func:~figaroh.tools.qrdecomposition.propagate_covariance_min_norm.
This does not change what the model predicts (the redistributed
vector round-trips exactly through M back to the original fitted
base values) — only how the identified correction is distributed
across individual joint parameters. It does not add information:
non-identifiable directions remain non-identifiable, and the
reported std_dev for a redistributed parameter reflects the
minimum-norm estimator's own sensitivity, not an unconditional
physical uncertainty. See TIAGO_CALIBRATION_ANALYSIS.md §8 for
the full discussion and literature context.
Only covers parameters that went through the
eliminate_non_dynaffect/QR reduction (per-joint DH offsets);
marker/tip parameters added afterward by add_pee_name are
already individually free-standing (not part of a redundant
group) and are not included here.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
|
dict
|
standard parameter in |
|
dict
|
|
|
dict
|
superset of |
Raises:
| Type | Description |
|---|---|
CalibrationError
|
If |
Source code in src/figaroh/calibration/base_calibration.py
1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 | |
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 be completed (STATUS == "CALIBRATED")
- 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
1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 | |
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
1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 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 | |
plot_joint_configurations()
¶
Plot joint configurations within range bounds.
Source code in src/figaroh/calibration/base_calibration.py
1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 | |
save_results(output_dir='results')
¶
Save calibration results using unified results manager.
Source code in src/figaroh/calibration/base_calibration.py
1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 | |
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
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 | |
verify(thresholds=None)
¶
Check this calibration's metrics against pass/fail thresholds.
Unlike :meth:print_quality_report/:meth:export_html_report
(for a human to read), this returns a machine-checkable
:class:~figaroh.tools._report_common.VerificationVerdict a CI
script can branch on. Computed entirely from data already
gathered during :meth:solve — never raises after a successful
solve, and never gates solve() itself (opt-in, called
whenever the caller wants a verdict).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
thresholds
|
Optional[Dict[str, Dict[str, Any]]]
|
Per-metric |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
VerificationVerdict |
|
|
|
raw |
||
|
text used by :meth: |
||
|
(git commit, config file hash, timestamp, robot name). |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If called before :meth: |
Source code in src/figaroh/calibration/base_calibration.py
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 1873 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 | |
export_verification_report(output_path=None, output_dir='results', thresholds=None)
¶
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
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The path the JSON verdict was written to. |
Source code in src/figaroh/calibration/base_calibration.py
1937 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 | |
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
1978 1979 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 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 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 2121 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 | |
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
get_param_from_yaml(robot, calib_data)
¶
Parse calibration parameters from YAML configuration file.
Processes robot and calibration data to build a parameter dictionary containing all necessary settings for robot calibration. Handles configuration of: - Frame identifiers and relationships - Marker/measurement settings - Joint indices and configurations - Non-geometric parameters - Eye-hand calibration setup
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
robot
|
RobotWrapper
|
Robot instance containing model and data |
required |
calib_data
|
dict
|
Calibration parameters parsed from YAML file containing: - markers: List of marker configurations - calib_level: Calibration model type - base_frame: Starting frame name - tool_frame: End frame name - free_flyer: Whether base is floating - non_geom: Whether to include non-geometric params |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Parameter dictionary containing: - robot_name: Name of robot model - NbMarkers: Number of markers - measurability: Measurement DOFs per marker - start_frame, end_frame: Frame names - base_to_ref_frame: Optional camera frame - IDX_TOOL: Tool frame index - actJoint_idx: Active joint indices - param_name: List of parameter names - Additional settings from YAML |
Side Effects
Prints warning messages if optional frames undefined Prints final parameter dictionary
Example
calib_data = yaml.safe_load(config_file) params = get_param_from_yaml(robot, calib_data) print(params['NbMarkers']) 2
Source code in src/figaroh/calibration/config.py
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 177 178 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 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 251 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 289 290 | |
unified_to_legacy_config(robot, unified_calib_config)
¶
Convert unified configuration format to legacy calib_config format.
Maps the new unified configuration structure to the exact format expected by get_param_from_yaml. This ensures backward compatibility while using the new unified parser.
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
|
Legacy format calibration configuration matching get_param_from_yaml output |
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
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 | |
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
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 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 | |
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 | |
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
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
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
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 | |
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 | |
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
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
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
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 | |
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
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 | |
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
176 177 178 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 | |
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
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 251 | |
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
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 | |
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.
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: Must be 1 (multi-marker is not supported) |
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 |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If calib_config["NbMarkers"] > 1. |
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
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 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 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | |
update_joint_placement(model, joint_idx, xyz_rpy)
¶
Update joint placement with offset parameters.
Modifies a joint's placement transform by adding position and orientation offsets.
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,) array of offsets: - xyz_rpy[0:3]: Translation offsets (x,y,z) - xyz_rpy[3:6]: Rotation offsets (roll,pitch,yaw) |
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
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | |
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
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 635 636 637 638 639 640 | |
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
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 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 | |
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
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 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 | |
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
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
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 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 | |
get_param_from_yaml(robot, calib_data)
¶
Parse calibration parameters from YAML configuration file.
Processes robot and calibration data to build a parameter dictionary containing all necessary settings for robot calibration. Handles configuration of: - Frame identifiers and relationships - Marker/measurement settings - Joint indices and configurations - Non-geometric parameters - Eye-hand calibration setup
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
robot
|
RobotWrapper
|
Robot instance containing model and data |
required |
calib_data
|
dict
|
Calibration parameters parsed from YAML file containing: - markers: List of marker configurations - calib_level: Calibration model type - base_frame: Starting frame name - tool_frame: End frame name - free_flyer: Whether base is floating - non_geom: Whether to include non-geometric params |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Parameter dictionary containing: - robot_name: Name of robot model - NbMarkers: Number of markers - measurability: Measurement DOFs per marker - start_frame, end_frame: Frame names - base_to_ref_frame: Optional camera frame - IDX_TOOL: Tool frame index - actJoint_idx: Active joint indices - param_name: List of parameter names - Additional settings from YAML |
Side Effects
Prints warning messages if optional frames undefined Prints final parameter dictionary
Example
calib_data = yaml.safe_load(config_file) params = get_param_from_yaml(robot, calib_data) print(params['NbMarkers']) 2
Source code in src/figaroh/calibration/config.py
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 177 178 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 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 251 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 289 290 | |
unified_to_legacy_config(robot, unified_calib_config)
¶
Convert unified configuration format to legacy calib_config format.
Maps the new unified configuration structure to the exact format expected by get_param_from_yaml. This ensures backward compatibility while using the new unified parser.
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
|
Legacy format calibration configuration matching get_param_from_yaml output |
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
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 | |
get_param_from_yaml_legacy(robot, calib_data)
¶
Legacy calibration parameter parser - kept for backward compatibility.
This is the original implementation. New code should use the unified config parser from figaroh.utils.config_parser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
robot
|
Robot instance |
required | |
calib_data
|
Calibration data dictionary |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Calibration configuration dictionary |
Source code in src/figaroh/calibration/config.py
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | |
get_param_from_yaml_unified(robot, calib_data)
¶
Enhanced parameter parser using unified configuration system.
This function provides backward compatibility while using the new unified configuration parser when possible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
robot
|
Robot instance |
required | |
calib_data
|
Configuration data (dict or file path) |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Calibration configuration dictionary |
Source code in src/figaroh/calibration/config.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | |
get_param_from_yaml_with_warning(robot, calib_data)
¶
Original function with deprecation notice.
Source code in src/figaroh/calibration/config.py
644 645 646 647 648 649 650 651 652 653 654 655 | |
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 | |
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
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | |
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
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 | |
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 | |