Skip to content

Instantly share code, notes, and snippets.

@joshua-8
joshua-8 / subscribe.py
Created March 19, 2023 01:17
subscribes to a couple ros topics and prints them.
#!/usr/bin/env python
import rospy
import time
from pidrone_pkg.msg import State
from sensor_msgs.msg import Range, Imu
def callbackRange(data):
import datetime
dt = datetime.datetime.now()
print("range",data.range,dt.second+dt.microsecond/1000000.0," "," "," ")
@joshua-8
joshua-8 / optical_flow_node_replacer.py
Created March 12, 2023 18:52
optical_flow_node_replacer.py is a ros node that can be used instead of the optical_flow_node in pidrone_pkg/scripts to publish a zero velocity and fly with no camera.
#!/usr/bin/env python3
"""
optical_flow_node_replacer.py is a ros node that can be used instead of the optical_flow_node in pidrone_pkg/scripts to publish a zero velocity and fly with no camera.
JoshuaPhelps127@gmail.com 2023-03-10
"""
import rospy
from geometry_msgs.msg import TwistStamped
@joshua-8
joshua-8 / tof_node.py
Created March 12, 2023 05:16
for h2r/pidrone_pkg but with option for additional noise to demonstrate a ukf filter.
#!/usr/bin/env python3
import rospy
import argparse
import numpy as np
from sensor_msgs.msg import Range
from std_msgs.msg import Header
from dt_vl53l0x import \
/**
Arduino program written by joshua-8 and rowanberry in 2021
This program was written to display patterns on
Adafruit's large led disk: https://www.adafruit.com/product/2477
a "sector", a portion of one of the circular paths, can be light up and fade out towards each end
another animation looks like a stone dropped in the center of poo.
*/
// written by Joshua-8 2022-05
// testing code for combining relays with a high resolution (PWMed) "fine adjust" to reduce relay movement
import grafica.*;
import java.util.Collections;
int gi=0;
GPlot plot;
int numRelays=5;
int numCoarseSteps=int(pow(2, numRelays));
// written by Joshua-8 2022-03
import grafica.*;
import java.util.Collections;
//simulate resistors being inaccurate
float[] scale={1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
/*
* It is an inexpensive device to motivate children to exercise on a stationary bike; when the children pedal a bike, a movie or song they have chosen plays.
* It uses a magnet sensor to measure the speed of the pedal or crank of an exercise machine, and has a knob for changing what threshold is fast enough.
* The microcontroller emulates a keyboard and sends a space key press to start or stop any video or music playing on a computer.
* Use with a Digispark http://digistump.com/products/1, knob, and magnet sensor.
* by Joshua, 2015
*/
#include "DigiKeyboard.h"
boolean paused = true;
unsigned long timeSinceCrank = 10000000;
@joshua-8
joshua-8 / serial_servo_control
Created August 26, 2021 18:24
ESC/Servo serial control
String inString = "";
#include <Servo.h>
Servo myservo1;
void setup() {
myservo1.attach(9);
Serial.begin(2000000);
Serial.println("ESCs Speed Control. attach pin 9 to the ESC.");
}
@joshua-8
joshua-8 / derivslim.pde
Last active February 14, 2023 23:12
motion profile with limited velocity and acceleration (trapezoidal velocity)
/*
This program is for testing code that can be used to limit the first and second derivative of a variable as it approaches a target value.
It's easiest to think of in terms of position, velocity, and acceleration. If used with a servo, for example, the servo would smoothly move to a target value with a trapezoidal velocity profile.
The formula in this program supports being run at uneven intervals, and allows for editing the target, position, and velocity while it runs
Arduino library I wrote using the algoritihm developed here: https://github.com/joshua-8/Derivs_Limiter
The code was rewritten for version 3 of Derivs_Limiter (supporting different accel from decel and velocity target mode) in June 2022 by joshua-8
*/