modified: src/Hippie.cpp

modified:   src/Hippie.h
This commit is contained in:
roboticafacil 2018-04-18 18:59:53 +02:00
parent ddca9ce8ce
commit caa9fc4584
2 changed files with 21 additions and 3 deletions

View File

@ -4,8 +4,7 @@
#include <Oscillator.h> #include <Oscillator.h>
void Hippie::init(int YL, int YR, int RL, int RR, int OYL, int OYR, int ORL, int ORR) {
void Hippie::init(int YL, int YR, int RL, int RR) {
servo_pins[0] = YL; servo_pins[0] = YL;
servo_pins[1] = YR; servo_pins[1] = YR;
@ -19,6 +18,24 @@ void Hippie::init(int YL, int YR, int RL, int RR) {
for (int i = 0; i < 4; i++) servo_position[i] = 90; for (int i = 0; i < 4; i++) servo_position[i] = 90;
} }
void Hippie::init_with_trim(int YL, int YR, int RL, int RR, int OYL, int OYR, int ORL, int ORR) {
servo_pins[0] = YL;
servo_pins[1] = YR;
servo_pins[2] = RL;
servo_pins[3] = RR;
servo[0].SetTrim(OYL);
servo[1].SetTrim(OYR);
servo[2].SetTrim(ORL);
servo[3].SetTrim(ORR);
attachServos();
isHippieResting=false;
for (int i = 0; i < 4; i++) servo_position[i] = 90;
}
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
//-- ATTACH & DETACH FUNCTIONS ----------------------------------// //-- ATTACH & DETACH FUNCTIONS ----------------------------------//
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
@ -71,6 +88,7 @@ void Hippie::oscillateServos(int A[4], int O[4], int T, double phase_diff[4], fl
servo[i].SetA(A[i]); servo[i].SetA(A[i]);
servo[i].SetT(T); servo[i].SetT(T);
servo[i].SetPh(phase_diff[i]); servo[i].SetPh(phase_diff[i]);
servo[i].SetTrim(servo_trim[i]);
} }
double ref=millis(); double ref=millis();
for (double x=ref; x<=T*cycle+ref; x=millis()){ for (double x=ref; x<=T*cycle+ref; x=millis()){

View File

@ -19,7 +19,7 @@ class Hippie
//-- Hippie initialisation //-- Hippie initialisation
void init(int YL, int YR, int RL, int RR); void init(int YL, int YR, int RL, int RR);
void init_with_trim(int YL, int YR, int RL, int RR, int OYL, int OYR, int ORL, int ORR);
//-- Attach & detach functions //-- Attach & detach functions
void attachServos(); void attachServos();
void detachServos(); void detachServos();