Skip to content

Commit

Permalink
Add suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rafal-gorecki committed Nov 7, 2023
1 parent 574b463 commit 8e2477b
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions rosbot_xl_gazebo/test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,13 @@ def start_node_thread(self):
self.timer = self.create_timer(1.0 / 10.0, self.timer_callback)

def is_twist_ok(self, twist: Twist):
x_ok, y_ok, yaw_ok = False, False, False

def are_close_to_each_other(true_value, dest_value, tolerance=self.ACCURACY, eps=0.01):
acceptable_range = dest_value * tolerance
return abs(true_value - dest_value) <= acceptable_range + eps

if are_close_to_each_other(twist.linear.x, self.v_x):
x_ok = True

if are_close_to_each_other(twist.linear.y, self.v_y):
y_ok = True

if are_close_to_each_other(twist.angular.z, self.v_yaw):
yaw_ok = True
x_ok = are_close_to_each_other(twist.linear.x, self.v_x)
y_ok = are_close_to_each_other(twist.linear.y, self.v_y)
yaw_ok = are_close_to_each_other(twist.angular.z, self.v_yaw)

return x_ok and y_ok and yaw_ok

Expand Down

0 comments on commit 8e2477b

Please sign in to comment.