8 from proxsuite_nlp.utils
import plot_pd_errs
10 prim_infeas = cb.prim_infeas.tolist()
11 dual_infeas = cb.dual_infeas.tolist()
13 prim_infeas.append(res.primal_infeas)
14 dual_infeas.append(res.dual_infeas)
15 plot_pd_errs(ax, prim_infeas, dual_infeas)
16 ax.grid(axis=
"y", which=
"major")
21 q: np.ndarray, ax: plt.Axes, alpha=0.5, fc=
"tab:blue"
23 from matplotlib
import transforms
27 center = (q[0] - 0.5 * w, q[1] - 0.5 * h)
28 rect = plt.Rectangle(center, w, h, fc=fc, alpha=alpha)
29 theta = np.arctan2(q[3], q[2])
30 transform_ = transforms.Affine2D().rotate_around(*q[:2], -theta) + ax.transData
31 rect.set_transform(transform_)
53) -> tuple[plt.Figure, list[plt.Axes]]:
58 nrows, r = divmod(nu, ncols)
61 fig, axes = plt.subplots(nrows, ncols, sharex=
"col", figsize=figsize)
63 fig = axes.flat[0].get_figure()
66 if rmodel
is not None:
67 effort_limit = rmodel.effortLimit
68 joint_names = rmodel.names
71 ax: plt.Axes = axes[i]
72 ax.step(times[:-1], us[:, i])
73 if effort_limit
is not None:
75 ax.hlines(-effort_limit[i], t0, tf, colors=
"k", linestyles=
"--")
76 ax.hlines(+effort_limit[i], t0, tf, colors=
"r", linestyles=
"dashdot")
78 if joint_names
is not None:
79 joint_name = joint_names[i].lower()
80 ax.set_ylabel(joint_name)
81 fig.supxlabel(
"Time $t$")
82 fig.suptitle(
"Control trajectories")
95) -> tuple[plt.Figure, list[plt.Axes]]:
98 assert nv == vs.shape[1]
99 if vel_limit
is not None:
100 assert nv == vel_limit.shape[0]
101 idx_to_joint_id_map = {}
104 if i
in rmodel.idx_vs.tolist():
106 idx_to_joint_id_map[i] = jid
107 nrows, r = divmod(nv, ncols)
114 fig, axes = plt.subplots(nrows, ncols, figsize=figsize)
117 fig = axes.flat[0].get_figure()
121 ax: plt.Axes = axes[i]
122 ax.plot(times, vs[:, i])
123 jid = idx_to_joint_id_map[i]
124 joint_name = rmodel.names[jid].lower()
125 if vel_limit
is not None:
127 ax.hlines(-vel_limit[i], t0, tf, colors=
"k", linestyles=
"--")
128 ax.hlines(+vel_limit[i], t0, tf, colors=
"r", linestyles=
"dashdot")
130 ax.set_ylabel(joint_name)
132 fig.supxlabel(
"Time $t$")
133 fig.suptitle(
"Velocity trajectories")
tuple[plt.Figure, list[plt.Axes]] plot_velocity_traj(times, vs, rmodel, axes=None, ncols=2, vel_limit=None, figsize=(6.4, 6.4))
tuple[plt.Figure, list[plt.Axes]] plot_controls_traj(times, us, ncols=2, axes=None, effort_limit=None, joint_names=None, rmodel=None, figsize=(6.4, 6.4))