mirror of
https://github.com/AtsushiSakai/PythonRobotics.git
synced 2026-04-22 03:00:22 -04:00
code clean up for LGTM
This commit is contained in:
@@ -73,8 +73,8 @@ def quad_sim(x_c, y_c, z_c):
|
||||
# des_x_pos = calculate_position(x_c[i], t)
|
||||
# des_y_pos = calculate_position(y_c[i], t)
|
||||
des_z_pos = calculate_position(z_c[i], t)
|
||||
des_x_vel = calculate_velocity(x_c[i], t)
|
||||
des_y_vel = calculate_velocity(y_c[i], t)
|
||||
# des_x_vel = calculate_velocity(x_c[i], t)
|
||||
# des_y_vel = calculate_velocity(y_c[i], t)
|
||||
des_z_vel = calculate_velocity(z_c[i], t)
|
||||
des_x_acc = calculate_acceleration(x_c[i], t)
|
||||
des_y_acc = calculate_acceleration(y_c[i], t)
|
||||
|
||||
@@ -576,7 +576,7 @@ def plot_animation(X, U): # pragma: no cover
|
||||
axis3d_equal(X[2, :], X[3, :], X[1, :], ax)
|
||||
|
||||
rx, ry, rz = X[1:4, k]
|
||||
vx, vy, vz = X[4:7, k]
|
||||
# vx, vy, vz = X[4:7, k]
|
||||
qw, qx, qy, qz = X[7:11, k]
|
||||
|
||||
CBI = np.array([
|
||||
@@ -618,8 +618,6 @@ def main():
|
||||
integrator = Integrator(m, K)
|
||||
problem = SCProblem(m, K)
|
||||
|
||||
last_linear_cost = None
|
||||
|
||||
converged = False
|
||||
w_delta = W_DELTA
|
||||
for it in range(iterations):
|
||||
@@ -633,7 +631,7 @@ def main():
|
||||
X_last=X, U_last=U, sigma_last=sigma,
|
||||
weight_sigma=W_SIGMA, weight_nu=W_NU,
|
||||
weight_delta=w_delta, weight_delta_sigma=W_DELTA_SIGMA)
|
||||
info = problem.solve()
|
||||
problem.solve()
|
||||
|
||||
X = problem.get_variable('X')
|
||||
U = problem.get_variable('U')
|
||||
|
||||
@@ -53,7 +53,7 @@ def animate(grid, arm, route):
|
||||
theta2 = 2 * pi * node[1] / M - pi
|
||||
arm.update_joints([theta1, theta2])
|
||||
plt.subplot(1, 2, 2)
|
||||
arm.plot(plt, obstacles=obstacles)
|
||||
arm.plot_arm(plt, obstacles=obstacles)
|
||||
plt.xlim(-2.0, 2.0)
|
||||
plt.ylim(-3.0, 3.0)
|
||||
plt.show()
|
||||
@@ -272,7 +272,7 @@ class NLinkArm(object):
|
||||
|
||||
self.end_effector = np.array(self.points[self.n_links]).T
|
||||
|
||||
def plot(self, myplt, obstacles=[]): # pragma: no cover
|
||||
def plot_arm(self, myplt, obstacles=[]): # pragma: no cover
|
||||
myplt.cla()
|
||||
|
||||
for obstacle in obstacles:
|
||||
|
||||
@@ -222,7 +222,6 @@ def extend_path(cx, cy, cyaw):
|
||||
|
||||
def main():
|
||||
# target course
|
||||
import numpy as np
|
||||
cx = np.arange(0, 50, 0.1)
|
||||
cy = [math.sin(ix / 5.0) * ix / 2.0 for ix in cx]
|
||||
|
||||
|
||||
@@ -73,7 +73,6 @@ def solve_DARE(A, B, Q, R):
|
||||
Xn = A.T * X * A - A.T * X * B * \
|
||||
la.inv(R + B.T * X * B) * B.T * X * A + Q
|
||||
if (abs(Xn - X)).max() < eps:
|
||||
X = Xn
|
||||
break
|
||||
X = Xn
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ def main():
|
||||
plt.axis("equal")
|
||||
|
||||
# path generation
|
||||
rx, ry = potential_field_planning(
|
||||
_, _ = potential_field_planning(
|
||||
sx, sy, gx, gy, ox, oy, grid_size, robot_radius)
|
||||
|
||||
if show_animation:
|
||||
|
||||
@@ -5,15 +5,18 @@ Path tracking simulation with LQR steering control and PID speed control.
|
||||
author Atsushi Sakai (@Atsushi_twi)
|
||||
|
||||
"""
|
||||
|
||||
import scipy.linalg as la
|
||||
import matplotlib.pyplot as plt
|
||||
import math
|
||||
import numpy as np
|
||||
import sys
|
||||
sys.path.append("../../PathPlanning/CubicSpline/")
|
||||
|
||||
import numpy as np
|
||||
import math
|
||||
import matplotlib.pyplot as plt
|
||||
import scipy.linalg as la
|
||||
import cubic_spline_planner
|
||||
try:
|
||||
import cubic_spline_planner
|
||||
except:
|
||||
raise
|
||||
|
||||
|
||||
Kp = 1.0 # speed proportional gain
|
||||
|
||||
@@ -76,7 +79,6 @@ def solve_DARE(A, B, Q, R):
|
||||
Xn = A.T @ X @ A - A.T @ X @ B @ \
|
||||
la.inv(R + B.T @ X @ B) @ B.T @ X @ A + Q
|
||||
if (abs(Xn - X)).max() < eps:
|
||||
X = Xn
|
||||
break
|
||||
X = Xn
|
||||
|
||||
@@ -206,8 +208,8 @@ def closed_loop_prediction(cx, cy, cyaw, ck, speed_profile, goal):
|
||||
plt.plot(cx[target_ind], cy[target_ind], "xg", label="target")
|
||||
plt.axis("equal")
|
||||
plt.grid(True)
|
||||
plt.title("speed[km/h]:" + str(round(state.v * 3.6, 2)) +
|
||||
",target index:" + str(target_ind))
|
||||
plt.title("speed[km/h]:" + str(round(state.v * 3.6, 2))
|
||||
+ ",target index:" + str(target_ind))
|
||||
plt.pause(0.0001)
|
||||
|
||||
return t, x, y, yaw, v
|
||||
|
||||
@@ -140,6 +140,7 @@ def main():
|
||||
assert lastIndex >= target_ind, "Cannot goal"
|
||||
|
||||
if show_animation:
|
||||
plt.cla()
|
||||
plt.plot(cx, cy, ".r", label="course")
|
||||
plt.plot(x, y, "-b", label="trajectory")
|
||||
plt.legend()
|
||||
@@ -148,7 +149,7 @@ def main():
|
||||
plt.axis("equal")
|
||||
plt.grid(True)
|
||||
|
||||
flg, ax = plt.subplots(1)
|
||||
plt.subplots(1)
|
||||
plt.plot(t, [iv * 3.6 for iv in v], "-r")
|
||||
plt.xlabel("Time[s]")
|
||||
plt.ylabel("Speed[km/h]")
|
||||
|
||||
Reference in New Issue
Block a user