Cruise Control using Ultrasonic sensor and Encoder Motor

What is wrong with the below code:

int velocityMeasurement(){ //calculating the speed of the robot
RightWheel_Velocity = Encoder_1.getCurrentSpeed();
RightWheel_Velocity = RightWheel_Velocity * Radius;
LeftWheel_Velocity = Encoder_2.getCurrentSpeed();
LeftWheel_Velocity = LeftWheel_Velocity * Radius;
Mean_Velocity = ((RightWheel_Velocity - LeftWheel_Velocity)/2);
return Mean_Velocity;
}

void moveForward(){
speedSet = velocityMeasurement();
if(speedSet < maxSpeed){
if (speedSet >= 55)
speedSet = 60;
else
speedSet = speedSet + 5;
Encoder_1.runSpeed(speedSet);
Encoder_2.runSpeed(-1 * speedSet);
_delay(1);
}
}

When executed, the robot does not move forward. But when velocityMeasurement() is commented, it works.

What is wrong with the below code:

For a start it is not a complete program so it is impossible to understand the context of how the functions are used.

Have you tried printing the value of Mean_Velocity or speedSet ?
Does it look reasonable ?

Mean_Velocity = ((RightWheel_Velocity - LeftWheel_Velocity)/2);

Usually, the mean of a and b is equal to (a+b)/2:

Mean_Velocity = (RightWheel_Velocity + LeftWheel_Velocity)/2;

Why _delay(1); and not delay(1); ?

santhosh3:
What is wrong with the below code:

UKHeliBob:
For a start it is not a complete program so it is impossible to understand the context of how the functions are

It's also not posted in Code Tags as per forum instruction.