From 23b0db0356a17f325e9d7fe7cf66c1c7cdcb384d Mon Sep 17 00:00:00 2001 From: Joyce Date: Wed, 13 Nov 2024 13:14:42 -0500 Subject: [PATCH] fixed format errors based on pylint message --- rb_ws/src/buggy/buggy/simulator/velocity_ui.py | 13 ++++++++----- rb_ws/src/buggy/buggy/simulator/velocity_updater.py | 9 +++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/rb_ws/src/buggy/buggy/simulator/velocity_ui.py b/rb_ws/src/buggy/buggy/simulator/velocity_ui.py index db7a855..3070439 100644 --- a/rb_ws/src/buggy/buggy/simulator/velocity_ui.py +++ b/rb_ws/src/buggy/buggy/simulator/velocity_ui.py @@ -9,9 +9,9 @@ class VelocityUI(Node): def __init__(self, init_vel: float, buggy_name: str): super().__init__('velocity_ui') - + # So the buggy doesn't start moving without user input - self.buggy_vel = 0 + self.buggy_vel = 0 self.controller = Controller(buggy_name) self.lock = threading.Lock() @@ -21,14 +21,16 @@ def __init__(self, init_vel: float, buggy_name: str): self.root.geometry('600x100') self.root.configure(background='#342d66') - self.scale = tk.Scale(self.root, from_=0, to=300, orient=tk.HORIZONTAL, length=500, width=30) + self.scale = tk.Scale(self.root, from_=0, to=300, orient=tk.HORIZONTAL, + length=500, width=30) self.scale.pack() self.root.bind("", lambda i: self.scale.set(self.scale.get() + 2)) self.root.bind("", lambda d: self.scale.set(self.scale.get() - 2)) # ROS2 timer for stepping - self.create_timer(0.01, self.step) # equivalent to 100Hz (100 times per second) + # 0.01 is equivalent to 100Hz (100 times per second) + self.create_timer(0.01, self.step) def step(self): # Sets the velocity of the buggy to the current scale value @@ -36,7 +38,8 @@ def step(self): self.root.update_idletasks() self.root.update() # Update velocity of the buggy - self.buggy_vel = self.scale.get() / 10 # set velocity with 0.1 precision + # '/10' set velocity with 0.1 precision + self.buggy_vel = self.scale.get() / 10 self.controller.set_velocity(self.buggy_vel) def main(args=None): diff --git a/rb_ws/src/buggy/buggy/simulator/velocity_updater.py b/rb_ws/src/buggy/buggy/simulator/velocity_updater.py index 5c3b6ae..4bc628b 100644 --- a/rb_ws/src/buggy/buggy/simulator/velocity_updater.py +++ b/rb_ws/src/buggy/buggy/simulator/velocity_updater.py @@ -1,24 +1,25 @@ #! /usr/bin/env python3 +import sys +import math import rclpy from rclpy.node import Node -import sys from controller_2d import Controller from geometry_msgs.msg import Pose from geometry_msgs.msg import Point import threading -import math class VelocityUpdater(Node): RATE = 100 # Bubbles for updating acceleration based on position # represented as 4-tuples: (x-pos, y-pos, radius, acceleration) + # need further update such as more data or import data from certain files CHECKPOINTS = [ (589701, 4477160, 20, 0.5) ] def __init__(self, init_vel: float, buggy_name: str): super().__init__('vel_updater') - + self.buggy_vel = init_vel self.accel = 0.0 self.position = Point() @@ -52,7 +53,7 @@ def calculate_accel(self): in self.CHECKPOINTS, and update acceleration of buggy accordingly ''' for (x, y, r, a) in self.CHECKPOINTS: - dist = math.sqrt((x - self.position.x)**2 + (y - self.position.y)**2) + dist = math.sqrt((x-self.position.x)**2 + (y-self.position.y)**2) if dist < r: self.accel = a break