File size: 2,002 Bytes
5f38e95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Exception types raised by the framework.

These live in a single module so that callers can ``except`` on a clean public
surface without importing the modules that raise them.
"""

from __future__ import annotations


class CdprError(Exception):
    """Base class for all framework-specific exceptions."""


class ConfigurationError(CdprError):
    """Raised when a robot configuration is inconsistent or under-specified."""


class SingularConfiguration(CdprError):
    """Raised when a kinematic analysis hits a structurally singular pose.

    The diagnostic information attached as ``self.condition_number`` (when
    available) lets callers decide whether to retry with a regularised solver
    or to report a workspace boundary.
    """

    def __init__(self, message: str, *, condition_number: float | None = None) -> None:
        super().__init__(message)
        self.condition_number = condition_number


class InfeasibleTensionError(CdprError):
    """Raised when no tension distribution satisfies cable bounds and equilibrium.

    Attributes
    ----------
    residual:
        Norm of the unsatisfied equilibrium residual at the best-effort
        solution, if any was produced.
    """

    def __init__(self, message: str, *, residual: float | None = None) -> None:
        super().__init__(message)
        self.residual = residual


class MissingAdapterDependency(CdprError):
    """Raised when an optional simulator backend is requested but not installed.

    The framework keeps the scientific core decoupled from any specific
    simulator; adapters are imported lazily and raise this exception with an
    actionable install hint instead of failing on a bare ``ImportError``.
    """

    def __init__(self, backend: str, install_hint: str) -> None:
        super().__init__(
            f"Adapter for backend {backend!r} is not available. "
            f"Install it with:  {install_hint}"
        )
        self.backend = backend
        self.install_hint = install_hint