Skip to content

Instantly share code, notes, and snippets.

@fisherds
fisherds / index.html
Created February 14, 2022 04:23
HTML code for the Pi Simulator
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons">
<link rel="stylesheet" href="styles/bootstrap-material-design.min.css">
<link rel="stylesheet" href="styles/main.css">
<title>Pi Simulator</title>
@fisherds
fisherds / CantStopGame.js
Last active January 2, 2022 03:36
Given code for the Cant Stop model object
rhit.CantStopGame = class {
static NUM_DICE = 3; // Hardcoded but easy to change if making a different game.
static MAX_FIRST_ROLL_VALUE = 3; // Hardcoded but easy to change
static RoundState = {
PLAYER_1_ACTIVE: "Player 1's Turn",
PLAYER_1_BUST: "Player 1 Bust!",
PLAYER_2_ACTIVE: "Player 2's Turn",
PLAYER_2_BUST: "Player 2 Bust!",
}
@fisherds
fisherds / app.js
Last active February 16, 2022 02:36
Starting point for boilerplate app.js code.
var express = require("express");
var app = express();
app.use('/', express.static("public"));
app.use('/api/', express.json());
let data = {};
// let data = []; // or an empty array depending on the instructions for your specific exam
const fs = require("fs");
const serverSideStorage = "../data/db.json";
@fisherds
fisherds / test_sensors.py
Created May 4, 2021 16:53
Helper program I used to work out the details for my sensor methods
"""
Authors: Dave Fisher and PUT_YOUR_NAME_HERE.
"""
# TODO: 1. Put your name in the above.
import time
import rosebot
def main():
@fisherds
fisherds / test_servos.py
Created May 4, 2021 16:48
Helper program I used to work out the details for my servo methods
"""
Authors: Dave Fisher and PUT_YOUR_NAME_HERE.
"""
# TODO: 1. Put your name in the above.
import time
import rosebot
def main():
""" Test a robot's SERVOS. """
@fisherds
fisherds / simple_python_receive.py
Created May 3, 2021 14:33
Example of receiving the MATLAB MQTT messages
import mqtt_helper
import time
class TankReceiver:
def __init__(self):
self.mqtt_client = mqtt_helper.MqttClient()
self.mqtt_client.callback = self.mqtt_callback
self.mqtt_client.connect(
mqtt_broker_ip_address="broker.hivemq.com",
@fisherds
fisherds / jsonMQTTTest.m
Last active May 3, 2021 14:32
MQTT in MATLAB example using JSON messags
function jsonMQTTTest
clc
fprintf("Connecting...\n");
mqttClient = mqtt('tcp://broker.hivemq.com')
subscribe(mqttClient,'fisherds',"Callback",@myCallback);
for k = 60:20:100
currentMessage = sprintf('{"type": "motor/go", "payload": [%d, %d]}', k, k);
publish(mqttClient, 'fisherds', currentMessage);
pause(1);
@fisherds
fisherds / mqtt_helper.py
Last active April 23, 2024 00:23
MQTT wrapper to help make it easier to use + a Tkinter example
"""
Library for making MQTT easier to use.
"""
import json
import paho.mqtt.client as mqtt
class MqttClient(object):
"""Helper class to make it easier to work with MQTT subscriptions and publications."""
@fisherds
fisherds / testServo.js
Created April 9, 2021 12:48
Tests for the servo submodules
const rosebot = require("./rosebot");
const prompt = require('prompt-sync')({sigint: true});
function main() {
console.log('--------------------------------------------------')
console.log('Testing the SERVO classes of a robot')
console.log('--------------------------------------------------')
robot = new rosebot.RoseBot();
// Allow the I2C module an opportunity to finish initialization.
@fisherds
fisherds / rosebotServos.js
Created April 9, 2021 12:47
RoseBot servo sub modules
var i2cBus = require("i2c-bus");
var Pca9685Driver = require("pca9685").Pca9685Driver;
const SERVO_PIN_CAMERA_TILT = 11;
const SERVO_PIN_ARM_JOINT_1 = 12;
const SERVO_PIN_ARM_JOINT_2 = 13;
const SERVO_PIN_ARM_JOINT_3 = 14;
const SERVO_PIN_GRIPPER = 15;
function createPca9685Driver() {