Skip to content

Instantly share code, notes, and snippets.

View chrismatthieu's full-sized avatar
🚀
Hacking on robots!

Chris Matthieu chrismatthieu

🚀
Hacking on robots!
View GitHub Profile
You cannot set a temperature threshold on a RealSense camera via the SDK; instead, you can read the internal temperature and use the information to determine if the camera is operating within safe limits. The laser will automatically adjust power or shut off if the projector temperature exceeds a threshold (around \(60^{\circ }C\)) to protect the camera. You can access the temperature values like rs.option.asic_temperature or rs.option.projector_temperature through the SDK, for example, by using sensor.get_option() in Python. How to get the temperature Start streaming: Begin streaming from the camera using rs.pipeline() and pipeline.start().Get the sensor: Obtain the sensor object for the depth sensor using pipeline_profile.get_device().first_depth_sensor().Access the temperature option: Call sensor.get_option() with the appropriate option. For example, to get the ASIC temperature, use rs.option.asic_temperature.For D400 series: Use rs.option.projector_temperature or rs.option.asic_temperature.For L500 series
import rclpy
from rclpy.node import Node
from geometry_msgs.msg import Twist
class TwistSubscriber(Node):
def __init__(self):
super().__init__('twist_subscriber')
self.subscription = self.create_subscription(
Twist,
'cmd_vel',
import time
import json
def fibonacci_recursive(n):
"""Generate Fibonacci sequence using recursion (inefficient for large n)."""
if n <= 0:
return []
elif n == 1:
return [0]
elif n == 2:
@chrismatthieu
chrismatthieu / factorial.py
Created October 13, 2025 22:09
corebrum demo
import time
import json
def factorial(n):
"""Compute factorial of n recursively."""
if n < 0:
raise ValueError("Factorial is not defined for negative numbers")
if n == 0 or n == 1:
return 1
return n * factorial(n - 1)
#!/bin/bash
set -e # Exit immediately if a command exits with a non-zero status
# --- Helper Functions ---
# Function for timed confirmation, takes message and function name to run
timed_confirm() {
local message=$1
local function_to_run=$2
local timeout=5 # seconds
@chrismatthieu
chrismatthieu / Rules.md
Created September 9, 2025 20:08
National Coding Week (https://codingweek.org/) RealSense Developer Challenge — Rules

National Coding Week (https://codingweek.org/) RealSense Developer Challenge — Rules

Sponsor: RealSense, Inc. (the “Sponsor”).

Eligibility: Open to individuals 18 years or older. Void where prohibited. No purchase necessary.

How to Enter:

During National Coding Week, a new RealSense challenge will be posted daily on Reddit.

@chrismatthieu
chrismatthieu / gist:a721a51b3983e89fea6a31e90314856c
Created August 28, 2025 21:45
RealSense Circle with Depth Detection
import pyrealsense2 as rs
import cv2
import numpy as np
# Configure RealSense pipeline
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30)
#!/usr/bin/env python3
import pyrealsense2 as rs
import numpy as np
import cv2
import torch
from ultralytics import YOLO
import rclpy
from rclpy.node import Node
from geometry_msgs.msg import Twist
@chrismatthieu
chrismatthieu / ros-twist.py
Created March 6, 2025 18:46
Copilot + RealSense Follow Me ROS
import pyrealsense2 as rs
import numpy as np
import cv2
import json # Add import for JSON
# Load YOLOv3 model
net = cv2.dnn.readNet("yolov3.weights", "yolov3.cfg")
layer_names = net.getLayerNames()
output_layers = [layer_names[i - 1] for i in net.getUnconnectedOutLayers()]
@chrismatthieu
chrismatthieu / person-detection.py
Created March 6, 2025 17:33
RealSense D415 object detection and distance calculation
import pyrealsense2 as rs
import numpy as np
import cv2
# Load YOLOv3 model
net = cv2.dnn.readNet("yolov3.weights", "yolov3.cfg")
layer_names = net.getLayerNames()
output_layers = [layer_names[i - 1] for i in net.getUnconnectedOutLayers()]
# Initialize RealSense camera