adding # pragma: no cover

This commit is contained in:
Atsushi Sakai
2019-02-03 11:24:53 +09:00
parent af854d6d1a
commit aefa8990dd
7 changed files with 16 additions and 34 deletions

View File

@@ -22,7 +22,7 @@ class NLinkArm(object):
self.lim = sum(link_lengths)
self.goal = np.array(goal).T
if show_animation:
if show_animation: # pragma: no cover
self.fig = plt.figure()
self.fig.canvas.mpl_connect('button_press_event', self.click)
@@ -46,7 +46,7 @@ class NLinkArm(object):
np.sin(np.sum(self.joint_angles[:i]))
self.end_effector = np.array(self.points[self.n_links]).T
if self.show_animation:
if self.show_animation: # pragma: no cover
self.plot()
def plot(self): # pragma: no cover

View File

@@ -21,7 +21,7 @@ MOVING_TO_GOAL = 2
show_animation = True
def main():
def main(): # pragma: no cover
"""
Creates an arm using the NLinkArm class and uses its inverse kinematics
to move it to the desired position.

View File

@@ -39,8 +39,8 @@ def two_joint_arm(GOAL_TH=0.0, theta1=0.0, theta2=0.0):
try:
theta2_goal = np.arccos(
(x**2 + y**2 - l1**2 - l2**2) / (2 * l1 * l2))
theta1_goal = np.math.atan2(y, x) - np.math.atan2(l2
* np.sin(theta2_goal), (l1 + l2 * np.cos(theta2_goal)))
theta1_goal = np.math.atan2(y, x) - np.math.atan2(l2 *
np.sin(theta2_goal), (l1 + l2 * np.cos(theta2_goal)))
if theta1_goal < 0:
theta2_goal = -theta2_goal
@@ -94,7 +94,7 @@ def ang_diff(theta1, theta2):
return (theta1 - theta2 + np.pi) % (2 * np.pi) - np.pi
def click(event):
def click(event): # pragma: no cover
global x, y
x = event.xdata
y = event.ydata
@@ -111,7 +111,7 @@ def animation():
GOAL_TH=0.01, theta1=theta1, theta2=theta2)
def main():
def main(): # pragma: no cover
fig = plt.figure()
fig.canvas.mpl_connect("button_press_event", click)
two_joint_arm()

View File

@@ -163,7 +163,7 @@ def main():
assert path.T[0][-1] == end_x, "path is invalid"
assert path.T[1][-1] == end_y, "path is invalid"
if show_animation:
if show_animation: # pragma: no cover
fig, ax = plt.subplots()
ax.plot(path.T[0], path.T[1], label="Bezier Path")
ax.plot(control_points.T[0], control_points.T[1],
@@ -198,10 +198,10 @@ def main2():
assert path.T[0][-1] == end_x, "path is invalid"
assert path.T[1][-1] == end_y, "path is invalid"
if show_animation:
if show_animation: # pragma: no cover
plt.plot(path.T[0], path.T[1], label="Offset=" + str(offset))
if show_animation:
if show_animation: # pragma: no cover
plot_arrow(start_x, start_y, start_yaw)
plot_arrow(end_x, end_y, end_yaw)
plt.legend()

View File

@@ -47,7 +47,7 @@ def LQRplanning(sx, sy, gx, gy):
break
# animation
if show_animation:
if show_animation: # pragma: no cover
plt.plot(sx, sy, "or")
plt.plot(gx, gy, "ob")
plt.plot(rx, ry, "-r")
@@ -129,7 +129,7 @@ def main():
rx, ry = LQRplanning(sx, sy, gx, gy)
if show_animation:
if show_animation: # pragma: no cover
plt.plot(sx, sy, "or")
plt.plot(gx, gy, "ob")
plt.plot(rx, ry, "-r")
@@ -137,23 +137,5 @@ def main():
plt.pause(1.0)
def main1():
print(__file__ + " start!!")
sx = 6.0
sy = 6.0
gx = 10.0
gy = 10.0
rx, ry = LQRplanning(sx, sy, gx, gy)
if show_animation:
plt.plot(sx, sy, "or")
plt.plot(gx, gy, "ob")
plt.plot(rx, ry, "-r")
plt.axis("equal")
plt.show()
if __name__ == '__main__':
main()

View File

@@ -167,7 +167,7 @@ class RRT():
def calc_dist_to_goal(self, x, y):
return np.linalg.norm([x - self.end.x, y - self.end.y])
def DrawGraph(self, rnd=None):
def DrawGraph(self, rnd=None): # pragma: no cover
plt.clf()
if rnd is not None:
plt.plot(rnd[0], rnd[1], "^k")
@@ -244,7 +244,7 @@ def main():
path = rrt.Planning(animation=show_animation)
# Draw final path
if show_animation:
if show_animation: # pragma: no cover
rrt.DrawGraph()
plt.plot([x for (x, y) in path], [y for (x, y) in path], '-r')
plt.grid(True)

View File

@@ -202,7 +202,7 @@ class RRT():
# print("rewire")
self.nodeList[i] = tNode
def DrawGraph(self, rnd=None):
def DrawGraph(self, rnd=None): # pragma: no cover
"""
Draw Graph
"""
@@ -288,7 +288,7 @@ def main():
path = rrt.Planning(animation=show_animation)
# Draw final path
if show_animation:
if show_animation: # pragma: no cover
rrt.DrawGraph()
plt.plot([x for (x, y) in path], [y for (x, y) in path], '-r')
plt.grid(True)