Can someone tell me what I am doing wrong?

So I am not too familiar with C++ but here is a very small section of a bigger project. I basically want to call the driveForward function after a certain button on the controller has been pressed. ( I know how to do the controller part.) I am getting a error on the driveForward function about a return value, no matter what I return the error wont go away. Sorry in advanced if there is a simple solution. Thanks!

#include "robot-config.h"
#include "math.h"

int controllerControls() {
  
}


int driveForward() {
    double wheelDiameterCM = 10.16; // wheel diameter (cm)
    double travelTargetCM = 20; // distance to travel (cm)
    double circumference = wheelDiameterCM * M_PI; // robot travels circumference per 360 degrees of rotation
    double degreesToRotate = (360 * travelTargetCM) / circumference; 
    
    LeftMotor.setVelocity(50, vex::velocityUnits::pct); // 50% power left 
    RightMotor.setVelocity(50, vex::velocityUnits::pct); // 50% power right 
    LeftMotor.rotateFor(degreesToRotate, vex::rotationUnits::deg, false); // non blocking
    RightMotor.rotateFor(degreesToRotate, vex::rotationUnits::deg, true); // blocking program till right motor is finished
}

You need to return a value at the end of the function such as 0, or declare the function as a void, not an int. You may also need to do the same with the controllerControls function.

1 Like