-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create velocity_updater.py Basic framework of VelocityUpdater class, just applies constant acceleration to the buggy * updated engine, keyboard import erroring * added publisher/subscriber for manual velocity (can publish via foxglove node) * fixed python reqs * cleaned up comments * integrated manual controller with simulated control * removed print debugs + bound scale to arrow keys * reversed binding * final cleanup --------- Co-authored-by: PatXue <[email protected]> Co-authored-by: TiaSinghania <[email protected]>
- Loading branch information
1 parent
4826444
commit 061e952
Showing
7 changed files
with
68 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ pymap3d==3.0.1 | |
scipy==1.10.1 | ||
trimesh==3.23.5 | ||
utm==0.7.0 | ||
keyboard==0.13.5 | ||
tk==0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#! /usr/bin/env python3 | ||
import sys | ||
import threading | ||
import tkinter as tk | ||
from controller_2d import Controller | ||
import rospy | ||
|
||
class VelocityUI: | ||
def __init__(self, init_vel: float, buggy_name: str): | ||
self.buggy_vel = 0 # So the buggy doesn't start moving without user input | ||
self.controller = Controller(buggy_name) | ||
self.lock = threading.Lock() | ||
|
||
self.root = tk.Tk() | ||
|
||
self.root.title('Manual Velocity') | ||
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.pack() | ||
|
||
self.root.bind("<Up>", lambda i: self.scale.set(self.scale.get() + 2)) | ||
self.root.bind("<Down>", lambda d: self.scale.set(self.scale.get() - 2)) | ||
|
||
def step(self): | ||
"""sets velocity of buggy to the current scale value | ||
called once every tick | ||
""" | ||
self.root.update_idletasks() | ||
self.root.update() | ||
'''Update velocity of buggy''' | ||
self.buggy_vel = self.scale.get()/10 # so we can set velocity with 0.1 precision | ||
self.controller.set_velocity(self.buggy_vel) | ||
|
||
if __name__ == "__main__": | ||
rospy.init_node("velocity_ui") | ||
init_vel = float(sys.argv[1]) | ||
buggy_name = sys.argv[2] | ||
vel = VelocityUI(init_vel, buggy_name) | ||
rate = rospy.Rate(100) | ||
while not rospy.is_shutdown(): | ||
vel.step() | ||
rate.sleep() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters