State machine

Dependencies:   mbed Adafruit_GFX BioroboticsMotorControl MODSERIAL BioroboticsEMGFilter

Committer:
brass_phoenix
Date:
Wed Oct 31 18:22:39 2018 +0000
Revision:
20:af1a6cd7469b
Child:
27:b247e78a4380
+ Added forward kinematics.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
brass_phoenix 20:af1a6cd7469b 1 #pragma once
brass_phoenix 20:af1a6cd7469b 2
brass_phoenix 20:af1a6cd7469b 3 const double PI = 3.14159265359;
brass_phoenix 20:af1a6cd7469b 4 // Main loop wait time per cycle. This does not influence the motor PID or EMG reading frequencies.
brass_phoenix 20:af1a6cd7469b 5 const float main_loop_wait_time = 0.01;
brass_phoenix 20:af1a6cd7469b 6
brass_phoenix 20:af1a6cd7469b 7 // Time between two button polls. Used to debounce the button presses.
brass_phoenix 20:af1a6cd7469b 8 const float button_poll_interval = 0.05;
brass_phoenix 20:af1a6cd7469b 9
brass_phoenix 20:af1a6cd7469b 10 const float pid_period = 0.001; // PID sample period in seconds.
brass_phoenix 20:af1a6cd7469b 11
brass_phoenix 20:af1a6cd7469b 12 const float Kp = 10.0;
brass_phoenix 20:af1a6cd7469b 13 const float Ki = 0.1;
brass_phoenix 20:af1a6cd7469b 14 const float Kd = 0.5;
brass_phoenix 20:af1a6cd7469b 15
brass_phoenix 20:af1a6cd7469b 16 // The motor -> main gear ratio is 25 / 60.
brass_phoenix 20:af1a6cd7469b 17 // The motor -> secondary gear ratio is 25/50
brass_phoenix 20:af1a6cd7469b 18 const float main_gear_ratio = 25.0/60.0;
brass_phoenix 20:af1a6cd7469b 19 const float sec_gear_ratio = 25.0/50.0;
brass_phoenix 20:af1a6cd7469b 20
brass_phoenix 20:af1a6cd7469b 21
brass_phoenix 20:af1a6cd7469b 22 const float L0 = 0.15; // Length between two motors [meter]
brass_phoenix 20:af1a6cd7469b 23 const float L1 = 0.10; // Length first beam from right motor2 [meter]
brass_phoenix 20:af1a6cd7469b 24 const float L2 = 0.30; // Length second beam from right motor2 [meter]
brass_phoenix 20:af1a6cd7469b 25 const float L3 = 0.15; // Length beam between L2 and L4 [meter]
brass_phoenix 20:af1a6cd7469b 26 const float L4 = 0.30; // Length first beam from left motor1 [meter]
brass_phoenix 20:af1a6cd7469b 27 const float L5 = 0.35; // Length from L3 to end-effector [meter]
brass_phoenix 20:af1a6cd7469b 28 const float L6 = 1.0; // Length beam between frame 0 and motor 1 [meter]
brass_phoenix 20:af1a6cd7469b 29
brass_phoenix 20:af1a6cd7469b 30 // Maximum and minimum angles of the main and secondary arm.
brass_phoenix 20:af1a6cd7469b 31 const float main_arm_max_angle = 1.22173;
brass_phoenix 20:af1a6cd7469b 32 const float main_arm_min_angle = 0.785398;
brass_phoenix 20:af1a6cd7469b 33 const float sec_arm_max_angle = 1.48353;
brass_phoenix 20:af1a6cd7469b 34 const float sec_arm_min_angle = -0.733038;