Skip to content

Commit 917d014

Browse files
committed
fixed desired position in x
1 parent d312faf commit 917d014

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

hw3/hw3.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ int main() {
9595

9696
//open file to store csv
9797
std::ofstream traj_file;
98-
traj_file.open("/media/varun/Work/Academics/_Spring 2019/CS 225A/cs225a_hw3/data4b.csv");
98+
traj_file.open("/media/varun/Work/Academics/_Spring 2019/CS 225A/cs225a_hw3/data3a.csv");
9999

100100

101101
// create a timer
@@ -119,7 +119,7 @@ int main() {
119119
// **********************
120120
// WRITE YOUR CODE AFTER
121121
// **********************
122-
int controller_number = QUESTION_4;
122+
int controller_number = QUESTION_3;
123123

124124
robot->gravityVector(g); //update gravity vector
125125
robot->coriolisForce(b); // update coriolis/cfugal vector
@@ -170,7 +170,7 @@ int main() {
170170

171171
x_desired_traj(0) = x_desired_traj_init(0) + 0.1*sin(Pi*controller_counter*dt);
172172
x_desired_traj(1) = x_desired_traj_init(1) + 0.1*cos(Pi*controller_counter*dt);
173-
x_desired_traj(2) = x_desired_traj_init(0) + 0;
173+
x_desired_traj(2) = x_desired_traj_init(2) + 0;
174174

175175
VectorXd xdot_traj(3);
176176
xdot_traj(0) = 0.1*Pi*cos(Pi*controller_counter*dt);
@@ -180,6 +180,7 @@ int main() {
180180
VectorXd xddot_traj(3);
181181
xddot_traj(0) = 0.1*Pi*Pi*(-sin(Pi*controller_counter*dt));
182182
xddot_traj(1) = 0.1*Pi*Pi*(-cos(Pi*controller_counter*dt));
183+
xddot_traj(2) = 0;
183184

184185

185186
//compute the control torques using the control law:
@@ -270,7 +271,7 @@ int main() {
270271
//store the trajectory in the csv file (order matters)
271272
traj_file << x(0) << "," << x(1) << "," << x(2) << "," <<
272273
x_desired(0) << "," << x_desired(1) << "," << x_desired(2) << "," <<
273-
xdot(0) << "," << xdot(1) << "," << xdot(2) << "," << Vmax << endl;
274+
dPhi(0) << "," << dPhi(1) << "," << dPhi(2) << endl;
274275

275276

276277
// **********************

read_plot.py

+11-13
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
dt = 0.001 #loop frequency (time per loop)
2828

29-
with open('/media/varun/Work/Academics/_Spring 2019/CS 225A/cs225a_hw3/data4b.csv','r') as csvfile:
29+
with open('/media/varun/Work/Academics/_Spring 2019/CS 225A/cs225a_hw3/data3a.csv','r') as csvfile:
3030
plots = csv.reader(csvfile, delimiter=',')
3131
for row in plots:
3232
a.append(float(row[0]))
@@ -36,14 +36,14 @@
3636
d.append(float(row[3]))
3737
e.append(float(row[4]))
3838
f.append(float(row[5]))
39-
39+
4040
g.append(float(row[6]))
4141
h.append(float(row[7]))
4242
i.append(float(row[8]))
43-
43+
'''
4444
j.append(float(row[9]))
4545
k.append(-1*float(row[9]))
46-
46+
'''
4747

4848

4949

@@ -69,27 +69,25 @@
6969
plt.legend()
7070
plt.grid()
7171

72-
7372
plt.subplot(2,1,2)
7473

75-
plt.plot(t,g, label='$\dot x_x$')
76-
plt.plot(t,h,label='$\dot x_y$')
77-
plt.plot(t,i, label='$\dot x_z$')
74+
plt.plot(t,g, label='$d\phi_x$')
75+
plt.plot(t,h,label='$d\phi_y$')
76+
plt.plot(t,i, label='$d\phi_z$')
7877

79-
plt.plot(t,j,'r', label='$ V_{max}$')
80-
plt.plot(t,k,'r', label='$ -V_{max}$')
78+
#plt.plot(t,j,'r', label='$ V_{max}$')
79+
#plt.plot(t,k,'r', label='$ -V_{max}$')
8180

8281

8382

8483

8584
plt.xlabel('Time [s]')
86-
plt.ylabel('Velocity [m/s]')
85+
plt.ylabel('Angle Error [rad]')
8786
plt.legend()
8887
plt.grid()
8988

9089

91-
plt.savefig('/media/varun/Work/Academics/_Spring 2019/CS 225A/cs225a_hw3/plot4b.png')
92-
90+
plt.savefig('/media/varun/Work/Academics/_Spring 2019/CS 225A/cs225a_hw3/plot3a_v2.png')
9391

9492

9593

0 commit comments

Comments
 (0)