 # wave moving down line of servos

Hey - I’m having trouble figuring out how to get servos to undulate - What I’d like is an index of values that will propagate through a line of servos, to create an undulation effect (I’m making a robotic snake). I’m having loads of trouble getting this to happen . I want control of the speed of the propagation and if possible, the timing delay from one to another, from outside input.

I have a class called servoWave

constructor: ServoWave::ServoWave(int _numServos, float _angle, unsigned long _period, int _wavelength, int _ampMax){

the number of servos is the total number of servos in the body, the angle is the angle the servo should be written at, the period corresponds to the delay period, the wavelength corresponds to the number of servos until the value is reset to 0, and the ampMax is the total amplitude that the servos will be at.

So I have an index of values that I’m writing the wave to be:

when I’m printing out the angles for each servo, I’m just getting 90 for wave , and my angle equals 0, instead of a whole array of values that are undulating.
I’m not sure what I’m doing wrong, any help would be appreciated
#include “servoWave.h”
//constructor with argiuments about the wave
ServoWave::ServoWave() {
}
ServoWave::~ServoWave() {

• delete servoPositions;*
• delete servos;*
}
ServoWave::ServoWave(int _numServos, float _angle, unsigned long _period, int _wavelength, int _ampMax){
• numServos = _numServos;//servos of the whole unit*
• angle = _angle;//height of wave*
• period = _period; //in milliseconds*
• wavelength = _wavelength;//how many servos long the wave will be*
• ampMax=_ampMax;*
float p = 0;
• int total = int(TWO_PI/0.01);//total num of index pioints, until the amplitude is back at zero*
• int numServos = _numServos;*
• //set currentServo to 0*
• int currentServo = 0;*
• int lastPosition=-1;*
• int steps = 5;*
• long previousMillis = 0;*
• long lastUpdatedAt = millis();*
• float wave[total];*
• p = 0;*
• //initialize servoPosition array*
• for(int i=0;i<numServos;i++){//wtf*
_ servoPositions = 90; // starting position for all servos. could be passed as an argument_
* }*
}
* servos[currentServo]=servo;*
* currentServo++;*
}
* servos[currentServo]=servo;*
* servoPositions[currentServo] = startingPosition;*
* currentServo++;*
}
void ServoWave::update(){

for(int i=0;i<total;i++){
wave = map(sin(p), -1,1,0,180);
p+=0.05;//THIS IS WHA T NMUST INFLUENCE SPEED
Serial.println(wave*);*
}
for(int i=0;i<numServos;i++){
index = i*2;//CHANGE THIS FOR CHANGING THE DIFFERENCE BETEWWEEN THEM
}
}
void ServoWave::move(){
for(int i=0;i<numServos;i++){
angle = wave[index*];*
index = (index*+1)%total;*
Serial.println(angle);
}
}
int ServoWave::calculateAngle(){
}
void ServoWave::passDownValues(int firstValue){

}