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
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
@chrismatthieu
chrismatthieu / robot.js
Last active February 11, 2025 21:11
Sample robotics.dev boiler plate code
//import robotics from 'robotics-dev';
const robotics = require('robotics-dev');
// Define ROS twist movement commands
const moveForward = {
linear: {x: 0.2, y: 0.0, z: 0.0},
angular: {x: 0.0, y: 0.0, z: 0.0}
};
const turnLeft = {
linear: {x: 0.0, y: 0.0, z: 0.0},