text: import ruckig
  from copy import copy
  import matplotlib.pyplot as plt
  from mpl_toolkits.mplot3d import Axes3D
  import numpy as np
  from IPython import embed
  
  
  def WalkThroughTrajectory(otg, in_param, T):
      dof = otg.degrees_of_freedom
      out_param: ruckig.OutputParameter = ruckig.OutputParameter(dof)
      first_output = None
      ts = []
      xs = []
      dxs = []
      ddxs = []
  
      t = 0
      res = ruckig.Result.Working
      while res == ruckig.Result.Working:
          res = otg.update(in_param, out_param)
          in_param.current_position = out_param.new_position
          in_param.current_velocity = out_param.new_velocity
          in_param.current_acceleration = out_param.new_acceleration
  
          ts.append(t)
          xs.append(out_param.new_position)
          dxs.append(out_param.new_velocity)
          ddxs.append(out_param.new_acceleration)
          t += T
  
          if not first_output:
              first_output = copy(out_param)
  
      return first_output, ts, xs, dxs, ddxs
  
  
  if __name__ == '__main__':
      dof = 3
      in_param = ruckig.InputParameter(dof)
      in_param.current_position = [0, 0, 0]
      in_param.current_velocity = [1., 0, 0]
      in_param.current_acceleration = [0, 0, 0]
      in_param.target_position = [0.1, -1, -2]
      in_param.target_velocity = [1, 0, 0]
      in_param.target_acceleration = [0, 2, 0]
      in_param.max_velocity = [1, 1, 1]
      in_param.max_acceleration = [2, 2, 2]
      in_param.max_jerk = [5, 5, 5]
  
      T = 0.004
      otg = ruckig.Ruckig(dof, T)
      # otg = ruckig.Smoothie(dof, T)
      # otg = ruckig.Quintic(dof, T)
  
      first_output, ts, xs, dxs, ddxs = WalkThroughTrajectory(otg, in_param, T)
  
      print(
          f'Calculation duration: {first_output.calculation_duration:0.1f} [µs]')
      print(f'Trajectory duration: {first_output.trajectory.duration:0.4f} [s]')
  
      shape = (2, 2)
  
      plt.subplots_adjust(hspace=1)
      plt.subplot2grid(shape, loc=(0, 0))
      plt.plot(ts, xs)
      plt.legend(['$D_%i$' % i for i in range(dof)])
      plt.title("$x(t)$")
  
      plt.subplot2grid(shape, loc=(0, 1))
      plt.plot(ts, dxs)
      plt.legend(['$D_%i$' % i for i in range(dof)])
      plt.title("$\dot x(t)$")
  
      plt.subplot2grid(shape, loc=(1, 0))
      plt.plot(ts, ddxs)
      plt.legend(['$D_%i$' % i for i in range(dof)])
      plt.title("$\ddot x(t)$")
  
      xs = np.asarray(xs)
      # plt.subplot2grid(shape, loc=(1, 1), projection='')
      plt.subplot2grid(shape, loc=(1, 1))
      plt.plot(*xs.T[:2])
      plt.legend(['$D_%i$' % i for i in range(dof)])
      plt.title("$x_1 x_2 x_3$")
  
      plt.show()
      # embed()
  