Skip to content

Instantly share code, notes, and snippets.

@cgreer
cgreer / operate_so100.py
Created November 26, 2024 01:23
Menu-driven interface to operate the SO100 robot arm
from dataclasses import dataclass
import os
import sys
import termios
import time
import tty
from lerobot.common.robot_devices.motors.feetech import FeetechMotorsBus as MotorBus
PORT = "/dev/tty.usbmodem<YOUR PORT>" # Put YOUR port here
@cgreer
cgreer / monitor_motor_bus.py
Created November 23, 2024 00:15
Monitor servo positions (absolute and relative) for S100 arm
import time
from lerobot.common.robot_devices.motors.feetech import FeetechMotorsBus as MotorBus
PORT = "/dev/tty.usbmodem<INSERT YOUR PORT>" # Put YOUR port here
BAUDRATE = 1_000_000
MODEL = "sts3215"
MAX_MOTOR_ID = 10 # S100 only has 6...
SCAN_IDS = list(range(1, MAX_MOTOR_ID))
@cgreer
cgreer / bag_of_little_bootstraps.py
Last active April 13, 2025 14:06
Bag of Little Bootstraps (w/ example usage)
import random
from typing import (
List,
Dict,
Callable,
Union,
)
import numpy
@cgreer
cgreer / nearestpytag.py
Created November 8, 2013 04:32
Get the tag (function/method/etc) in which the current position (cursor, file row/col) is in that tag's scope.
import re
def first_non_whitespace_index(lineText):
''' Find the index of the first non-whitespace character on line. '''
pat = re.compile(r'(\s*)(\S)')
m = pat.match(lineText)
if m:
# start(2) gets start of 2nd group
return m.start(2)
else:
@cgreer
cgreer / run_from_cmd_line.py
Last active December 23, 2015 03:38
Quickly run a function in a script from the command line without option parsing (useful for pipeline creation)
'''
USAGE:
Let's say you have a "find_words_with_letter" function (not method) in a script called "script_name.py"...
def find_words_with_letter(fileName, letter = "g"):
#fxn code here
...you can then call the function in the script from the command line - function name 1st argument, function args follow.