Skip to content
Simon Reichel edited this page Apr 4, 2019 · 3 revisions

Model Validation

Important note: This functionality has been disabled for Phobos 1.0.

The internal dictionary Phobos creates to process a Blender model can become quite large, just as the models themselves can become quite complicated. To avoid errors and simplify building models, we have introduced a way to check models for validity before exporting them to URDF or SMURF. Since SMURF as an output format is very generic and we wanted to maintain this flexibility in Blender, it is possible for the user to extend the functionality we have implemented, which is why we introduced a flexible way to define what exactly makes a model valid using YAML files read by Phobos. The following defines the default document as of Phobos 0.6:

DictConstraints:
    sensors:
        $forElem:
            type:
                required: true
                default: 'CameraSensor'
            $selection__type: {} #will be generated by Phobos
    geometry:
        isReference: true
        type:
            required: true
            default: 'box'
        $selection__type:
            box:
                size:
                    required: true
                    default: [1.0, 1.0, 1.0]
            sphere:
                radius:
                    required: true
                    default: 1.0
            cylinder:
                radius:
                    required: true
                    default: 1.0
                length:
                    required: true
                    default: 1.0
            plane:
                size:
                    required: true
                    default: [1.0, 1.0]
            mesh:
                filename:
                    required: true
                    default: 'meshFileName'
    pose:
        isReference: true
        matrix:
            required: true
            default:
                - [0.0, 0.0, 0.0, 0.0]
                - [0.0, 0.0, 0.0, 0.0]
                - [0.0, 0.0, 0.0, 0.0]
                - [0.0, 0.0, 0.0, 0.0]
        rotation_euler:
            required: true
            default: [0.0, 0.0, 0.0]
        rotation_quaternion:
            required: true
            default: [0.0, 0.0, 0.0]
        translation:
            required: true
            default: [0.0, 0.0, 0.0]
    links:
        $forElem:
            approxcollision:
                required: true
                default: []
            name:
                required: true
                default: 'linkName'
            $reference: pose
            visual:
                $forElem:
                    name:
                        required: true
                        default: 'visualName'
                    $reference: geometry
                    $reference: pose
            inertial:
                inertia:
                    required: true
                    default: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
                mass:
                    required: true
                    default: 1.0
                name:
                    required: true
                    default: 'inertialName'
                $reference: pose
            collision:
                $forElem:
                    name:
                        required: true
                        default: 'collisionName'
                    $reference: pose
                    $reference: geometry
    joints:
        $forElem:
            state:
                matrix:
                    required: true
                    default:
                        - [1.0, 0.0, 0.0, 0.0]
                        - [0.0, 1.0, 0.0, 0.0]
                        - [0.0, 0.0, 1.0, 0.0]
                        - [0.0, 0.0, 0.0, 1.0]
                rotation_euler:
                    required: true
                    default: [0.0, 0.0, 0.0]
                rotation_quaternion:
                    required: true
                    default: [1.0, 0.0, 0.0, 0.0]
                translation:
                    required: true
                    default: [0.0, 0.0, 0.0]
            child:
                required: true
                default: 'jointChild'
            name:
                required: true
                default: 'jointName'
            parent:
                required: true
                default: 'jointParent'
            type:
                required: true
                default: 'floating'

The document's overall structure is that of a YAML dictionary, just as the internal model used by Phobos is a Python dictionary. The root element has to be ModelConstraints TODO should this be DictConstraints? to tell Phobos this is part of the modelConstraints when parsing the yml files. The given key-value structure is the same as the model dictionary in Phobos, with a few exceptions:

  • $forElem: Whenever you are at a point in your structure where you have a collection of similar objects, you use this keyword to tell Phobos that all following definitions are valid for all elements in this node. You can find a number of examples in the example file above.

  • $reference and isReference: true: In some cases structures are reused in other parts of the dictionary. To do so you can create another top level substructure with an isReference:true tag in it. At the point you want to insert this substructure just use the $reference tag and the substructures name as its value.

  • $selection__NAME: This tag is mostly the same as a switch statement in other languages. If you want to change the substructure depending of the value of a specific node just use this tag with the nodes name as NAME. The subnodes of this tag should be the possible values you want to decide between. The node you want to depend on has to be in the same level as the tag.

  • leaves: If you reach a leaf in your structure (so a single variable), two tags are used: required and default, defining whether a variable is optional or has to be in the dictionary and which value will be used as a default respectively.