Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 compatible #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quadPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def plot_quad_3d(waypoints, get_world_frame):
frames=400, interval=10, blit=False)

if len(sys.argv) > 1 and sys.argv[1] == 'save':
print "saving"
print("saving")
an.save('sim.gif', dpi=80, writer='imagemagick', fps=60)
else:
plt.show()
Expand Down
2 changes: 1 addition & 1 deletion runsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

animation_frequency = 50
control_frequency = 200 # Hz for attitude control loop
control_iterations = control_frequency / animation_frequency
control_iterations = (int)(control_frequency / animation_frequency)
dt = 1.0 / control_frequency
time = [0.0]

Expand Down
6 changes: 3 additions & 3 deletions test/test_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def test_run(self):
time = 0.0
des_state = trajGen.genLine(time)
F, M = controller.run(quad, des_state)
print "des_state", des_state
print "F", F
print "M", M
print("des_state", des_state)
print("F", F)
print("M", M)

if __name__ == '__main__':
unittest.main()
4 changes: 2 additions & 2 deletions test/test_quadcopter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_state_dot(self):
dt = 0.01

s_dot = quadcopter.state_dot(quadcopter.state,dt,F,M)
print "s_dot", s_dot
print("s_dot", s_dot)

def test_update(self):
pos = (0,0,0)
Expand All @@ -41,7 +41,7 @@ def test_attitude(self):
attitude = [0,0,np.pi/2]
quadcopter = Quadcopter(pos, attitude)
attitude = quadcopter.attitude()
print "attitude", attitude
print("attitude", attitude)

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion test/test_quaternion.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_as_v_thta(self):
expected_v = np.array(x)
expected_theta = np.pi/2
actual_v, actual_theta = q.as_v_theta()
print actual_v, actual_theta, expected_v
print(actual_v, actual_theta, expected_v)
self.assertTrue(np.array_equal(expected_v, actual_v))
self.assertEqual(expected_theta, actual_theta)

Expand Down
2 changes: 1 addition & 1 deletion test/test_trajGen3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_desired_state_size(self):
self.assertEqual(desired_state.vel.shape, (3,))
self.assertEqual(desired_state.acc.shape, (3,))
des_x_dot, des_y_dot, des_z_dot = desired_state.vel
print "desired_state", desired_state
print("desired_state", desired_state)

if __name__ == '__main__':
unittest.main()
4 changes: 2 additions & 2 deletions test/test_waypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
def get_full_trajectory():
T = np.linspace(0, 100, 1000)
waypoints = trajGen3D.get_helix_waypoints(0, 9)
print "T", T
print "waypoints", waypoints
print("T", T)
print("waypoints", waypoints)

full_traj = np.zeros((T.size,3))
for i, t in enumerate(T):
Expand Down
2 changes: 1 addition & 1 deletion trajGen3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def generate_trajectory(t, v, waypoints, coeff_x, coeff_y, coeff_z):
if yaw > np.pi:
yaw = yaw - 2*np.pi

# print next_heading, current_heading, "yaw", yaw*180/np.pi, 'pos', pos
# print(next_heading, current_heading, "yaw", yaw*180/np.pi, 'pos', pos
current_heading = next_heading
yawdot = delta_psi / 0.005 # dt is control period
return DesiredState(pos, vel, acc, yaw, yawdot)
Expand Down