# SPDX-License-Identifier: MPL-2.0
# SPDX-FileCopyrightText: 2026 SECORO AG (secoro.uni-bremen.de)
# Author: Vamsi Kalagaturu
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix kc: <https://comp-rob2b.github.io/metamodels/kinematic-chain/structural-entities#> .
@prefix kc-stat: <https://comp-rob2b.github.io/metamodels/kinematic-chain/state#> .
@prefix act: <https://secorolab.github.io/metamodels/robot/actuation#> .
@prefix qudt: <http://qudt.org/schema/qudt/> .
@prefix qkind: <http://qudt.org/vocab/quantitykind/> .
@prefix unit: <http://qudt.org/vocab/unit/> .

act:ActuationShape
  a sh:NodeShape ;
  sh:targetClass act:Actuation ;
  sh:property [
    sh:path act:joint ;
    sh:class kc:Joint ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
  ] ;
  sh:property [
    sh:path act:gear-ratio ;
    sh:datatype xsd:double ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
  ] ;
  # Rotor inertia reflected to the joint side.
  sh:property [
    sh:path act:rotor-inertia ;
    sh:node act:RotorInertiaShape ;
    sh:maxCount 1 ;
  ] ;
  sh:property [
    sh:path act:command-interface ;
    sh:in (kc-stat:JointPosition kc-stat:JointVelocity kc-stat:JointAcceleration kc-stat:JointForce act:JointCurrent) ;
    sh:minCount 1 ;
  ] ;
  sh:property [
    sh:path act:state-interface ;
    sh:in (kc-stat:JointPosition kc-stat:JointVelocity kc-stat:JointAcceleration kc-stat:JointForce act:JointCurrent) ;
    sh:minCount 1 ;
  ] ;
  sh:sparql [
    sh:message "A transmission gear ratio must be nonzero." ;
    sh:select """
      PREFIX act: <https://secorolab.github.io/metamodels/robot/actuation#>
      SELECT $this WHERE {
        $this act:gear-ratio ?value .
        FILTER (?value = 0.0)
      }
    """ ;
  ] .

act:RotorInertiaShape
  a sh:NodeShape ;
  sh:message "A rotor inertia must be a non-negative moment of inertia in kg m^2." ;
  sh:class qudt:Quantity ;
  sh:property [ sh:path qudt:hasQuantityKind ; sh:hasValue qkind:MomentOfInertia ] ;
  sh:property [ sh:path qudt:unit ; sh:hasValue unit:KiloGM-M2 ; sh:maxCount 1 ] ;
  sh:property [
    sh:path qudt:value ;
    sh:datatype xsd:double ;
    sh:minInclusive 0.0 ;
    sh:minCount 1 ;
    sh:maxCount 1 ;
  ] .
