Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import seaborn as sns
import matplotlib.pylab as plt
import pandas as pd
import csv
import datetime
reader = csv.reader(open('StatePopulations.csv'))
statePopulations = {}
echo "Clearing old data..."
rm -rf covid-19-data/
rm us-states.csv
echo "Getting new data..."
git clone https://github.com/nytimes/covid-19-data
echo "Done."
cp covid-19-data/us-states.csv .
echo "Starting..."
#!/usr/bin/env python
rh = {
"username": "",
"password": "",
}
config = {
"statusEmailAddress": "xxxxxxxxxx@vtext.com",
"buyLimit": 0.0075,
class coin:
purchasedPrice = 0.0
numHeld = 0.0
numBought = 0.0
name = ""
lastBuyOrder = ""
timeBought = ""
def __init__(self, name=""):
print("Creating coin " + name)
# generate moving averages
for c in self.coinList:
colName = c + "-MA"
self.data[colName] = self.data[c].shift(1).rolling(window=self.movingAverageWindows).mean()
colName = c + "-RSI"
self.data[colName] = talib.RSI(self.data[c].values, timeperiod = self.rsiWindow)
def buy(self, c, price):
#we are already in the process of a buy, don't submit another
if self.boughtIn == True:
print("Previous buy incomplete.")
return
availableCash = self.getCash()
if availableCash == -1:
print("Got an exception checking for available cash, canceling buy.")
@JasonRBowling
JasonRBowling / gist:16664659910432eea5924e83b5e5785b
Created September 24, 2022 16:21
Wheel Speed Calculations
# Calculate wheel speeds in m/s
#reference https://snapcraft.io/blog/your-first-robot-the-driver-4-5
left_wheel_vel = data.linear.x - ((data.angular.z * wheel_base) / 2.0)
right_wheel_vel = data.linear.x + ((data.angular.z * wheel_base) / 2.0)
# convert the required wheel speeds in m/s into rpms
c = math.pi * wheel_diameter # wheel circumference in meters
right_rpm = int((right_wheel_vel / c) * 60.0 * gear_ratio)
left_rpm = int((left_wheel_vel / c) * 60.0 * gear_ratio)
@JasonRBowling
JasonRBowling / gist:c7162b93d58c10ff88ec1d414e76a434
Created September 24, 2022 16:26
Odometry position calculations
def l_tick_cb(msg):
global wheel_diameter
global l_distance
global l_vel
ticks = msg.data
l_distance = ((ticks / 32.0) / 56.0) * (math.pi * wheel_diameter)
l_vel = l_distance * 20.0
l_rpm_actual = (ticks / 32.0) * 20.0 * 60.0
#print("l_vel: " + str(l_vel))
# compute the overall motion of the robot since last update
vec_v = (r_vel + l_vel) / 2.0
ang_vel = (r_vel - l_vel) / wheel_base
# decompose into x, y components of velocity vector
vx = vec_v * math.cos(ang_vel)
# calculate angular velocity
vy = vec_v * math.sin(ang_vel)
str2str -in ntrip://username:password@caster_ip_address:port/ODOT_VRS_RTCM3 -n 1 -b 1 -out serial://ttyACM0:38400:8:n:1