def __init__(self, parent, name="ActuatedArm", translation=[0.0, 0.0, 0.0], eulerRotation=[0.0, 0.0, 0.0], attachingTo=None): self.node = parent.createChild(name) r = Transform(translation, eulerRotation=eulerRotation) self.node.createObject("MechanicalObject", name="dofs", size=1, position=r.toSofaRepr(), template='Rigid3', showObject=True, showObjectScale=15) servomotor = ServoMotor(self.node) servomotor.createObject("RigidRigidMapping", name="mapping") ServoArm(self.node, servomotor.ServoWheel.dofs) if attachingTo is not None: constraint = self.addConstraint( attachingTo.dofs.getData("rest_position"), translation, eulerRotation) attachingTo.createObject( 'RestShapeSpringsForceField', points=constraint.BoxROI.getData("indices"), external_rest_shape=constraint.dofs, stiffness='1e12')
def init(self): self.servomotor = self.addChild( ServoMotor(name="ServoMotor", translation=self.translation.value, rotation=self.rotation.value)) self.servoarm = self.addChild( ServoArm(name="ServoArm") ) #,mappingInputLink=self.ServoMotor.ServoWheel.dofs.getLinkPath())) self.servoarm.setRigidMapping( self.ServoMotor.ServoWheel.dofs.getLinkPath()) ## add a public attribute and connect it to the private one. self.addData(name='angleIn', group='ArmProperties', help='angle of rotation (in radians) of the arm', type='float', value=0) self.ServoMotor.getData('angleIn').setParent(self.getData('angleIn')) ## add a public attribute and connect it to the internal one. self.addData(name='angleOut', group='ArmProperties', help='angle of rotation (in radians) of the arm', type='float', value=0) self.getData('angleOut').setParent(self.ServoMotor.getData('angleOut')) if self.attachingToLink: attachingTo = getFromRoot(self, self.attachingToLink) constraint = self.addConstraint(attachingTo, self.translation.value, self.rotation.value) self.attachingTo.addObject( 'RestShapeSpringsForceField', name='rssff' + self.name, points=constraint.BoxROI.getData('indices'), external_rest_shape=constraint.dofs, stiffness='1e12')
def __init__(self, parent, name="ActuatedArm", translation=[0.0, 0.0, 0.0], eulerRotation=[0.0, 0.0, 0.0], attachingTo=None): self.node = parent.createChild(name) self.servomotor = ServoMotor(self.node, translation=translation, rotation=eulerRotation) self.servoarm = ServoArm(self.node, self.servomotor.ServoWheel.dofs) ## Create a public attribute and connect it to the private one. self.node.addNewData("angleIn", "ArmProperties", "angle of rotation (in radians) of the arm", "float", 0) self.node.ServoMotor.getData("angleIn").setParent(self.node.getData("angleIn")) ## Create a public attribute and connect it to the internal one. self.node.addNewData("angleOut", "ArmProperties", "angle of rotation (in radians) of the arm", "float", 0) self.node.getData("angleOut").setParent(self.node.ServoMotor.getData("angleOut")) if attachingTo is not None: constraint = self.addConstraint(attachingTo, translation, eulerRotation) attachingTo.createObject('RestShapeSpringsForceField', name="rssff"+name, points=constraint.BoxROI.getData("indices"), external_rest_shape=constraint.dofs, stiffness='1e12')
def __init__(self, parent, name="ActuatedArm", translation=[0.0, 0.0, 0.0], eulerRotation=[0.0, 0.0, 0.0], attachingTo=None): self.node = parent.addChild(name) self.servomotor = ServoMotor(self.node, translation=translation, rotation=eulerRotation) ServoArm(self.node, self.servomotor.ServoWheel.dofs) if attachingTo is not None: constraint = self.addConstraint( attachingTo.dofs.getData("rest_position"), translation, eulerRotation) attachingTo.addObject('RestShapeSpringsForceField', name="rssff" + name, points=constraint.BoxROI.getData("indices"), external_rest_shape=constraint.dofs, stiffness='1e12')