From aefa8990ddaf84f090a38cb2b21f3cb8f2b87414 Mon Sep 17 00:00:00 2001 From: Atsushi Sakai Date: Sun, 3 Feb 2019 11:24:53 +0900 Subject: [PATCH] adding # pragma: no cover --- .../n_joint_arm_to_point_control/NLinkArm.py | 4 ++-- .../n_joint_arm_to_point_control.py | 2 +- .../two_joint_arm_to_point_control.py | 8 +++---- PathPlanning/BezierPath/bezier_path.py | 6 ++--- PathPlanning/LQRPlanner/LQRplanner.py | 22 ++----------------- PathPlanning/RRTDubins/rrt_dubins.py | 4 ++-- PathPlanning/RRTStarDubins/rrt_star_dubins.py | 4 ++-- 7 files changed, 16 insertions(+), 34 deletions(-) diff --git a/ArmNavigation/n_joint_arm_to_point_control/NLinkArm.py b/ArmNavigation/n_joint_arm_to_point_control/NLinkArm.py index e8f558db..8ed12c56 100644 --- a/ArmNavigation/n_joint_arm_to_point_control/NLinkArm.py +++ b/ArmNavigation/n_joint_arm_to_point_control/NLinkArm.py @@ -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 diff --git a/ArmNavigation/n_joint_arm_to_point_control/n_joint_arm_to_point_control.py b/ArmNavigation/n_joint_arm_to_point_control/n_joint_arm_to_point_control.py index a04c64cc..b232ab33 100644 --- a/ArmNavigation/n_joint_arm_to_point_control/n_joint_arm_to_point_control.py +++ b/ArmNavigation/n_joint_arm_to_point_control/n_joint_arm_to_point_control.py @@ -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. diff --git a/ArmNavigation/two_joint_arm_to_point_control/two_joint_arm_to_point_control.py b/ArmNavigation/two_joint_arm_to_point_control/two_joint_arm_to_point_control.py index 23ade401..e674ae8a 100644 --- a/ArmNavigation/two_joint_arm_to_point_control/two_joint_arm_to_point_control.py +++ b/ArmNavigation/two_joint_arm_to_point_control/two_joint_arm_to_point_control.py @@ -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() diff --git a/PathPlanning/BezierPath/bezier_path.py b/PathPlanning/BezierPath/bezier_path.py index 48b4c75b..fb6050d9 100644 --- a/PathPlanning/BezierPath/bezier_path.py +++ b/PathPlanning/BezierPath/bezier_path.py @@ -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() diff --git a/PathPlanning/LQRPlanner/LQRplanner.py b/PathPlanning/LQRPlanner/LQRplanner.py index 78251a44..fef1020e 100644 --- a/PathPlanning/LQRPlanner/LQRplanner.py +++ b/PathPlanning/LQRPlanner/LQRplanner.py @@ -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() diff --git a/PathPlanning/RRTDubins/rrt_dubins.py b/PathPlanning/RRTDubins/rrt_dubins.py index 976d3c47..09e35ae8 100644 --- a/PathPlanning/RRTDubins/rrt_dubins.py +++ b/PathPlanning/RRTDubins/rrt_dubins.py @@ -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) diff --git a/PathPlanning/RRTStarDubins/rrt_star_dubins.py b/PathPlanning/RRTStarDubins/rrt_star_dubins.py index b58e3453..0494bbab 100644 --- a/PathPlanning/RRTStarDubins/rrt_star_dubins.py +++ b/PathPlanning/RRTStarDubins/rrt_star_dubins.py @@ -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)