Skip to content

Commit

Permalink
fix floating point issue in python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
betab0t committed Apr 17, 2019
1 parent a7c9466 commit dc234ff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nodes/simple_ball_tracker_node.py
Expand Up @@ -117,7 +117,7 @@ def _calc_proportional_z_angle_velocity(image_width, red_ball_center_x, p=300):
def is_ball_in_tolerance():
return (image_width / 2 - (image_width / 12)) < red_ball_center_x < (image_width / 2 + (image_width / 12))

return 0.0 if is_ball_in_tolerance() else float(-(red_ball_center_x - (image_width / 2)) / p)
return 0.0 if is_ball_in_tolerance() else float(-(red_ball_center_x - (image_width / 2))) / float(p)

def _rotate_robot(self, z_axis_velocity):
self.cmd_vel_msg.angular.z = float(z_axis_velocity)
Expand All @@ -127,7 +127,7 @@ def _stop_robot(self):
self._rotate_robot(0.0)

def _calc_desired_z_axis_velocity(self, red_ball_center, image):
_, width = image.shape[:2]
height, width = image.shape[:2]
cx, cy = red_ball_center
return self._calc_proportional_z_angle_velocity(width, cx)

Expand Down

0 comments on commit dc234ff

Please sign in to comment.