Skip to content

Commit f69f3fc

Browse files
Correct plotting bugs
1 parent 9b5aea4 commit f69f3fc

13 files changed

+112
-22
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ python3 togt_refine.py
5555
cd ../plots
5656
python3 plot_togt_refined_traj.py
5757
```
58-
![Alt Text](documents/images/togt_refined_traj.png)
58+
![Alt Text](documents/images/fig_togt_refined_traj.png)
5959

6060
## Visualize the AOS trajectory for waypoint flight
6161

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

7171
## Visualize the AOS-TOGT trajectory
7272

@@ -77,7 +77,7 @@ cd ../scripts/plots
7777
python3 plot_aos_togt_traj.py
7878
```
7979

80-
![Alt Text](documents/images/aos_togt_traj.png)
80+
![Alt Text](documents/images/fig_aos_togt_traj.png)
8181

8282
## Acknowledgements
8383

documents/images/aos_refined_traj.png

-62.4 KB
Binary file not shown.

documents/images/aos_togt_traj.png

-68.6 KB
Binary file not shown.

documents/images/aos_traj.png

-62.4 KB
Binary file not shown.
80.9 KB
Loading
97.6 KB
Loading

documents/images/fig_aos_traj.png

87.1 KB
Loading
67.9 KB
Loading
-64 KB
Binary file not shown.

scripts/plots/plot_aos_refined_traj.py

+36-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import numpy as np
22
import matplotlib
33
import matplotlib.pyplot as plt
4-
from track import plot_track
4+
from scipy.interpolate import UnivariateSpline
55

66
import sys, os
77
BASEPATH = os.path.abspath(__file__).split("plots/", 1)[0]+"plots/"
88
ROOTPATH = os.path.abspath(__file__).split("plots/", 1)[0]+".."
99
sys.path += [BASEPATH]
1010
sys.path += [ROOTPATH]
1111

12-
track_file = ROOTPATH + "/resources/racetrack/race_uzh_7g_multiprisma.yaml"
13-
traj_file = ROOTPATH + "/resources/trajectory/togt_traj.csv"
12+
directory = ROOTPATH + "/resources/trajectory"
13+
14+
traj_file = directory + "/aos_refined_traj.csv"
1415

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

@@ -64,15 +65,44 @@
6465

6566
plt.scatter(ps[:, 0], ps[:, 1], s=5,
6667
c=vt, cmap=plt.cm.autumn.reversed())
67-
plt.colorbar(pad=0.01).ax.set_ylabel('Speed [m/s]')
68+
plt.colorbar(pad=0.0).ax.set_ylabel('Speed [m/s]')
69+
70+
# Plot gates
71+
72+
orientations = {
73+
'Gate1': [0.0, -90.0, -0.0],
74+
'Gate2': [0.0, -90.0, -20.0],
75+
'Gate3': [0.0, -90.0, 50.0],
76+
'Gate4': [0.0, -90.0, 0.0],
77+
'Gate5': [0.0, -90.0, 0.0],
78+
'Gate6': [0.0, -90.0, 70.0],
79+
'Gate7': [0.0, -90.0, 20.0]
80+
}
81+
82+
positions = {
83+
'Gate1': (-1.1, -1.6, 3.6),
84+
'Gate2': (9.2, 6.6, 1.0),
85+
'Gate3': (9.2, -4.0, 1.2),
86+
'Gate4': (-4.5, -6.0, 3.5),
87+
'Gate5': (-4.5, -6.0, 0.8),
88+
'Gate6': [4.75, -0.9, 1.2],
89+
'Gate7': [-2.8, 6.8, 1.2]
90+
}
91+
6892

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

71101

72102
plt.xlabel('x [m]')
73103
plt.ylabel('y [m]')
74104
plt.axis('equal')
75105
plt.grid()
76-
plt.savefig('aos_refined_traj.png', bbox_inches='tight')
106+
plt.savefig('aos_refined_traj.png')
77107

78108
plt.show()

scripts/plots/plot_aos_togt_traj.py

+36-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import numpy as np
22
import matplotlib
33
import matplotlib.pyplot as plt
4-
from track import plot_track
4+
from scipy.interpolate import UnivariateSpline
55

66
import sys, os
77
BASEPATH = os.path.abspath(__file__).split("plots/", 1)[0]+"plots/"
88
ROOTPATH = os.path.abspath(__file__).split("plots/", 1)[0]+".."
99
sys.path += [BASEPATH]
1010
sys.path += [ROOTPATH]
1111

12-
track_file = ROOTPATH + "/resources/racetrack/race_uzh_7g_multiprisma.yaml"
13-
traj_file = ROOTPATH + "/resources/trajectory/togt_traj.csv"
12+
directory = ROOTPATH + "/resources/trajectory"
13+
14+
traj_file = directory + "/aos_togt_traj.csv"
1415

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

@@ -64,15 +65,44 @@
6465

6566
plt.scatter(ps[:, 0], ps[:, 1], s=5,
6667
c=vt, cmap=plt.cm.summer.reversed())
67-
plt.colorbar(pad=0.01).ax.set_ylabel('Speed [m/s]')
68+
plt.colorbar(pad=0.0).ax.set_ylabel('Speed [m/s]')
69+
70+
# Plot gates
71+
72+
orientations = {
73+
'Gate1': [0.0, -90.0, -0.0],
74+
'Gate2': [0.0, -90.0, -20.0],
75+
'Gate3': [0.0, -90.0, 50.0],
76+
'Gate4': [0.0, -90.0, 0.0],
77+
'Gate5': [0.0, -90.0, 0.0],
78+
'Gate6': [0.0, -90.0, 70.0],
79+
'Gate7': [0.0, -90.0, 20.0]
80+
}
81+
82+
positions = {
83+
'Gate1': (-1.1, -1.6, 3.6),
84+
'Gate2': (9.2, 6.6, 1.0),
85+
'Gate3': (9.2, -4.0, 1.2),
86+
'Gate4': (-4.5, -6.0, 3.5),
87+
'Gate5': (-4.5, -6.0, 0.8),
88+
'Gate6': [4.75, -0.9, 1.2],
89+
'Gate7': [-2.8, 6.8, 1.2]
90+
}
91+
6892

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

71101

72102
plt.xlabel('x [m]')
73103
plt.ylabel('y [m]')
74104
plt.axis('equal')
75105
plt.grid()
76-
plt.savefig('aos_togt_traj.png', bbox_inches='tight')
106+
plt.savefig('aos_togt_traj.png')
77107

78108
plt.show()

scripts/plots/plot_aos_traj.py

+36-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import numpy as np
22
import matplotlib
33
import matplotlib.pyplot as plt
4-
from track import plot_track
4+
from scipy.interpolate import UnivariateSpline
55

66
import sys, os
77
BASEPATH = os.path.abspath(__file__).split("plots/", 1)[0]+"plots/"
88
ROOTPATH = os.path.abspath(__file__).split("plots/", 1)[0]+".."
99
sys.path += [BASEPATH]
1010
sys.path += [ROOTPATH]
1111

12-
track_file = ROOTPATH + "/resources/racetrack/race_uzh_7g_multiprisma.yaml"
13-
traj_file = ROOTPATH + "/resources/trajectory/togt_traj.csv"
12+
directory = ROOTPATH + "/resources/trajectory"
13+
14+
traj_file = directory + "/aos_traj.csv"
1415

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

@@ -64,15 +65,44 @@
6465

6566
plt.scatter(ps[:, 0], ps[:, 1], s=5,
6667
c=vt, cmap=plt.cm.autumn.reversed())
67-
plt.colorbar(pad=0.01).ax.set_ylabel('Speed [m/s]')
68+
plt.colorbar(pad=0.0).ax.set_ylabel('Speed [m/s]')
69+
70+
# Plot gates
71+
72+
orientations = {
73+
'Gate1': [0.0, -90.0, -0.0],
74+
'Gate2': [0.0, -90.0, -20.0],
75+
'Gate3': [0.0, -90.0, 50.0],
76+
'Gate4': [0.0, -90.0, 0.0],
77+
'Gate5': [0.0, -90.0, 0.0],
78+
'Gate6': [0.0, -90.0, 70.0],
79+
'Gate7': [0.0, -90.0, 20.0]
80+
}
81+
82+
positions = {
83+
'Gate1': (-1.1, -1.6, 3.6),
84+
'Gate2': (9.2, 6.6, 1.0),
85+
'Gate3': (9.2, -4.0, 1.2),
86+
'Gate4': (-4.5, -6.0, 3.5),
87+
'Gate5': (-4.5, -6.0, 0.8),
88+
'Gate6': [4.75, -0.9, 1.2],
89+
'Gate7': [-2.8, 6.8, 1.2]
90+
}
91+
6892

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

71101

72102
plt.xlabel('x [m]')
73103
plt.ylabel('y [m]')
74104
plt.axis('equal')
75105
plt.grid()
76-
plt.savefig('aos_traj.png', bbox_inches='tight')
106+
plt.savefig('aos_traj.png')
77107

78108
plt.show()

scripts/plots/plot_togt_refined_traj.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
sys.path += [ROOTPATH]
1111

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

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

0 commit comments

Comments
 (0)