Make process closed with exit code : 2 (problem) vexV5 c++

This is our code. We need help getting rid of our exit code problem. Whenever we compile our code, it comes up with [error]: make process closed with exit code : 2 or BUILDING ERROR.

/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       C:\Users\dscurry                                          */
/*    Created:      Mon Mar 08 2021                                           */
/*    Description:  V5 project                                                */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name]               [Type]        [Port(s)]
// Controller1          controller    21           
// Leftmotor            motor         20              
// Rightmotor           motor         19              
// ClawMotor            motor         17              
// ArmMotor             motor         18              
// ---- END VEXCODE CONFIGURED DEVICES ----

#include "vex.h"
#include <cmath> // std::abs

using namespace vex;

// A global instance of competition
competition Competition;

// define your global instances of motors and other devices here

/*--------------------------------------------------------------------------*/
/*                          Pre-Auonomus Functions                          */
/*                                                                          */
/* You may want to preform some actions before the competition starts.      */
/* Do then in the following function. You must return from this function    */ 
/* or the automus usercontrol tasks will not be started. This               */ 
/* function is only called once after the V5 has been powered on and        */ 
/*  not every time that the robot is disabled.                              */
/*--------------------------------------------------------------------------*/ 

void pre_auton (void) {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // All activites that occur before the competition starts
  // Example: clearing encoders, setting servo positions, 
}

//Settings
double kP = 0.0;
double kI = 0.0;
double kD = 0.0;

//Autonomous Settings
int desiredValue = 200;

int error; //SensorValue - DesireValue : Position
int prevError = 0; //Position 20 milliseconds ago
int derivative;
int totalError;

//Variables modified for use
bool enableDrivePID = true;

int drivePID(){

  while(enableDrivePID){

    //Get the position of both motors
    int leftMotorPosition = Leftmotor.position(degrees);
    int rightMotorPosition = Rightmotor.position(degrees);

    ///////////////////////////////////
    //Lateral Movement PID
    //////////////////////////////////////////////////////
    //Get average of the two motors
    int averagePosition = (leftMotorPosition + rightMotorPosition)/2;

   // potential
    error = averagePosition - desiredValue;

  // derivative
    derivative = error - prevError;


    //code
    prevError = error;
    vex::task::sleep(20);

  }
    return 1; 

}
/*--------------------------------------------------------------------------*/
/*                                                                          */
/*                               Autonomus Task                             */
/*                                                                          */
/* This task is used to control your robot during the autonomus phase of    */
/* a VEX Competition.                                                       */
/*                                                                          */
/* You must modify the code to add your own robot specific commands here.   */
/*--------------------------------------------------------------------------*/

void autonomous(void) {

 vex::task billWiTheScienceFi(drivePID);


/////////////////////////////
//Drivetrain
//Settings
//////////////////////////////////////////////////////////////////////////////

//Driver Control

double turnImportance = 0.5;

while (1) {
/////////////////////////////
//Driver Control
//////////////////////////////////////////////////////////////////////////////

double turnVal = Controller1.Axis1.position(percent);

double forwardVal = Controller1.Axis3.position(percent);

double turnVolts = turnVal * 0.12;
double forwardVolts = forwardVal * 0.12 * (1 - std::abs (turnVolts)/12.0) * turnImportance;

//12 - 12 = 0
//12 + 12= 12 (due to cap)

Leftmotor.spin(forward,  forwardVolts + turnVolts, voltageUnits::volt);
Rightmotor.spin(forward,  forwardVolts - turnVolts, voltageUnits::volt);
////////////////////////////////////////////////////////////////////////////

/////////////////////////////
//Arm Control
////////////////////////////////////////////////////////////////////////////

bool topRightButton = Controller1.ButtonR1.pressing();
bool bottomRightButton = Controller1.ButtonR2.pressing();

if (topRightButton){
  ArmMotor.spin(forward, 12.0, voltageUnits::volt);

}
else if (bottomRightButton){
  ArmMotor.spin(forward, 12.0, voltageUnits::volt);

}
else{
  ArmMotor.spin(forward, 0, voltageUnits::volt);

}
////////////////////////////////////////////////////////////////////////////

//Claw Control
////////////////////////////////////////////////////////////////////////////

bool topLeftButton = Controller1.ButtonL1.pressing();
bool bottomLeftButton = Controller1.ButtonL2.pressing();

if (topLeftButton){
  ClawMotor.spin(forward, 12.0, voltageUnits::volt);

}
else if (bottomLeftButton){
  ClawMotor.spin(forward, 12.0, voltageUnits::volt);

}
else{
  ClawMotor.spin(forward, 0, voltageUnits::volt);

}

// This is the main execution loop for the user control program
// Each time through the loop your program must update motor + servo
// values based on feedback from the joysticks.

//.........................................................................
// Insert user code here. This is where you use the joystick values to
// update your motors, etc.
//.........................................................................

wait(20, msec); // sleep the task for a short amount of time to
                // prevent wasted sources
}
 #include "vex.h"
using namespace vex;


int main(void); {
  // Initializing Robot Configuration. DO NOT REMOVE! 
  vexcodeInit();
  Brain.Screen.print("Hello");


}


while (1)
wait(20,msec);
int num1 =1;
double num2 = 1.2;
char char1 = 'A';
bool bool1 = false;
num1 = (int)num2;
num2 = 3/2.0;   
char1 = 'B';
bool1 = false;
bool1 = true;

/*==

>=

>
<=
!-*/

while(1==1){
  // code
  num2 = 2.0;
}

double turnVal = Controller1.Axis1.position(percent);
double forwardVal = Controller1.Axis3.position(percent);
double turnVolts = turnVal *0.12;     
double forwardVolts = forwardVal *0.12; 

//12 - 12 = 0
//12 + 12= 12 (due to cap)

Leftmotor.spin(forward,  forwardVolts - turnVolts, voltageUnits::volt);
Rightmotor.spin(forward,  forwardVolts + turnVolts, voltageUnits::volt);

}
1 Like

This seems to be the same code as you posted in another topic. Community has given feedback, all code needs to be inside a function so, for example, this code cannot exist outside of a function.

while(1==1){
  // code
  num2 = 2.0;
}

double turnVal = Controller1.Axis1.position(percent);
double forwardVal = Controller1.Axis3.position(percent);
double turnVolts = turnVal *0.12;     
double forwardVolts = forwardVal *0.12; 

//12 - 12 = 0
//12 + 12= 12 (due to cap)

Leftmotor.spin(forward,  forwardVolts - turnVolts, voltageUnits::volt);
Rightmotor.spin(forward,  forwardVolts + turnVolts, voltageUnits::volt);

}
6 Likes