Skip to content

Instantly share code, notes, and snippets.

View pringithub's full-sized avatar
💭
coding

Phillip Ring pringithub

💭
coding
View GitHub Profile
@pringithub
pringithub / ps1_interface.py
Created October 25, 2020 17:06
PS1 Controller Interface
import os
import serial
import numpy as np
btns = np.zeros(19)
# data sent in two-byte chunks
# first 10 bits map to shapes, sel/start, and trigger buttons
# next 4 bit map to D-Pad, but not 1:1; can press up-left, down-right, etc
@pringithub
pringithub / rostf_udp_broadcast.py
Created August 8, 2019 15:10
UDP broadcast/receive rostf data
import rospy
import tf
import socket
import time
# specify host on network you wish to broadcast on
HOST = '192.168.43.36'
PORT = 44444
server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
@pringithub
pringithub / the_button_giveth_life_and_the_button_taketh_away.cs
Last active May 1, 2019 15:49
Press the blue button to instantiate cubes, press the red button to destroy them.
// Game object "index" refers to the LeapMotion index finger
private void OnTriggerEnter(Collider c)
{
if (this.name == "blue")
{
if (c.gameObject.transform.parent.name.Equals("index") && numPrefabs < MAX_NUM_PREFABS)
{
prefabs[numPrefabs] = Instantiate(prefab) as GameObject;
numPrefabs += 1;
}
@pringithub
pringithub / cuberesizer.cs
Created May 1, 2019 15:06
Unity C# code to move and resize a cube using your hands
var leftDiff = (leftIndex.transform.position - leftThumb.transform.position).magnitude;
var rightDiff = (rightIndex.transform.position - rightThumb.transform.position).magnitude;
if (leftDiff < PINCH_DISTANCE && rightDiff < PINCH_DISTANCE)
{
var leftX = leftIndex.transform.position.x;
var leftY = leftIndex.transform.position.y;
var leftZ = leftIndex.transform.position.z;
var rightX = rightIndex.transform.position.x;
var rightY = rightIndex.transform.position.y;