-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example that explains critical damping
- Loading branch information
1 parent
dd3c433
commit 921d377
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
================ | ||
Critical Damping | ||
================ | ||
The transformation system of a DMP converges to the goal and the convergence is | ||
modeled as a spring-damper system. For an optimal convergence, the constants | ||
defining the spring-damper system (spring constant k and damping coefficient c) | ||
have to be set to critical damping for optimal convergence, that is, as quickly | ||
as possible without overshooting. To illustrate this, we use a standalone | ||
spring-damper system and explore several values for these parameters. | ||
""" | ||
print(__doc__) | ||
|
||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from movement_primitives.spring_damper import SpringDamper | ||
|
||
|
||
k = 100 | ||
start_y = np.zeros(1) | ||
goal_y = np.ones(1) | ||
for c in [10, 20, 40]: | ||
attractor = SpringDamper(n_dims=1, k=k, c=c, dt=0.01) | ||
attractor.configure(start_y=start_y, goal_y=goal_y) | ||
T, Y = attractor.open_loop(run_t=2.0) | ||
plt.plot(T, Y[:, 0], label=f"$k={k}, c={c}$") | ||
plt.scatter(1.0, 1.0, marker="*", s=200, label="Goal") | ||
plt.legend(loc="best") | ||
plt.title(r"Condition for critical damping: $c = 2 \sqrt{k}$") | ||
plt.show() |