Requesting Help with Vex V5 Code

My team and I have created a Vex V5 code for a reverse four bar lift robot and we are experiencing two issues,

A. The two rear dive motors (Motors 3 & 4) are stopping completely when the program begins and do not move even when attempting to manually force them to turn.
B. When complying, the program says that names like “Motor 1” and “Brain” are unidentified and I cannot understand why this would happen.

Below is my code in its entirety and attached is an image of the motor set up and the compilation errors I am experiencing. If you could help me in any way I would be grateful as we have a competition coming up soon (Sat. 2/2/19) and need to have this done as soon as possible. Thanks.

My team is the Cougar Renegades (42748C), and we compete in upstate South Carolina.

Code:


int main() {
    
    Brain.Screen.setPenColor(vex::color::red);    
    Brain.Screen.print("Help they've trapped me in a robot!");
    Brain.timer(15::sec);
    Brain.Screen.clearScreen();
    
    while(1) {
        
        int counter = 0;
        
        //Speed for Drive Motors
        Motor1.setVelocity(100,vex::velocityUnits::rpm);
        Motor2.setVelocity(100,vex::velocityUnits::rpm);
        Motor3.setVelocity(100,vex::velocityUnits::rpm);
        Motor4.setVelocity(100,vex::velocityUnits::rpm);       
        
        //Drive Control
        Motor1.spin(vex::directionType::fwd, (Controller1.Axis4.value() + Controller1.Axis3.value())/2, vex::velocityUnits::pct);
        Motor2.spin(vex::directionType::fwd, (Controller1.Axis4.value() - Controller1.Axis3.value())/2, vex::velocityUnits::pct);
        Motor3.spin(vex::directionType::fwd, (Controller1.Axis4.value() + Controller1.Axis3.value())/2, vex::velocityUnits::pct);
        Motor4.spin(vex::directionType::fwd, (Controller1.Axis4.value() - Controller1.Axis3.value())/2, vex::velocityUnits::pct);

        //Claw Control A - Place Caps on Poles
        if(Controller1.Axis2.value()>10) { 
            Motor5.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
            Motor6.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
            Motor7.spin(vex::directionType::fwd, 100, vex::velocityUnits::pct);
        }
        else if(Controller1.Axis2.value()<-10) { 
            Motor5.spin(vex::directionType::rev, 50, vex::velocityUnits::pct);
            Motor6.spin(vex::directionType::rev, 50, vex::velocityUnits::pct);
            Motor7.spin(vex::directionType::rev, 50, vex::velocityUnits::pct);
        }
        else { 
            Motor5.stop(brakeType::hold);
            Motor6.stop(brakeType::hold);
            Motor7.stop(brakeType::hold);
        }    
        
        //Claw Control B - Flip Caps
         if(Controller1.ButtonX.pressing()) {
             Motor7.spin(directionType::fwd,100,velocityUnits::rpm);
        }
        else if(Controller1.ButtonB.pressing()) {
             Motor7.spin(directionType::rev,50,velocityUnits::rpm);
        }
        else {
             Motor7.stop(brakeType::hold);  
        }
        
        //Claw Control C - Claw Swivel
        if (counter) = 0 {
            if(Controller1.ButtonR1.pressed(pressedFunction); {
                    Motor.rotateTo(180,rotationUnits::deg,50,velocityUnits::pct);
                    counter = 1
                    Brain.timer(10::sec); 
                    counter = 0
                }
            else {
                    FClaw.stop(brakeType::hold);  
            }  
        
         }                  
    }
               
}

Screenshot (13).png Motor set up
Screenshot (11).png Compilation errors
Screenshot (12).png Compilation errors Cont.

Do you have #include “robot-config.h”?
Have you competed before?

Thanks that fixed it.
Yes we have competed before, but not with the V5 system.

A. Your program won’t download with compilation errors. Whatever it’s doing now is not related to the code that you’ve posted with compilation errors.
B. You appear to have deleted


#include "robot-config.h"

from the top of your project. Would be my first guess. Whatever code was defining your motors has been removed. [You fixed this while I was typing.]

Some housekeeping first:

//Speed for Drive Motors
Motor1.setVelocity(100,vex::velocityUnits::rpm);
Motor2.setVelocity(100,vex::velocityUnits::rpm);
Motor3.setVelocity(100,vex::velocityUnits::rpm);
Motor4.setVelocity(100,vex::velocityUnits::rpm);

None of these lines do anything, as you immediately overwrite them with spin commands that take velocities.


int counter = 0;

This line is misplaced, or poorly setup. Every single loop, this will reset your counter to 0. If you want it to only happen once and be persistent from loop to loop, you either need to move its scope outside of the while loop or declare it as static. So one of these:

int counter = 0;
while(1) {
while(1) {
    static int counter = 0;

This section is malformed in many ways:

if(Controller1.ButtonR1.pressed(pressedFunction); {
    Motor.rotateTo(180,rotationUnits::deg,50,velocityUnits::pct);
    counter = 1
    Brain.timer(10::sec); 
    counter = 0
} else {
    FClaw.stop(brakeType::hold);  
}

What were you trying to do here? As written, this will not compile. The pressed method registers a function as an event handler, and is not a logical test. For that you would use the pressing method. Second, you don’t match parentheses properly on the if statement: ((). Further, you add a semicolon after the conditional, which will satisfy the “statements after an if” part of the if syntax. The following curly brace section would be executed regardless as a simple block of statements. This means that the following else would not be associated with any if, and would give an error as well. Further, two assignment statements are not terminated with a semicolon, and would also fail to compile. I’m also not sure what the timer here is for, as it retrieves a value from the timer, which you don’t store anywhere or use for anything. 10::sec is also not valid syntax for a vex::timeUnits. You would instead want to be using vex::timeUnits::sec as the argument to retrieve the timer’s time in seconds. I also don’t see the motors “Motor” or “FClaw” listed in your robot config, so the uses of those will also probably fail.