TriPed-Robot / trip_kinematics

Python package for inverse kinematic calculations of hybrid serial parallel robots
https://trip-kinematics.readthedocs.io/en/main/
MIT License
28 stars 5 forks source link

More helpfull error messages #7

Closed liquidcronos closed 3 years ago

liquidcronos commented 3 years ago

There are a number of error messages which could be more helpfull in providing guidance. These include:

class TransformationParameters():
    def get_convention(state: Dict[str, float]):

Which should return a list of available keys, if invalid keys are used in its initialisation

class TransformationParameters():
    def __init__(self, values: Dict[str, float], state_variables: List[str] = []):
        if not set(state_variables) <= set(values.keys()):
            raise ValueError("Key(s) from stateVariables not present inside values")

Which does not accuately describe the underlying problem, and moreover WHY they need to be present.

class KinematicGroup():

    def __init__(self, virtual_transformations: List[TransformationParameters], actuated_state: Dict[str, float] = None, f_mapping: Callable = None, g_mapping: Callable = None, f_args=None, g_args=None, parent=None):
        if not ((actuated_state and f_mapping and g_mapping) or not (actuated_state and f_mapping and g_mapping)):
            raise ValueError(
                "For actuated states a forward and an inverse mapping are required.")

The error message should clarify how a mapping would look like ifthe actuated state is not part of a closed chain.

class KinematicGroup():

    def __init__(self, virtual_transformations: List[TransformationParameters], actuated_state: Dict[str, float] = None, f_mapping: Callable = None, g_mapping: Callable = None, f_args=None, g_args=None, parent=None):
            if KinematicGroup.virtual_state_to_keys(f_mapping_to_check) != KinematicGroup.virtual_state_to_keys(virtual_state):
                raise RuntimeError("f_mapping does not fit virtual state")")
            if g_mapping_to_check.keys() != actuated_state.keys():
                raise RuntimeError("g_mapping does not fit actuated state")

The error messages should clarify what that means and how both mappings are supposed to work

liquidcronos commented 3 years ago

resolved due to restructuring of code