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

Commit 13d4b4d

Browse files
author
Resethel
committed
oscillate implementation
La fonction oscillate permet de resonner en terme de pas et non de cycles pour faire osciller les servos...
1 parent 02d952c commit 13d4b4d

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

Kubot.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,27 @@ void Kubot::oscillateServos(int A[4], int O[4], int T, double Ph[4], float cycle
167167
}
168168
}
169169

170+
void Kubot::Oscillate(int A[4], int O[4], int T, double phase_diff[4], float steps)
171+
{
172+
attachServos();
173+
setRestState(false);
174+
175+
float cycles = trunc(steps);
176+
177+
if(steps >= 1)
178+
{
179+
180+
for(int i(0) ; i < cycles; ++i)
181+
oscillateServos(A,O,T,phase_diff);
182+
}
183+
184+
oscillateServos(A,O,T,phase_diff,steps-cycles);
185+
186+
}
187+
188+
189+
190+
170191

171192
////////////////////////////////////////////////
172193
/// Homing: Controle de la position de repos ///

Kubot.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class Kubot
4848

4949
//-- Contrôle basique des servos
5050
void moveServos(int duration, int servo_target[]);
51-
void oscillateServos(int A[4], int O[4], int T, double phase_diff[4], float cycle);
52-
51+
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);
5353
//-- HOME = Kubot à sa position de repos
5454
void home();
5555
bool getRestState();

0 commit comments

Comments
 (0)