0

I am trying to provide the solver with an initial guess that is a sinusoidal trajectory. I was hoping that there would be a way to specify the initial guess for the individual knot points, because then it would have been quite simple to provide the solver with an initial trajectory guess for a trajectory of any shape.

I have only found examples using the dircol.SetInitialTrajectory() function, together with a PiecewisePolynomial with FirstOrderHold, i.e. a linear initial guess. Is there a way to provide i.e. a sinuosidal initial trajectory?

Thanks!

bernhardpg
  • 61
  • 5

1 Answers1

2

SetInitialTrajectory takes an arbitrary PiecewisePolynomial as input, and will only be evaluated at the sample times of the initial guess. So you should be able to pass in a PiecewisePolynomial that matches your sinusoid perfectly.

Alternatively, you can use the SetInitialGuess interface from MathematicalProgram, and simply iterate through the dircol.state(i) variables to set them (allow you to define the mapping to time yourself).

Russ Tedrake
  • 4,703
  • 1
  • 7
  • 10
  • Ah, I see, thanks for getting back to me! I did not realize until that you can use the inherited functions from ```MathematicalProgram```, but of course that makes a lot of sense. How would you go about creating a sine as a PiecewisePolynomial? Is the best way to use a series expansion of a sine, to use one of the "Coefficient-based construction methods" from the docs, or am I missing an easier route? – bernhardpg Dec 14 '20 at 19:37