askuric HF Staff commited on
Commit
bddfca1
·
1 Parent(s): 99efded

removed the ifram update

Browse files
Files changed (4) hide show
  1. Dockerfile +1 -0
  2. README.md +2 -2
  3. app.py +10 -4
  4. robot.py +8 -6
Dockerfile CHANGED
@@ -10,6 +10,7 @@ ENV PIP_ONLY_BINARY=:all:
10
  RUN apt-get update && apt-get install -y --no-install-recommends \
11
  libgl1-mesa-dev \
12
  libglib2.0-0 \
 
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
10
  RUN apt-get update && apt-get install -y --no-install-recommends \
11
  libgl1-mesa-dev \
12
  libglib2.0-0 \
13
+ git \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
  RUN apt-get update && apt-get install -y --no-install-recommends \
README.md CHANGED
@@ -17,11 +17,11 @@ This application provides an interactive 3D viewer for the Reachy Mini robot, al
17
  1. Clone this repository.
18
  2. build the Docker image using the provided Dockerfile.
19
  ```
20
- docker build -t robotics-visual-lab .
21
  ```
22
  3. Run the Docker container
23
  ```
24
- docker run -p 7860:7860 robotics-visual-lab
25
  ```
26
  4. Open your web browser and navigate to `http://localhost:7860` to access the app.
27
 
 
17
  1. Clone this repository.
18
  2. build the Docker image using the provided Dockerfile.
19
  ```
20
+ docker build -t reachy-mini-live .
21
  ```
22
  3. Run the Docker container
23
  ```
24
+ docker run -p 7860:7860 reachy-mini-live
25
  ```
26
  4. Open your web browser and navigate to `http://localhost:7860` to access the app.
27
 
app.py CHANGED
@@ -1,7 +1,9 @@
1
  import gradio as gr
2
  import numpy as np
3
  from robot import LiveReachyMini
4
-
 
 
5
 
6
  # keep one MeshCat session alive
7
  robot = LiveReachyMini()
@@ -81,16 +83,20 @@ with gr.Blocks(css=css, title="Reachy Mini - Interactive Viewer") as demo:
81
  ]
82
 
83
  # ---------- Callbacks ----------
84
-
85
  def on_sliders(*vals):
 
 
 
86
  """Apply first k slider values to robot joints."""
87
  robot.set_target(vals)
88
  # viewer iframe persists; nothing to update there
89
- return gr.update()
 
90
 
91
  # Wire all sliders to the same handler (fixed signature via *vals)
92
  for s in sliders:
93
- s.change(on_sliders, inputs=sliders, outputs=viewer, queue=True)
94
 
95
  # On app load, configure sliders for the initial robot
96
  def _initial():
 
1
  import gradio as gr
2
  import numpy as np
3
  from robot import LiveReachyMini
4
+ import logging
5
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
6
+ import time
7
 
8
  # keep one MeshCat session alive
9
  robot = LiveReachyMini()
 
83
  ]
84
 
85
  # ---------- Callbacks ----------
86
+ last_call_time = time.time()
87
  def on_sliders(*vals):
88
+ global last_call_time
89
+ logging.debug("Time since last on_sliders call: {:.2f} ms".format(((time.time() -last_call_time) % 1e6)*1000))
90
+ last_call_time = time.time()
91
  """Apply first k slider values to robot joints."""
92
  robot.set_target(vals)
93
  # viewer iframe persists; nothing to update there
94
+ dt = time.time() - last_call_time
95
+ logging.debug(f"on_sliders total took {dt*1000:.2f} ms")
96
 
97
  # Wire all sliders to the same handler (fixed signature via *vals)
98
  for s in sliders:
99
+ s.change(on_sliders, inputs=sliders, outputs=None, queue=False, stream_every=0.1)
100
 
101
  # On app load, configure sliders for the initial robot
102
  def _initial():
robot.py CHANGED
@@ -3,6 +3,8 @@ import time
3
 
4
  import meshcat
5
  import meshcat.geometry as g
 
 
6
 
7
  import pinocchio as pin
8
  from pinocchio.visualize import MeshcatVisualizer
@@ -24,7 +26,7 @@ class LiveReachyMini:
24
  """
25
  def __init__(self):
26
  self.vis = meshcat.Visualizer(zmq_url="tcp://127.0.0.1:6001")
27
- print(f"Zmq URL: {self.vis.window.zmq_url}, web URL: {self.vis.window.web_url}")
28
 
29
 
30
  self.rdata = robot
@@ -63,7 +65,7 @@ class LiveReachyMini:
63
  try:
64
  self.viz.display(self.q)
65
  except Exception as e:
66
- print(f"Error setting robot joints: {e}")
67
 
68
 
69
 
@@ -81,19 +83,19 @@ class LiveReachyMini:
81
  T_head = tf.translation_matrix((x, y, z)) @ tf.euler_matrix(
82
  r, p, yaw
83
  )
84
- solver.ik(T_head, body_yaw=vals[0], no_iterations=32)
 
85
  q = solver.robot_ik.state.q.copy()
86
 
87
  # set antennas
88
  q [ self.model.getJointId("left_antenna") + 6 -1 ] = vals[7]
89
  q [ self.model.getJointId("right_antenna") + 6 -1 ] = vals[8]
90
-
91
  try:
92
  self.viz.display(q)
93
  self.q = q
94
  except Exception as e:
95
- print(f"Error setting robot joints: {e}")
96
-
97
 
98
  def neutral(self):
99
  self.q = pin.neutral(self.model)
 
3
 
4
  import meshcat
5
  import meshcat.geometry as g
6
+ import logging
7
+ logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
8
 
9
  import pinocchio as pin
10
  from pinocchio.visualize import MeshcatVisualizer
 
26
  """
27
  def __init__(self):
28
  self.vis = meshcat.Visualizer(zmq_url="tcp://127.0.0.1:6001")
29
+ logging.info(f"Zmq URL: {self.vis.window.zmq_url}, web URL: {self.vis.window.web_url}")
30
 
31
 
32
  self.rdata = robot
 
65
  try:
66
  self.viz.display(self.q)
67
  except Exception as e:
68
+ logging.error(f"Error setting robot joints: {e}")
69
 
70
 
71
 
 
83
  T_head = tf.translation_matrix((x, y, z)) @ tf.euler_matrix(
84
  r, p, yaw
85
  )
86
+ #T_head[2,3] += t # add some vertical bobbing
87
+ solver.ik(T_head, body_yaw=vals[0], no_iterations=5)
88
  q = solver.robot_ik.state.q.copy()
89
 
90
  # set antennas
91
  q [ self.model.getJointId("left_antenna") + 6 -1 ] = vals[7]
92
  q [ self.model.getJointId("right_antenna") + 6 -1 ] = vals[8]
93
+
94
  try:
95
  self.viz.display(q)
96
  self.q = q
97
  except Exception as e:
98
+ logging.error(f"Error setting robot joints: {e}")
 
99
 
100
  def neutral(self):
101
  self.q = pin.neutral(self.model)