Skip to content

Instantly share code, notes, and snippets.

View clungzta's full-sized avatar

Alex McClung clungzta

View GitHub Profile
#Returns the normalised correlation (a number that represents the similarity) between lists of y coordinates
#Note: ENSURE that and both lists are of identical length, delta x remains constant and x coordinate is common to both lists
import numpy as np
a = [0, 1, 0.5]
b = [100, 1, 0.5]
output = np.correlate((a - np.mean(a)) / (np.std(a) * len(a)), (b - np.mean(b)) / np.std(b)) #Normalised correlation
#!/usr/bin/env python
#ROS Node to convert a GPS waypoint published on the topic "waypoint" into a 2D Navigation Goal in SLAM to achieve autonomous navigation to a GPS Waypoint
#Converts Decimal GPS Coordinates of waypoint to ROS Position Vector relative to the current gps position of the robot
#Accounts for curvature of the earth using haversine formula
#Depends rospy, std_msgs, geographic_msgs, sensor_msgs, numpy
#Written by Alex McClung, 2015, alex.mcclung@hotmail.com, To be Released Open Source under Creative Commons Attribution Share-Alike Licence
import roslib
import rospy
@clungzta
clungzta / OpenUPS2_Linux.md
Last active March 10, 2021 14:43
Overview of how to install OpenUPS2 using Linux, using the usbhid-ups driver for NUT (Network UPS Tools), allows you to view ups status, battery voltage and temperature etc.

OpenUPS2 Install Linux

alt text

Step 1

Plug the device in, check the device connection

$ lsusb | grep "d005"
@clungzta
clungzta / d3_ros.html
Created February 28, 2016 12:23
D3 JS Graph ROS Listener
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
@clungzta
clungzta / my-usbaccess.rules
Last active April 28, 2016 06:02
my-usbaccess.rules
KERNEL=="ttyUSB0", MODE="0666"
#!/usr/bin/env python
import roslib
roslib.load_manifest('rgbd_people_tracking')
import sys
import os
import rospy
import cv2
import matplotlib.pyplot as plt
from std_msgs.msg import String
from sensor_msgs.msg import Image
from subprocess import call
'''
Emulates a webcam, subscribing to mjpeg stream published by ROS web_video_server
First, run "$ sudo modprobe v4l2loopback" to create the virtual webcam device
Use "$ rostopic list" to list all available topics.
You can subscribe to any topics of type sensor_msgs/Image.
- To find out the type of the topic: use "$ rostopic info [TOPIC_NAME]"
@clungzta
clungzta / spectrometer_classification.py
Last active July 9, 2016 07:54
Scikit Learn SVM Classification for spectrometer
#!/usr/bin/python
#import rospy
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
import time
from scipy import signal
from sklearn import datasets
from sklearn import svm
from serial.serialutil import SerialException
@clungzta
clungzta / numpy_polynomials.py
Last active April 4, 2017 02:26
Playing around with generating 1D polynomials using numpy
#For full reference, see http://docs.scipy.org/doc/numpy-1.10.1/reference/routines.polynomials.poly1d.html
def generate_poly(points, n):
'''
Generates an n degree polynomial from 2d array of discrete Points.
parameter points is a 2D numpy array: e.g. np.array([(1, 1), (2, 4), (3, 1), (9, 3)])
'''
return np.poly1d(np.polyfit(points[:,0], points[:,1], n))
points = np.array([(1050, 1.0), (900, 0.775), (800, 0.5)])
@clungzta
clungzta / openvpn.md
Last active January 26, 2018 06:35
Openvpn Access Server

On server

  1. Create user account (useradd), add password for this user (passwd)
  2. Login to openvpn access server admin, add openvpn account with the same credentials

On Client
3.sudo apt-get install openvpn
4. Login to openvpn access server (on port 943) with credentials, download the "autologin profile"
5. sudo cp client.ovpn /etc/openvpn/client.conf
6. echo "AUTOSTART=\"ALL\"" | sudo tee -a /etc/default/openvpn
7. To connect to VPN: sudo service openvpn start