Skip to content

Instantly share code, notes, and snippets.

@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 28, 2025 03:00
MQTT wrapper to help make it easier to use + a Tkinter example
"""
Library for making MQTT easier to use.
"""
import json
import paho.mqtt
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() {
@fisherds
fisherds / main.css
Created April 7, 2021 03:58
Additional CSS for the Node Tank Drive Server
.page-container {
margin-top: 75px;
display: flex;
flex-direction: column;
align-items: center;
}
#sliderContainer {
margin: 10px;
@fisherds
fisherds / index.html
Created April 7, 2021 03:55
mainPage contents for the Node Tank Drive Server
<div id="sliderContainer">
<input type="range" min="0" max="255" value="127" class="slider" id="baseSpeed">
</div>
<div id="driveGrid">
<button type="button" data-left-multiplier="0.5" data-right-multiplier="1.0" class="driveButton btn btn-block btn-outline-primary">
<i class="material-icons">undo</i>
</button>
<button type="button" data-left-multiplier="1.0" data-right-multiplier="1.0" class="driveButton btn btn-block btn-outline-primary">
<i class="material-icons">arrow_upward</i>
</button>
@fisherds
fisherds / testDriveSystem.js
Created April 6, 2021 13:35
Starting code for testing the drive system of the RoseBot via Node
const prompt = require('prompt-sync')({sigint: true});
// # -------------------------------------------------------------------------
// # TODO: import rosebot
// const rosebot = require("./rosebot");
// # -------------------------------------------------------------------------
function msleep(n) {
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, n);
}
function sleep(n) {
@fisherds
fisherds / main.js
Last active April 8, 2021 02:47
Given code for the Water Park Planner JavaScript
var rhit = rhit || {};
rhit.WaterParkController = class {
constructor() {
const startingTicketsInput = document.querySelector("#startingTicketsInput");
const updateBtn = document.querySelector("#updateButton");
const btn1 = document.querySelector("#option1Button");
const btn2 = document.querySelector("#option2Button");
const btn3 = document.querySelector("#option3Button");
const btn4 = document.querySelector("#option4Button");