You are viewing the documentation for OpenSim 2.4. Are you looking for the latest OpenSim 4.0 Documentation?
Creating a Customized Actuator
In this exercise, we will create a specific type of actuator that implements a spring with controllable stiffness. The source code and associated files for this example come with the OpenSim 2.0 distribution under the directory:
C:\Program Files\OpenSim 2.0\sdk\APIExamples\CustomActuatorExample
When defining a new actuator, you can either start from scratch by deriving from the base class, CustomActuator, or if your actuator builds on an existing class, you can derive from that class. In this example we will implement a controllable stiffness spring by deriving from the PistonActuator class. The topics covered in this section include:
Actuator Overview
We define an actuator as something that produces controllable loads between two bodies. These could be torques applied between two bodies along a common axis, forces applied between two points defined on two different bodies, or some combination of loads applied according to some geometry and state parameters. The key function of any actuator class is to calculate and apply loads to its associated bodies based on its control value and the state variables at any time step.
The PistonActuator class
In this exercise we wish to create a spring with controllable stiffness that acts between two points located on different bodies. Instead of building this actuator from the generic, pure virtual class, CustomActuator, we will instead derive our new class from the pre-existing PistonActuator class. This class is a copy of the LineActuator Is now PointToPointActuatorclass defined within OpenSim. However, to serve as an example of how we design our actuator classes we have implemented and included the renamed version, PistonActuator, within the source material of this example. The figure below illustrates the PistonActuator class. This actuator applies a force between two points fixed on two bodies. These bodies do not need to be consecutive bodies in a kinematic chain. This class calculates the magnitude of its force as the product (optimalForce x control value) and uses the convention that a positive force magnitude acts to increase the distance between points PA and PB.
Illustration of the PistonActuator class
The ControllableSpring class
The figure below illustrates the ControllableSpring class that we will define. Just like PistonActuator, ControllableSpring will act between two points fixed on two different bodies. However, the force magnitude will not simply be calculated as the product of the optimal force and the control value. Instead, this product will represent the spring stiffness: k = (optimalForce x control value). We will also have to define a rest length at which the spring produces no force. The force magnitude will then be calculated as F = k(restLength – currentLength).*
Illustration of the ControllableSpring class to be implemented
OpenSim is supported by the Mobilize Center , an NIH Biomedical Technology Resource Center (grant P41 EB027060); the Restore Center , an NIH-funded Medical Rehabilitation Research Resource Network Center (grant P2C HD101913); and the Wu Tsai Human Performance Alliance through the Joe and Clara Tsai Foundation. See the People page for a list of the many people who have contributed to the OpenSim project over the years. ©2010-2024 OpenSim. All rights reserved.