Skip to content

Commit

Permalink
Add the joint tracking error plot in joint-position-tracking script (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehsan Ranjbari authored Dec 19, 2023
1 parent 4484598 commit 6e6d85e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ All notable changes to this project are documented in this file.
- Change use of dynamics name for fts, contacts, accelerometers, gyroscopes in `RobotDynamicsEstimator` (https://github.com/ami-iit/bipedal-locomotion-framework/pull/759)
- 🤖 Modify the `YarpRobotLoggerDevice` of `ergoCubSN001` to be compliant with the latest [robots-configuration files](https://github.com/robotology/robots-configuration/pull/598) (https://github.com/ami-iit/bipedal-locomotion-framework/pull/772)
- Modify the `balancing-position-control` application to be compliant with the new implementation of the spline and the `VectorsCollectionServer` (https://github.com/ami-iit/bipedal-locomotion-framework/pull/776)
- Add the joint tracking error plot in joint-position-tracking script (https://github.com/ami-iit/bipedal-locomotion-framework/pull/775/)

### Removed
- Remove the latex dependency in the joint-position-tracking script (https://github.com/ami-iit/bipedal-locomotion-framework/pull/775/)

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
import matplotlib
import matplotlib.pyplot as plt

from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
rc('text', usetex=True)

def read_data(file_name):
data = []

Expand Down Expand Up @@ -47,27 +43,35 @@ def plot_data(axes, x_data, y_data, color, linewidth = 1.0):
return axes.plot(x_data, y_data, color = col, linewidth = linewidth)

def plot_and_save(data):
fig, ax = plt.subplots(1)
fig, ax = plt.subplots(1,2)

channel_0 = data[:, 0]
channel_1 = data[:, 1]

plot_0, = plot_data(ax, times(channel_0), channel_0, "red")
plot_1, = plot_data(ax, times(channel_1), channel_1, "blue")
plot_0, = plot_data(ax[0], times(channel_0), channel_0, "red")
plot_1, = plot_data(ax[0], times(channel_1), channel_1, "blue")

legend = [plot_0, plot_1]
legend = fig.legend(legend, labels = ["$\mathrm{Reference}$", "$\mathrm{Actual}$"], ncol = 2, loc = "upper center", frameon=False)
legend = fig.legend(legend, labels = ["Reference", "Actual"], ncol = 2, loc = "upper center", frameon=False)

for line in legend.get_lines():
line.set_linewidth(2.0)

label_font_size = 10
ax.grid()
ax.set_xlabel('time [s]', fontsize = label_font_size)
ax.set_ylabel('position [rad]', fontsize = label_font_size)
ax.set_title('joint position', fontsize = label_font_size)
ax[0].grid()
ax[0].set_xlabel('time [s]', fontsize = label_font_size)
ax[0].set_ylabel('position [rad]', fontsize = label_font_size)
ax[0].set_title('joint position', fontsize = label_font_size)

error = channel_1 - channel_0
plot_error, = ax[1].plot(times(channel_0), error, color="green")
ax[1].grid()
ax[1].set_xlabel('time [s]', fontsize=label_font_size)
ax[1].set_ylabel('error [rad]', fontsize=label_font_size)
ax[1].set_title('Error Plot', fontsize=label_font_size)

figure = plt.gcf()
plt.tight_layout()
plt.savefig("./figure.png", bbox_inches='tight', dpi = 150)

# plt.show()
Expand All @@ -81,5 +85,3 @@ def plot_and_save(data):
data = read_data(args.dataset)

plot_and_save(data)


0 comments on commit 6e6d85e

Please sign in to comment.