This seems like it should have been a well studied problem, but I can't find any solution.
We want to define what a motor must be commanded to do to move a single link with mass $m$ and length $l$ $180^\circ$ in a certain amount of time $\tau$.
In the horizontal plane, we know that the torque required to move the link is $$ T = \frac{1}{3}ml^2\ddot{\theta} $$ It took a little calculation, but to move the link $180^\circ$ in $\tau$ sec, a quintic polynomial can solve all of the boundary conditions $$ \theta(0) = 0 $$ $$ \theta(\tau) = \pi $$ $$ \dot{\theta}(0) = 0 $$ $$ \dot{\theta}(\tau) = 0 $$ $$ T(\theta) = 0 $$ $$ T(\tau) = 0 $$ The function that works is $$ \theta(t) = 10\pi\left(\frac{t}{\tau}\right)^3 - 15\pi\left(\frac{t}{\tau}\right)^4 + 6\pi\left(\frac{t}{\tau}\right)^5 $$ The implied torque that the actuator must deliver is $$ T(t) = 20\pi\,\frac{ml^2}{\tau^2}\left[\left(\frac{t}{\tau}\right) - 3\left(\frac{t}{\tau}\right)^2 + 2\left(\frac{t}{\tau}\right)^3\right] $$ I believe all of the above is correct, but if someone thinks otherwise I would welcome the correction.
Now we want to solve this same problem in the vertical plane, where the actuator has to work against gravity. It can be shown from the Lagrangian or elsewhere that now the actuator has to effect $$ T = \frac{1}{3}ml^2\ddot{\theta} + \frac{1}{2}mgl\cos\theta $$ I would like to again come up some expression for $T(t)$ or $\theta$ but I am stumped. The boundary conditions now include (I think) $\ddot{\theta} = 0$ at $t=0$ and $t=\tau$. This seems like something someone must have solved, since in a real system someone would have had to define the torque or position commands for the motor. I tried things with different polynomials and/or the Taylor series approximation for $\cos\theta$. Probably I will have to resort to some kind of numerical search, but I am wondering if there is any kind of elegant closed-form expression that solves this.