Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HIDScope MODSERIAL QEI biquadFilter mbed Servo
Diff: main.cpp
- Revision:
- 20:31876566d70f
- Parent:
- 19:e1e18746d98d
- Child:
- 22:31065a83d9e8
--- a/main.cpp Fri Oct 26 11:04:30 2018 +0000 +++ b/main.cpp Fri Oct 26 12:59:52 2018 +0000 @@ -32,10 +32,9 @@ //Global variables/objects States current_state; Ticker loop_ticker; //The Ticker object that will ensure perfect timing of our looping code -float e, u1, u2, emg_signal_raw_0, processed_emg_0, emg_signal_raw_1, processed_emg_1, robot_end_point, reference_end_point, motor_angle_1, motor_angle_2, motor_counts, q_ref; //will be set by the motor_controller function +float e, u1, u2, emg_signal_raw_0, processed_emg_0, emg_signal_raw_1, processed_emg_1, robot_end_x, robot_end_y, reference_end_x, reference_end_y, motor_angle_1, motor_angle_2, motor_counts_1, motor_counts_2, q_ref_1, q_ref_2; //will be set by the motor_controller function int counts_per_rotation = 32; bool state_changed = false; -double samplingfreq = 1000; double x; // Making the position (x,y) of the end effector global double y; @@ -47,7 +46,8 @@ { motor_angle_1 = motor_counts_1*2.0f*3.1415926535f/counts_per_rotation; //do this here, and not in the encoder interrupt, to reduce computational load motor_angle_2 = motor_counts_2*2.0f*3.1415926535f/counts_per_rotation; - robot_end_point = forwardkinematics_function(motor_angle_1,motor_angle_2); //motor_angle is global, this function ne + forwardkinematics_function(motor_angle_1,motor_angle_2); //motor_angle is global, this function ne + emg_signal_raw_0 = emg0.read(); //sample analog voltages (all sampling theory applies, you might get aliasing etc.) emg_signal_raw_1 = emg1.read(); processed_emg_0 = processing_chain_emg(0); // some function ‘float my_emg_processing_chain()’ that returns a float. The raw emg is global @@ -95,7 +95,9 @@ case operational: //interpreting emg-signals to move the end effector if (state_changed==true) { int x = 5; } // example - reference_end_point = robot_end_point + processed_emg_0; + reference_end_x = robot_end_x + processed_emg_0; + reference_end_y = robot_end_y + processed_emg_0; + if (button.read() == true) { current_state = demo; } break;