Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
void setup() {
// put your setup code here, to run once:
bool once = false;
float w = 1.2; //wheelbase
float v = 6; //speed in meters/sec of bike
float g = 9.8; //constant of gravity in meters/sec
float r = 10000000000; //radius of the turn
float height = 0.75; //height of the center of mass
float h = .5; //half of the length of the handlebar
float t = 0.035; //half of the width of the tire
float l = 0.8381; //length of the body of the actuator + 1.5 of the length of the fully extended actuator
float c = radians(72); //caster angle in degrees
float rate = 0.22987; //rate of motor
float cel = 0.8381; //current extention length of actuator
void loop() {
if (once == false){
c = radians(c);
float angle = (w*cos(atan(sq(v)/g*r)+asin(t*(sin(c)/(height-t)))))/r*cos(c); //needed steer angle of bike for desired turn
float rawdist = (sqrt(sq(l+h*sin(angle))+(sq(h-h*cos(angle))))); //distance that the actuator must travel
rawdist = float(rawdist, 3);
float dist = rawdist-cel; //total distance from actuator mount to new place to move
float sec = dist/rate; //number of seconds for the motors to run to make the needed changes to the bike handle bar poss
once = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.