Skip to content
This repository has been archived by the owner on Jun 25, 2019. It is now read-only.

Commit

Permalink
v0.2.1
Browse files Browse the repository at this point in the history
+ ajout de la fonction oscillate pour le développement de gaits, etc
  • Loading branch information
Resethel committed Oct 22, 2017
1 parent 13d4b4d commit 42bc1ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
25 changes: 14 additions & 11 deletions Kubot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ void Kubot::moveServos(int duration, int servo_target[])
servo_position[i] = servo_target[i];
}



void Kubot::oscillateServos(int A[4], int O[4], int T, double Ph[4], float cycle)
{
for (int i(0); i<4; i++)
Expand Down Expand Up @@ -167,23 +169,24 @@ void Kubot::oscillateServos(int A[4], int O[4], int T, double Ph[4], float cycle
}
}

void Kubot::Oscillate(int A[4], int O[4], int T, double phase_diff[4], float steps)
{
attachServos();
setRestState(false);

float cycles = trunc(steps);

if(steps >= 1)
{
void Kubot::oscillate(int A[4], int O[4], int T, double phase_diff[4], float steps)
{
attachServos();
setRestState(false);

for(int i(0) ; i < cycles; ++i)
float cycles = trunc(steps);

if(steps >= 1)
{
for(int i(0) ; i < cycles; ++i)
oscillateServos(A,O,T,phase_diff);
}
}

oscillateServos(A,O,T,phase_diff,steps-cycles);
oscillateServos(A,O,T,phase_diff,steps-cycles);

}
}



Expand Down
9 changes: 7 additions & 2 deletions Kubot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Kubot
//-- Contrôle basique des servos
void moveServos(int duration, int servo_target[]);
void oscillateServos(int A[4], int O[4], int T, double phase_diff[4], float cycle = 1.0);
void oscillate(int A[4], int O[4], int T, double phase_diff[4], float steps = 1.0);

//-- HOME = Kubot à sa position de repos
void home();
bool getRestState();
Expand All @@ -64,7 +64,12 @@ class Kubot
void _tone(float frequency, long noteDuration, long silenceDuration = 1);
void bendTones(float initFrequency, float finalFrequency, float _step);

private:

// Cette fonction est utilisé seulement pour les mouvements pré-programmés...
// Elle permet de raisonner en terme de pas et définir l'état du Kubot.
// TODO: Peut-être mergé cette fonction avec oscillateServos
void oscillate(int A[4], int O[4], int T, double phase_diff[4], float steps = 1.0);

private:

Expand All @@ -82,7 +87,7 @@ class Kubot

bool isResting;

// void _execute(int A[4], int O[4], int T, double phase_diff[4], float steps);


};

Expand Down

0 comments on commit 42bc1ee

Please sign in to comment.