Skip to content

Commit

Permalink
Fix: Change dobot demo from Process to Thread
Browse files Browse the repository at this point in the history
  • Loading branch information
ansonnn07 committed Feb 4, 2022
1 parent 5ff05ed commit 9ee372e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/lib/dobot_arm_demo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
else:
from .dobot_api import dobot_api_dashboard, dobot_api_feedback, MyType

# from threading import Thread
from multiprocessing import Process
from threading import Thread
# from multiprocessing import Process
import numpy as np
from time import sleep

Expand Down Expand Up @@ -328,7 +328,7 @@ def move_and_publish_view(client_dashboard: dobot_api_dashboard, client_feedback
DobotTask.P2_140: move_for_p2_140
}

client = get_mqtt_client()
client = get_mqtt_client('dobot_demo')
client.connect(conf.broker, port=conf.port)
client.loop_start()

Expand Down Expand Up @@ -401,7 +401,7 @@ def data_feedback(client_feedback: dobot_api_feedback):
print('q_actual', np.around(a['q_actual'], decimals=4))


def run(conf: MQTTConfig, task: DobotTask = DobotTask.Box) -> Tuple[bool, Process]:
def run(conf: MQTTConfig, task: DobotTask = DobotTask.Box) -> Tuple[bool, Thread]:
if task == DobotTask.DEBUG:
logger.debug("Running debug publishing")
move_fn = debug_publish
Expand All @@ -419,13 +419,13 @@ def run(conf: MQTTConfig, task: DobotTask = DobotTask.Box) -> Tuple[bool, Proces
move_fn = move_and_publish_view
args = (client_dashboard, client_feedback, conf, task)

p1 = Process(target=move_fn, args=args)
p1 = Thread(target=move_fn, args=args)
p1.start()

return True, p1

# Not using all these for our vision inspection app
# p2 = Process(target=data_feedback, args=(client_feedback,))
# p2 = Thread(target=data_feedback, args=(client_feedback,))
# p2.daemon = True
# p2.start()
# p1.join()
Expand Down
6 changes: 3 additions & 3 deletions src/lib/pages/sub_pages/deployment_page/deployment_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1602,9 +1602,9 @@ def update_publish_frame_conf(publish_frame: bool):
# and reset back to None
session_state.check_labels = None
logger.info("Label checking process has finished")
if dobot_process is not None:
# gracefully kill the dobot_demo's Process
dobot_process.kill()
# if dobot_process is not None:
# # gracefully kill the dobot_demo's Process
# dobot_process.kill()
continue

if use_multi_cam:
Expand Down

0 comments on commit 9ee372e

Please sign in to comment.