Cleanup comments and add back call to spin()
This commit is contained in:
@@ -16,7 +16,6 @@ import tkinter as tk
|
|||||||
import math
|
import math
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
import atexit
|
|
||||||
|
|
||||||
def translate(val, lmin, lmax, rmin, rmax):
|
def translate(val, lmin, lmax, rmin, rmax):
|
||||||
lspan = lmax - lmin
|
lspan = lmax - lmin
|
||||||
@@ -31,7 +30,6 @@ class DrawingApp(tk.Tk):
|
|||||||
self.queue = queue
|
self.queue = queue
|
||||||
self.canvas = tk.Canvas(self, width=400, height=400)
|
self.canvas = tk.Canvas(self, width=400, height=400)
|
||||||
self.canvas.pack(side="top", fill="both", expand=True)
|
self.canvas.pack(side="top", fill="both", expand=True)
|
||||||
#self.canvas.create_line(200,200, 200,200, tags=("line",), arrow="last")
|
|
||||||
self.read_queue()
|
self.read_queue()
|
||||||
|
|
||||||
def create_circle(self, x, y, r, **kwargs):
|
def create_circle(self, x, y, r, **kwargs):
|
||||||
@@ -43,7 +41,7 @@ class DrawingApp(tk.Tk):
|
|||||||
self.after(10, lambda: self.read_queue())
|
self.after(10, lambda: self.read_queue())
|
||||||
return
|
return
|
||||||
p = self.queue.get()
|
p = self.queue.get()
|
||||||
print("last_point->x:{} y:{} z:{}".format(p.x, p.y, p.z))
|
#print("last_point->x:{} y:{} z:{}".format(p.x, p.y, p.z))
|
||||||
r = 5
|
r = 5
|
||||||
x = translate(p.x, -1.0, 0.5, 0, 400)
|
x = translate(p.x, -1.0, 0.5, 0, 400)
|
||||||
y = translate(p.y, 0.5, -1.0, 0, 400)
|
y = translate(p.y, 0.5, -1.0, 0, 400)
|
||||||
@@ -69,16 +67,12 @@ class LogPen(Node):
|
|||||||
callback_group=self._callback_group,
|
callback_group=self._callback_group,
|
||||||
)
|
)
|
||||||
self.get_logger().info("Initialization successful.")
|
self.get_logger().info("Initialization successful.")
|
||||||
#atexit.register(self.cleanup)
|
|
||||||
#def cleanup(self):
|
|
||||||
#app.quit()
|
|
||||||
|
|
||||||
def pen_position_callback(self, msg: Odometry):
|
def pen_position_callback(self, msg: Odometry):
|
||||||
"""
|
"""
|
||||||
Log position of pen
|
Log position of pen
|
||||||
"""
|
"""
|
||||||
p = msg.pose.pose.position
|
p = msg.pose.pose.position
|
||||||
#self.get_logger().info("x:{} y:{} z:{}".format(p.x, p.y, p.z))
|
self.get_logger().info("x:{} y:{} z:{}".format(p.x, p.y, p.z))
|
||||||
self.queue.put(p)
|
self.queue.put(p)
|
||||||
|
|
||||||
def main(args=None):
|
def main(args=None):
|
||||||
@@ -102,15 +96,10 @@ def start_log_thread(queue=Queue()):
|
|||||||
|
|
||||||
executor = rclpy.executors.MultiThreadedExecutor(2)
|
executor = rclpy.executors.MultiThreadedExecutor(2)
|
||||||
executor.add_node(log_pen)
|
executor.add_node(log_pen)
|
||||||
#executor.spin()
|
executor.spin()
|
||||||
|
|
||||||
#rclpy.shutdown()
|
|
||||||
#exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
#main()
|
|
||||||
|
|
||||||
q = Queue()
|
q = Queue()
|
||||||
|
|
||||||
global app
|
global app
|
||||||
@@ -120,11 +109,6 @@ if __name__ == "__main__":
|
|||||||
log_thread = threading.Thread(target=start_log_thread, args=[q])
|
log_thread = threading.Thread(target=start_log_thread, args=[q])
|
||||||
log_thread.start()
|
log_thread.start()
|
||||||
|
|
||||||
#thread0.join()
|
|
||||||
#thread1 = threading.Thread(target=DrawingApp().mainloop)
|
|
||||||
#thread1.start()
|
|
||||||
#thread1.join()
|
|
||||||
|
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
rclpy.shutdown()
|
rclpy.shutdown()
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user