Skip to content

Commit c528c1f

Browse files
fix: added tracebacks (#29)
1 parent 1b604e4 commit c528c1f

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

examples/2_collect_teleop_data_with_neuracore.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def log_to_neuracore_on_change_callback(
8585
else:
8686
print(f"\n⚠️ Unknown logging function: {name}")
8787
except Exception as e:
88-
print(f"\n⚠️ Failed to call {name} to Neuracore: {e}")
88+
print(f"\n⚠️ Failed to call {name} to Neuracore. Exception: {e}")
89+
print("Traceback:")
90+
traceback.print_exc()
8991

9092

9193
def on_button_a_pressed() -> None:
@@ -132,14 +134,18 @@ def on_button_rj_pressed() -> None:
132134
nc.start_recording()
133135
print("✓ 🔴 Recording started (Button RJ)")
134136
except Exception as e:
135-
print(f"✗ Failed to start recording: {e}")
137+
print(f"✗ Failed to start recording. Exception: {e}")
138+
print("Traceback:")
139+
traceback.print_exc()
136140
else:
137141
# Stop recording
138142
try:
139143
nc.stop_recording()
140144
print("✓ ⏹️ Recording stopped (Button RJ)")
141145
except Exception as e:
142-
print(f"✗ Failed to stop recording: {e}")
146+
print(f"✗ Failed to stop recording. Exception: {e}")
147+
print("Traceback:")
148+
traceback.print_exc()
143149

144150

145151
if __name__ == "__main__":
@@ -298,11 +304,9 @@ def on_button_rj_pressed() -> None:
298304
except KeyboardInterrupt:
299305
print("\n👋 Interrupt received - shutting down gracefully...")
300306
except Exception as e:
301-
print(f"\n❌ Demo error: {e}")
302-
import traceback
303-
307+
print(f"\n❌ Demo error. Exception: {e}")
308+
print("Traceback:")
304309
traceback.print_exc()
305-
306310
# Cleanup
307311
print("\n🧹 Cleaning up...")
308312

@@ -313,7 +317,9 @@ def on_button_rj_pressed() -> None:
313317
nc.cancel_recording()
314318
print("✓ Recording cancelled")
315319
except Exception as e:
316-
print(f"⚠️ Error cancelling recording: {e}")
320+
print(f"⚠️ Error cancelling recording. Exception: {e}")
321+
print("Traceback:")
322+
traceback.print_exc()
317323

318324
# shutdown threads
319325
nc.logout()

piper_controller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ def cleanup(self) -> None:
135135
and self.piper is not None
136136
and self.piper.get_connect_status()
137137
):
138-
self.graceful_stop() # this will disable the robot as well
138+
if self.is_robot_enabled():
139+
self.graceful_stop() # this will disable the robot as well
139140
self.piper.DisconnectPort()
140141
print("✓ Robot disconnected")
141142

0 commit comments

Comments
 (0)