Skip to content

Commit

Permalink
Correct plotting bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaoqinRobotics committed May 15, 2024
1 parent 9b5aea4 commit f69f3fc
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ python3 togt_refine.py
cd ../plots
python3 plot_togt_refined_traj.py
```
![Alt Text](documents/images/togt_refined_traj.png)
![Alt Text](documents/images/fig_togt_refined_traj.png)

## Visualize the AOS trajectory for waypoint flight

Expand All @@ -66,7 +66,7 @@ Another example is the Split-S track provided in [this](https://www.science.org/
cd ../scripts/plots
python3 plot_aos_traj.py
```
![Alt Text](documents/images/aos_traj.png)
![Alt Text](documents/images/fig_aos_traj.png)

## Visualize the AOS-TOGT trajectory

Expand All @@ -77,7 +77,7 @@ cd ../scripts/plots
python3 plot_aos_togt_traj.py
```

![Alt Text](documents/images/aos_togt_traj.png)
![Alt Text](documents/images/fig_aos_togt_traj.png)

## Acknowledgements

Expand Down
Binary file removed documents/images/aos_refined_traj.png
Binary file not shown.
Binary file removed documents/images/aos_togt_traj.png
Binary file not shown.
Binary file removed documents/images/aos_traj.png
Binary file not shown.
Binary file added documents/images/fig_aos_refined_traj.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/images/fig_aos_togt_traj.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/images/fig_aos_traj.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added documents/images/fig_togt_refined_traj.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed documents/images/togt_refined_traj.png
Binary file not shown.
42 changes: 36 additions & 6 deletions scripts/plots/plot_aos_refined_traj.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from track import plot_track
from scipy.interpolate import UnivariateSpline

import sys, os
BASEPATH = os.path.abspath(__file__).split("plots/", 1)[0]+"plots/"
ROOTPATH = os.path.abspath(__file__).split("plots/", 1)[0]+".."
sys.path += [BASEPATH]
sys.path += [ROOTPATH]

track_file = ROOTPATH + "/resources/racetrack/race_uzh_7g_multiprisma.yaml"
traj_file = ROOTPATH + "/resources/trajectory/togt_traj.csv"
directory = ROOTPATH + "/resources/trajectory"

traj_file = directory + "/aos_refined_traj.csv"

data_ocp = np.genfromtxt(traj_file, dtype=float, delimiter=',', names=True)

Expand Down Expand Up @@ -64,15 +65,44 @@

plt.scatter(ps[:, 0], ps[:, 1], s=5,
c=vt, cmap=plt.cm.autumn.reversed())
plt.colorbar(pad=0.01).ax.set_ylabel('Speed [m/s]')
plt.colorbar(pad=0.0).ax.set_ylabel('Speed [m/s]')

# Plot gates

orientations = {
'Gate1': [0.0, -90.0, -0.0],
'Gate2': [0.0, -90.0, -20.0],
'Gate3': [0.0, -90.0, 50.0],
'Gate4': [0.0, -90.0, 0.0],
'Gate5': [0.0, -90.0, 0.0],
'Gate6': [0.0, -90.0, 70.0],
'Gate7': [0.0, -90.0, 20.0]
}

positions = {
'Gate1': (-1.1, -1.6, 3.6),
'Gate2': (9.2, 6.6, 1.0),
'Gate3': (9.2, -4.0, 1.2),
'Gate4': (-4.5, -6.0, 3.5),
'Gate5': (-4.5, -6.0, 0.8),
'Gate6': [4.75, -0.9, 1.2],
'Gate7': [-2.8, 6.8, 1.2]
}


plot_track(plt.gca(), track_file)
orders = ['Gate1', 'Gate2', 'Gate3', 'Gate4', 'Gate5', 'Gate6', 'Gate7']
for g in orders:
rpy = np.array(orientations[g]) * np.pi/180
y = rpy[2]
r = 0.8
plt.plot([positions[g][0]+r*np.sin(y), positions[g][0]-r*np.sin(y)],
[positions[g][1]-r*np.cos(y), positions[g][1]+r*np.cos(y)], 'k-', linewidth=4.0)


plt.xlabel('x [m]')
plt.ylabel('y [m]')
plt.axis('equal')
plt.grid()
plt.savefig('aos_refined_traj.png', bbox_inches='tight')
plt.savefig('aos_refined_traj.png')

plt.show()
42 changes: 36 additions & 6 deletions scripts/plots/plot_aos_togt_traj.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from track import plot_track
from scipy.interpolate import UnivariateSpline

import sys, os
BASEPATH = os.path.abspath(__file__).split("plots/", 1)[0]+"plots/"
ROOTPATH = os.path.abspath(__file__).split("plots/", 1)[0]+".."
sys.path += [BASEPATH]
sys.path += [ROOTPATH]

track_file = ROOTPATH + "/resources/racetrack/race_uzh_7g_multiprisma.yaml"
traj_file = ROOTPATH + "/resources/trajectory/togt_traj.csv"
directory = ROOTPATH + "/resources/trajectory"

traj_file = directory + "/aos_togt_traj.csv"

data_ocp = np.genfromtxt(traj_file, dtype=float, delimiter=',', names=True)

Expand Down Expand Up @@ -64,15 +65,44 @@

plt.scatter(ps[:, 0], ps[:, 1], s=5,
c=vt, cmap=plt.cm.summer.reversed())
plt.colorbar(pad=0.01).ax.set_ylabel('Speed [m/s]')
plt.colorbar(pad=0.0).ax.set_ylabel('Speed [m/s]')

# Plot gates

orientations = {
'Gate1': [0.0, -90.0, -0.0],
'Gate2': [0.0, -90.0, -20.0],
'Gate3': [0.0, -90.0, 50.0],
'Gate4': [0.0, -90.0, 0.0],
'Gate5': [0.0, -90.0, 0.0],
'Gate6': [0.0, -90.0, 70.0],
'Gate7': [0.0, -90.0, 20.0]
}

positions = {
'Gate1': (-1.1, -1.6, 3.6),
'Gate2': (9.2, 6.6, 1.0),
'Gate3': (9.2, -4.0, 1.2),
'Gate4': (-4.5, -6.0, 3.5),
'Gate5': (-4.5, -6.0, 0.8),
'Gate6': [4.75, -0.9, 1.2],
'Gate7': [-2.8, 6.8, 1.2]
}


plot_track(plt.gca(), track_file)
orders = ['Gate1', 'Gate2', 'Gate3', 'Gate4', 'Gate5', 'Gate6', 'Gate7']
for g in orders:
rpy = np.array(orientations[g]) * np.pi/180
y = rpy[2]
r = 0.8
plt.plot([positions[g][0]+r*np.sin(y), positions[g][0]-r*np.sin(y)],
[positions[g][1]-r*np.cos(y), positions[g][1]+r*np.cos(y)], 'k-', linewidth=4.0)


plt.xlabel('x [m]')
plt.ylabel('y [m]')
plt.axis('equal')
plt.grid()
plt.savefig('aos_togt_traj.png', bbox_inches='tight')
plt.savefig('aos_togt_traj.png')

plt.show()
42 changes: 36 additions & 6 deletions scripts/plots/plot_aos_traj.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from track import plot_track
from scipy.interpolate import UnivariateSpline

import sys, os
BASEPATH = os.path.abspath(__file__).split("plots/", 1)[0]+"plots/"
ROOTPATH = os.path.abspath(__file__).split("plots/", 1)[0]+".."
sys.path += [BASEPATH]
sys.path += [ROOTPATH]

track_file = ROOTPATH + "/resources/racetrack/race_uzh_7g_multiprisma.yaml"
traj_file = ROOTPATH + "/resources/trajectory/togt_traj.csv"
directory = ROOTPATH + "/resources/trajectory"

traj_file = directory + "/aos_traj.csv"

data_ocp = np.genfromtxt(traj_file, dtype=float, delimiter=',', names=True)

Expand Down Expand Up @@ -64,15 +65,44 @@

plt.scatter(ps[:, 0], ps[:, 1], s=5,
c=vt, cmap=plt.cm.autumn.reversed())
plt.colorbar(pad=0.01).ax.set_ylabel('Speed [m/s]')
plt.colorbar(pad=0.0).ax.set_ylabel('Speed [m/s]')

# Plot gates

orientations = {
'Gate1': [0.0, -90.0, -0.0],
'Gate2': [0.0, -90.0, -20.0],
'Gate3': [0.0, -90.0, 50.0],
'Gate4': [0.0, -90.0, 0.0],
'Gate5': [0.0, -90.0, 0.0],
'Gate6': [0.0, -90.0, 70.0],
'Gate7': [0.0, -90.0, 20.0]
}

positions = {
'Gate1': (-1.1, -1.6, 3.6),
'Gate2': (9.2, 6.6, 1.0),
'Gate3': (9.2, -4.0, 1.2),
'Gate4': (-4.5, -6.0, 3.5),
'Gate5': (-4.5, -6.0, 0.8),
'Gate6': [4.75, -0.9, 1.2],
'Gate7': [-2.8, 6.8, 1.2]
}


plot_track(plt.gca(), track_file)
orders = ['Gate1', 'Gate2', 'Gate3', 'Gate4', 'Gate5', 'Gate6', 'Gate7']
for g in orders:
rpy = np.array(orientations[g]) * np.pi/180
y = rpy[2]
r = 0.8
plt.plot([positions[g][0]+r*np.sin(y), positions[g][0]-r*np.sin(y)],
[positions[g][1]-r*np.cos(y), positions[g][1]+r*np.cos(y)], 'k-', linewidth=4.0)


plt.xlabel('x [m]')
plt.ylabel('y [m]')
plt.axis('equal')
plt.grid()
plt.savefig('aos_traj.png', bbox_inches='tight')
plt.savefig('aos_traj.png')

plt.show()
2 changes: 1 addition & 1 deletion scripts/plots/plot_togt_refined_traj.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
sys.path += [ROOTPATH]

track_file = ROOTPATH + "/resources/racetrack/race_uzh_7g_multiprisma.yaml"
traj_file = ROOTPATH + "/resources/trajectory/togt_traj.csv"
traj_file = ROOTPATH + "/resources/trajectory/togt_refined_traj.csv"

data_ocp = np.genfromtxt(traj_file, dtype=float, delimiter=',', names=True)

Expand Down

0 comments on commit f69f3fc

Please sign in to comment.