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

Commit 42bc1ee

Browse files
author
Resethel
committed
v0.2.1
+ ajout de la fonction oscillate pour le développement de gaits, etc
1 parent 13d4b4d commit 42bc1ee

2 files changed

Lines changed: 21 additions & 13 deletions

File tree

Kubot.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ void Kubot::moveServos(int duration, int servo_target[])
139139
servo_position[i] = servo_target[i];
140140
}
141141

142+
143+
142144
void Kubot::oscillateServos(int A[4], int O[4], int T, double Ph[4], float cycle)
143145
{
144146
for (int i(0); i<4; i++)
@@ -167,23 +169,24 @@ void Kubot::oscillateServos(int A[4], int O[4], int T, double Ph[4], float cycle
167169
}
168170
}
169171

170-
void Kubot::Oscillate(int A[4], int O[4], int T, double phase_diff[4], float steps)
171-
{
172-
attachServos();
173-
setRestState(false);
174172

175-
float cycles = trunc(steps);
176173

177-
if(steps >= 1)
178-
{
174+
void Kubot::oscillate(int A[4], int O[4], int T, double phase_diff[4], float steps)
175+
{
176+
attachServos();
177+
setRestState(false);
179178

180-
for(int i(0) ; i < cycles; ++i)
179+
float cycles = trunc(steps);
180+
181+
if(steps >= 1)
182+
{
183+
for(int i(0) ; i < cycles; ++i)
181184
oscillateServos(A,O,T,phase_diff);
182-
}
185+
}
183186

184-
oscillateServos(A,O,T,phase_diff,steps-cycles);
187+
oscillateServos(A,O,T,phase_diff,steps-cycles);
185188

186-
}
189+
}
187190

188191

189192

Kubot.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Kubot
4949
//-- Contrôle basique des servos
5050
void moveServos(int duration, int servo_target[]);
5151
void oscillateServos(int A[4], int O[4], int T, double phase_diff[4], float cycle = 1.0);
52-
void oscillate(int A[4], int O[4], int T, double phase_diff[4], float steps = 1.0);
52+
5353
//-- HOME = Kubot à sa position de repos
5454
void home();
5555
bool getRestState();
@@ -64,7 +64,12 @@ class Kubot
6464
void _tone(float frequency, long noteDuration, long silenceDuration = 1);
6565
void bendTones(float initFrequency, float finalFrequency, float _step);
6666

67+
private:
6768

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

6974
private:
7075

@@ -82,7 +87,7 @@ class Kubot
8287

8388
bool isResting;
8489

85-
// void _execute(int A[4], int O[4], int T, double phase_diff[4], float steps);
90+
8691

8792
};
8893

0 commit comments

Comments
 (0)