add a release_all_servos button
Browse fileshttps://claude.site/artifacts/24511f1e-9114-4599-b43a-d47ff2953a27
app.py
CHANGED
@@ -285,6 +285,22 @@ def control_gripper(user_id, gripper_value, movement_speed):
|
|
285 |
logger.debug(f"Gripper control blocked, user {user_id} not authorized")
|
286 |
return None, queue_status_msg
|
287 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
def set_coords_to_current(user_id):
|
289 |
logger.info(f"User {user_id} requesting to set coordinates to current position")
|
290 |
to_execute, queue_status_msg = authenticate_user(user_id)
|
@@ -361,6 +377,13 @@ with gr.Blocks(css=CSS) as app:
|
|
361 |
speed_gripper = gr.Slider(value=50.0, minimum=0.0, maximum=100.0, step=1.0, label="Movement speed")
|
362 |
gripper_control_button = gr.Button("Send gripper command")
|
363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
with gr.Row():
|
365 |
# ANGLE PANEL
|
366 |
with gr.Column(elem_id="col"):
|
@@ -460,6 +483,13 @@ with gr.Blocks(css=CSS) as app:
|
|
460 |
inputs = [user_id],
|
461 |
outputs = [status_text]
|
462 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
463 |
|
464 |
app.load(
|
465 |
namesgenerator.get_random_name,
|
|
|
285 |
logger.debug(f"Gripper control blocked, user {user_id} not authorized")
|
286 |
return None, queue_status_msg
|
287 |
|
288 |
+
def release_servos(user_id):
|
289 |
+
logger.info(f"User {user_id} requesting to release all servos")
|
290 |
+
to_execute, queue_status_msg = authenticate_user(user_id)
|
291 |
+
if to_execute:
|
292 |
+
try:
|
293 |
+
resp = client.release_all_servos()
|
294 |
+
resp["command"] = "control/release_servos"
|
295 |
+
logger.info(f"Release servos command successful: {resp}")
|
296 |
+
return json.dumps(resp, indent=4), queue_status_msg
|
297 |
+
except Exception as e:
|
298 |
+
logger.error(f"Error releasing servos: {str(e)}", exc_info=True)
|
299 |
+
return json.dumps({"success": False, "error": str(e), "command": "control/release_servos"}, indent=4), queue_status_msg
|
300 |
+
else:
|
301 |
+
logger.debug(f"Release servos command blocked, user {user_id} not authorized")
|
302 |
+
return None, queue_status_msg
|
303 |
+
|
304 |
def set_coords_to_current(user_id):
|
305 |
logger.info(f"User {user_id} requesting to set coordinates to current position")
|
306 |
to_execute, queue_status_msg = authenticate_user(user_id)
|
|
|
377 |
speed_gripper = gr.Slider(value=50.0, minimum=0.0, maximum=100.0, step=1.0, label="Movement speed")
|
378 |
gripper_control_button = gr.Button("Send gripper command")
|
379 |
|
380 |
+
# Add Release Servos section
|
381 |
+
with gr.Row():
|
382 |
+
with gr.Column(elem_id="col"):
|
383 |
+
gr.Markdown("## Release Servos")
|
384 |
+
gr.Markdown("Use this button to release all servos, allowing the robot arm to be moved freely by hand.")
|
385 |
+
release_servos_button = gr.Button("Release All Servos", variant="primary")
|
386 |
+
|
387 |
with gr.Row():
|
388 |
# ANGLE PANEL
|
389 |
with gr.Column(elem_id="col"):
|
|
|
483 |
inputs = [user_id],
|
484 |
outputs = [status_text]
|
485 |
)
|
486 |
+
|
487 |
+
# Add event handler for the release servos button
|
488 |
+
release_servos_button.click(
|
489 |
+
release_servos,
|
490 |
+
inputs = [user_id],
|
491 |
+
outputs = [response, status_text]
|
492 |
+
)
|
493 |
|
494 |
app.load(
|
495 |
namesgenerator.get_random_name,
|