Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,9 @@ physicsClient = p.connect(p.DIRECT)
|
|
| 10 |
p.setAdditionalSearchPath(pybullet_data.getDataPath())
|
| 11 |
p.setGravity(0, 0, -9.8)
|
| 12 |
p.loadURDF("plane.urdf")
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def get_panda_joints(robot):
|
| 16 |
revolute, finger = [], []
|
|
@@ -76,21 +78,18 @@ with gr.Blocks(title="Live Robot Control with Reset") as demo:
|
|
| 76 |
img_output = gr.Image(type="filepath", label="Simulation View")
|
| 77 |
text_output = gr.Textbox(label="Joint States")
|
| 78 |
|
| 79 |
-
#
|
| 80 |
-
def live_update(
|
| 81 |
-
return render_sim([
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
j4.change(live_update, inputs=[j1, j2, j3, j4, gripper], outputs=[img_output, text_output])
|
| 87 |
-
gripper.change(live_update, inputs=[j1, j2, j3, j4, gripper], outputs=[img_output, text_output])
|
| 88 |
|
| 89 |
# Reset button
|
| 90 |
def reset():
|
| 91 |
return render_sim([0, 0, 0, 0], 0.02)
|
| 92 |
|
| 93 |
-
|
| 94 |
-
reset_btn.click(fn=reset, inputs=[], outputs=[img_output, text_output])
|
| 95 |
|
| 96 |
demo.launch()
|
|
|
|
| 10 |
p.setAdditionalSearchPath(pybullet_data.getDataPath())
|
| 11 |
p.setGravity(0, 0, -9.8)
|
| 12 |
p.loadURDF("plane.urdf")
|
| 13 |
+
|
| 14 |
+
# 🔒 Fix the base of the robot to the ground
|
| 15 |
+
robot = p.loadURDF("franka_panda/panda.urdf", basePosition=[0, 0, 0], useFixedBase=True)
|
| 16 |
|
| 17 |
def get_panda_joints(robot):
|
| 18 |
revolute, finger = [], []
|
|
|
|
| 78 |
img_output = gr.Image(type="filepath", label="Simulation View")
|
| 79 |
text_output = gr.Textbox(label="Joint States")
|
| 80 |
|
| 81 |
+
# Live update function
|
| 82 |
+
def live_update(j1_val, j2_val, j3_val, j4_val, grip_val):
|
| 83 |
+
return render_sim([j1_val, j2_val, j3_val, j4_val], grip_val)
|
| 84 |
|
| 85 |
+
# Connect sliders to live update
|
| 86 |
+
for slider in [j1, j2, j3, j4, gripper]:
|
| 87 |
+
slider.change(live_update, inputs=[j1, j2, j3, j4, gripper], outputs=[img_output, text_output])
|
|
|
|
|
|
|
| 88 |
|
| 89 |
# Reset button
|
| 90 |
def reset():
|
| 91 |
return render_sim([0, 0, 0, 0], 0.02)
|
| 92 |
|
| 93 |
+
gr.Button("🔄 Reset Robot").click(fn=reset, inputs=[], outputs=[img_output, text_output])
|
|
|
|
| 94 |
|
| 95 |
demo.launch()
|