Skip to content

Commit

Permalink
Merge pull request #388 from Peter230655/pendulum-fixed-duration
Browse files Browse the repository at this point in the history
docstrings as per #348, backend= nzmpy, reduced frames
  • Loading branch information
moorepants authored Feb 27, 2025
2 parents a476e23 + da2effb commit 3885740
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions examples-gallery/beginner/plot_pendulum_swing_up_fixed_duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,27 @@
Fixed Duration Pendulum Swing Up
================================
Objective
---------
- Show the use of opty with likely the simplest example possible.
Introduction
------------
Given a compound pendulum that is driven by a torque about its joint axis,
swing the pendulum from hanging down to standing up in a fixed amount of time
using minimal input torque with a bounded torque magnitude.
Notes
-----
This example uses a fixed duration. There is an example which is mechanically
identical to this one, but it uses a variable time interval, to get the
pendulum up as fast as possible, given the torque limitations.
"""

import numpy as np
Expand Down Expand Up @@ -75,7 +92,9 @@
known_parameter_map=par_map,
instance_constraints=instance_constraints,
bounds=bounds,
time_symbol=t)
time_symbol=t,
backend='numpy',
)

# %%
# Use a random positive initial guess.
Expand Down Expand Up @@ -129,8 +148,8 @@ def animate(i):
return line, time_text


ani = animation.FuncAnimation(fig, animate, range(num_nodes),
interval=int(interval_value*1000), blit=True,
ani = animation.FuncAnimation(fig, animate, range(0, num_nodes, 4),
interval=int(interval_value*1000*4), blit=True,
init_func=init)

plt.show()

0 comments on commit 3885740

Please sign in to comment.