Behaviors of degrees of freedom

To define the motion of a joint requires that we define the behavior of each of the joint's degrees of freedom. There are three different types of behavior of a degree of freedom: (1) Its motion is prescribed with a given function of time, in which case we say that the degree of freedom is constrained (2) Its motion is specified directly, but determined by a process that lies outside of the body system, in which case we say the degree of freedom is exogenous. (3) Its motion is determined indirectly by some sort of force model for its behavior, such as a spring or damper, in which case we say the degree of freedom is unconstrained.

Here, we will discuss how to set a degree of freedom with one of these behaviors, and how to set the prescribed motion, if desired.

using RigidBodyTools
using Plots

Constrained behavior (i.e., prescribed motion)

When a degree of freedom is constrained, then its behavior over time is set by some time-varying function. There are a number of different types of predefined time-varying behaviors.

Constant velocity

To specify constant velocity with some velocity, e.g. $U=1$, set

U = 1.0
k = ConstantVelocityDOF(U)
Constant velocity kinematics (velocity = 1.0)

For any prescribed motion, we can evaluate it at any specified time. It returns data of type DOFKinematicData.

t = 1.0
kt = k(t)
DOFKinematicData(1.0, 1.0, 1.0, 0.0)

The kinematic data can be parsed with dof_position, dof_velocity, and dof_acceleration:

dof_position(kt)
1.0
dof_velocity(kt)
1.0
dof_acceleration(kt)
0.0

Let's plot the position over time

t = range(0,3,length=301)
plot(t,dof_position.(k.(t)),xlims=(0,Inf),ylims=(0,Inf))
Example block output

Oscillatory motion

We can set the position to be a sinusoidal function. For this, we set the amplitude, the angular frequency, the phase, and the mean velocity (typically zero).

A = 1.0 ## amplitude
Ω = 2π ## angular frequency
ϕ = π/2 ## phase
vel = 0  ## mean velocity
k = OscillatoryDOF(A,Ω,ϕ,vel)
Oscillatory kinematics (amplitude = 1.0, ang freq = 6.283185307179586, phase = 1.5707963267948966, mean velocity = 0.0)

Plot the position, velocity, and acceleration

plot(t,dof_position.(k.(t)),xlims=(0,Inf),label="x")
plot!(t,dof_velocity.(k.(t)),label="ẋ")
plot!(t,dof_acceleration.(k.(t)),label="ẍ")
Example block output

Smooth ramp motion

To ramp the position from one value to another, we use the SmoothRampDOF. For this, we need to specify the nominal velocity of the ramp, the change in position, and the time at which the ramp starts. There is an optional argument ramp to control the ramp's smoothness. It defaults to EldredgeRamp(11.0), an Eldredge-type ramp with smoothness factor 11.

vel = 1.0  ## nominal ramp velocity
Δx = 1.0 ## change in position
t0 = 1.0 ## time of ramp start
k = SmoothRampDOF(vel,Δx,t0)
Smooth position ramp kinematics (nominal rate = 1.0, amplitude = 1.0, nominal time = 1.0), smoothing=logcosh ramp (aₛ = 11.0)

Plot the position

plot(t,dof_position.(k.(t)),xlims=(0,Inf),label="x")
Example block output

We can also ramp up the velocity from one value to another, using SmoothVelocityRampDOF. For example,

u1 = 1.0 ## initial velocity
u2 = 2.0 ## final velocity
acc = 1.0 ## nominal acceleration of the ramp
t0 = 1.0 ## time of ramp start
k = SmoothVelocityRampDOF(acc,u1,u2,t0)
Smooth velocity ramp kinematics (nominal rate = 1.0, initial velocity = 1.0, final velocity = 2.0, nominal time = 1.0), smoothing = logcosh ramp (aₛ = 11.0)

Plot the velocity

plot(t,dof_velocity.(k.(t)),xlims=(0,Inf),label="u")
Example block output

and the position

plot(t,dof_position.(k.(t)),xlims=(0,Inf),label="x")
Example block output

User-defined motion

The user can specify the time-varying position by supplying a function of time and using CustomDOF. It automatically differentiates this function to get velocity and acceleration. For example, a quadratic behavior

f(t) = 1.0*t + 2.0*t^2
k = CustomDOF(f)
Custom kinematics

Plot the position

plot(t,dof_position.(k.(t)),xlims=(0,Inf),label="x")
Example block output

and the velocity

plot(t,dof_velocity.(k.(t)),xlims=(0,Inf),label="ẋ")
Example block output

and the acceleration

plot(t,dof_acceleration.(k.(t)),xlims=(0,Inf),label="ẍ")
Example block output

Exogenous and unconstrained behaviors

If the degree of freedom is to be exogenous or unconstrained, then it can be designated as such, e.g,

k = ExogenousDOF()
Exogeneously-specified DOF

or

k = UnconstrainedDOF()
Unconstrained DOF

Degree of freedom functions

RigidBodyTools.OscillatoryDOFType
OscillatoryDOF(amp,angfreq,phase,ẋ0) <: AbstractPrescribedDOFKinematics

Set sinusoidal kinematics with amplitude amp, angular frequency angfreq, phase phase, and mean velocity ẋ0. The function it provides is x(t) = ẋ0*t + amp*sin(angfreq*t+phase).

source
RigidBodyTools.SmoothRampDOFType
SmoothRampDOF(ẋ0,Δx,t0[;ramp=EldredgeRamp(11.0)]) <: AbstractPrescribedDOFKinematics

Kinematics describing a smooth ramp change in position Δx starting at time t0 with nominal rate ẋ0. Note that the sign of ẋ0 should be the same as the sign of Δx, and will be automatically changed if they differ. The optional ramp argument is assumed to be given by the smooth ramp EldredgeRamp with a smoothness factor of 11 (larger values lead to sharper transitions on/off the ramp), but this can be replaced by another Eldredge ramp with a different value or a ColoniusRamp.

source
RigidBodyTools.CustomDOFType
CustomDOF(f::Function) <: AbstractPrescribedDOFKinematics

Set custom kinematics for a degree of freedom with a function f that specifies its value at any given time.

source
RigidBodyTools.ExogenousDOFType
ExogenousDOF() <: AbstractDOFKinematics

Sets a DOF as constrained, but with its behavior set by an exogenous process at every instant. For such a DOF, one must provide a vector [x,ẋ,ẍ].

source
RigidBodyTools.UnconstrainedDOFType
UnconstrainedDOF([f::Function]) <: AbstractDOFKinematics

Sets a DOF as unconstrained, so that its behavior is either completely free or determined by a given force response (e.g., spring and/or damper). This force response is set by the optional input function f. The signature of f must be f(x,xdot,t), where x and xdot are the position of the dof and its derivative, respectively, and t is the current time. It must return a single scalar, serving as a force or torque for that DOF.

source

This page was generated using Literate.jl.