2-wheels robot

Hallo ,
i try to programm a tow-wheels Robot with Odometry , the robot should move around a square of 40 cms length.
i tried to do that but it is very complicated

Here is my own Code but i cant do more , any help ? i can pay for that , cuz thats my last labor in the university.

contact(Whatsapp) : +491622549057

#include <Servo.h>

Servo servoRight;
Servo servoLeft;

int pos = 0;
byte pinFeedbackRight = 9;
byte pinFeedbackLeft = 10;
byte pinServoRight = 5;
byte pinServoLeft = 6;
unsigned long highRight = 0, highLeft = 0;
unsigned long lowRight = 0, lowLeft = 0;
char keyCommand;
double dutyCycleRight = 0.0, dutyCycleLeft = 0.0;
unsigned long cycleTimeRight, cycleTimeLeft;
double totalCycle = 1098.901;
double thetaRight = 0.0, thetaLeft = 0.0;
double thetaRightPrev = 0.0, thetaLeftPrev = 0.0;
int turnsRight = 0, turnsLeft = 0;
double deltaThetaRight = 0, deltaThetaLeft = 0;
double totalThetaRight = 0, totalThetaLeft = 0;
int PcontrolRight = 0, PcontrolLeft = 0;

void calculateThetaRight();
void calculateThetaLeft();
void Pcontroller(int dir);
void printInfos();

void setup(){
Serial.begin(9600);
pinMode(pinFeedbackRight, INPUT);
pinMode(pinFeedbackLeft, INPUT);
}

void loop(){
if (Serial.available() > 0){
keyCommand = Serial.read();

switch(keyCommand){
case ‘f’:
servoRight.attach(pinServoRight);
servoLeft.attach(pinServoLeft);
servoRight.write(89 + PcontrolRight);
servoLeft.write(98 + PcontrolLeft);
delay(500);
servoRight.detach();
servoLeft.detach();
Pcontroller(1);
break;
case ‘b’:
servoRight.attach(5);
servoLeft.attach(6);
servoRight.write(98 + PcontrolRight);
servoLeft.write(70 + PcontrolLeft);
delay(500);
servoRight.detach();
servoLeft.detach();
Pcontroller(-1);
break;
case ‘s’:
servoRight.attach(5);
servoLeft.attach(6);
servoRight.write(94);
servoLeft.write(94);
delay(500);
servoRight.detach();
servoLeft.detach();
break;
default: break;
}
}
}

void Pcontroller(int dir){

calculateThetaRight();
calculateThetaLeft();
PcontrolRight = -1 * dir ;
PcontrolLeft = 1 * dir ;
printInfos();
}

void printInfos(){
deltaThetaRight = thetaRight - thetaRightPrev ;
thetaRightPrev = thetaRight ;
totalThetaRight += deltaThetaRight ;
deltaThetaLeft = thetaLeft - thetaLeftPrev ;
thetaLeftPrev = thetaLeft ;
totalThetaLeft += deltaThetaLeft ;
Serial.print("ThetaRight: “);
Serial.print(thetaRight);
Serial.print(” , ThetaLeft: ");
Serial.println(thetaLeft);
Serial.print("deltaThetaRight: “);
Serial.print(deltaThetaRight);
Serial.print(” , deltaThetaLeft: ");
Serial.println(deltaThetaLeft);
Serial.print("totalThetaRight: “);
Serial.print(totalThetaRight);
Serial.print(” , totalThetaLeft: ");
Serial.println(totalThetaLeft);
Serial.print("PcontrolRight: “);
Serial.print(PcontrolRight);
Serial.print(” , PcontrolLeft: ");
Serial.println(PcontrolLeft);
}
void calculateThetaRight(){

highRight = pulseIn(pinFeedbackRight , 1); // Measure high pulse
lowRight = pulseIn(pinFeedbackRight , 0);
cycleTimeRight = highRight + lowRight;
dutyCycleRight = highRight / cycleTimeRight ;

Serial.println(" ");
Serial.println(dutyCycleRight);

thetaRight = (360.0 - 1.0) - ((dutyCycleRight - 2.9) * 360.0) / ( 97.1 - 2.9 + 1);

}

void calculateThetaLeft(){

while(1)
{
highLeft = pulseIn(pinFeedbackLeft , 1); // Measure high pulse
lowLeft = pulseIn(pinFeedbackLeft , 0);
cycleTimeLeft = highLeft + lowLeft;
if ( cycleTimeLeft > 1000 && cycleTimeLeft < 1200)
{
break; //valid tCycle;
}
}
dutyCycleLeft = (100* highLeft) / cycleTimeLeft;
thetaLeft = (360.0 - 1.0) - ((dutyCycleLeft - 2.9) * 360.0) / ( 97.1 - 2.9 + 1);
if thetaLeft < 0)
{
thetaLeft = 0;
}
else if(thetaLeft > 359)
{
thetaLeft = 359;
}

}

Here is my own Code but i cant do more , any help ? i can pay for that

If you are willing to pay for help then this would best be asked in Gigs and Collaborations

Report to moderator if you want it moved

Topic moved and merged

@schekel - why did you not do as I suggested instead of starting a duplicate thread ?

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a timeout from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Sorry , but im new here , and i try now to understand the Lows of the Forum .

@Help: Send me a PM of what you want and what's the budget.