Skip to content

Commit 2b41460

Browse files
author
cobot
committed
Pushing to cobot_demo
1 parent dbcd8cd commit 2b41460

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

codebotler.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ def execute(code):
9494
robot_execution_thread = threading.Thread(target=execute_task_program, name="robot_execute", args=[code, robot_interface])
9595
robot_execution_thread.start()
9696

97+
def initiate_place():
98+
global ros_available
99+
global robot_available
100+
global robot_interface
101+
print("Received initiation request for place operation")
102+
if not ros_available:
103+
print("ROS not available. Ignoring place request.")
104+
elif not robot_available:
105+
print("Robot not available. Ignoring place request.")
106+
else:
107+
from robot_interface.src.robot_client_interface import initiate_place_action
108+
place_thread = threading.Thread(target=initiate_place_action, name="robot_place", args=[robot_interface])
109+
place_thread.start()
110+
97111
async def handle_message(websocket, message, args):
98112
data = json.loads(message)
99113
if data['type'] == 'code':
@@ -110,6 +124,9 @@ async def handle_message(websocket, message, args):
110124
elif data['type'] == 'execute':
111125
print("Executing generated code...")
112126
execute(data['code'])
127+
elif data['type'] == 'place':
128+
print("Initiating place operation...")
129+
initiate_place()
113130
else:
114131
print("Unknown message type: " + data['type'])
115132

0 commit comments

Comments
 (0)