Error message but errors not showing up

Hi everyone! I am having an error message show up, even though there isn’t errors that I know of. I reverted the code to what it was 2 days ago (which was working) and that didn’t work either, same error.

Log
[info]: Project Path: C:\Users\rowan\Desktop\11-06-19 macro hightower
[info]: Saving Project ...
[info]: Project saved!
windows build for platform vexv5
vex/mkrules.mk:23: warning: overriding recipe for target 'build/11-06-19'
vex/mkrules.mk:17: warning: ignoring old recipe for target 'build/11-06-19'
vex/mkrules.mk:23: warning: overriding recipe for target 'macro'
vex/mkrules.mk:17: warning: ignoring old recipe for target 'macro'
vex/mkrules.mk:27: warning: overriding recipe for target 'macro'
vex/mkrules.mk:23: warning: ignoring old recipe for target 'macro'
make: Circular build/11-06-19 <- build/11-06-19 dependency dropped.
"CXX src/main.cpp"
make: Circular macro <- build/11-06-19 dependency dropped.
make: Circular macro <- macro dependency dropped.
"LINK hightower.elf"
   text	   data	    bss	    dec	    hex	filename
  11520	   1108	1064892	1077520	 107110	hightower.elf
Usage: arm-none-eabi-objcopy [option(s)] in-file [out-file]
 Copies a binary file, possibly transforming it in the process
 The options are:
  -I --input-target <bfdname>      Assume input file is in format <bfdname>
  -O --output-target <bfdname>     Create an output file in format <bfdname>
  -B --binary-architecture <arch>  Set output arch, when input is arch-less
  -F --target <bfdname>            Set both input and output format to <bfdname>
     --debugging                   Convert debugging information, if possible
  -p --preserve-dates              Copy modified/access timestamps to the output
  -D --enable-deterministic-archives
                                   Produce deterministic output when stripping archives
  -U --disable-deterministic-archives
                                   Disable -D behavior (default)
  -j --only-section <name>         Only copy section <name> into the output
     --add-gnu-debuglink=<file>    Add section .gnu_debuglink linking to <file>
  -R --remove-section <name>       Remove section <name> from the output
  -S --strip-all                   Remove all symbol and relocation information
  -g --strip-debug                 Remove all debugging symbols & sections
     --strip-dwo                   Remove all DWO sections
     --strip-unneeded              Remove all symbols not needed by relocations
  -N --strip-symbol <name>         Do not copy symbol <name>
     --strip-unneeded-symbol <name>
                                   Do not copy symbol <name> unless needed by
                                     relocations
     --only-keep-debug             Strip everything but the debug information
     --extract-dwo                 Copy only DWO sections
     --extract-symbol              Remove section contents but keep symbols
  -K --keep-symbol <name>          Do not strip symbol <name>
     --keep-file-symbols           Do not strip file symbol(s)
     --localize-hidden             Turn all ELF hidden symbols into locals
  -L --localize-symbol <name>      Force symbol <name> to be marked as a local
     --globalize-symbol <name>     Force symbol <name> to be marked as a global
  -G --keep-global-symbol <name>   Localize all symbols except <name>
  -W --weaken-symbol <name>        Force symbol <name> to be marked as a weak
     --weaken                      Force all global symbols to be marked as weak
  -w --wildcard                    Permit wildcard in symbol comparison
  -x --discard-all                 Remove all non-global symbols
  -X --discard-locals              Remove any compiler-generated symbols
  -i --interleave [<number>]       Only copy N out of every <number> bytes
     --interleave-width <number>   Set N for --interleave
  -b --byte <num>                  Select byte <num> in every interleaved block
     --gap-fill <val>              Fill gaps between sections with <val>
     --pad-to <addr>               Pad the last section up to address <addr>
     --set-start <addr>            Set the start address to <addr>
    {--change-start|--adjust-start} <incr>
                                   Add <incr> to the start address
    {--change-addresses|--adjust-vma} <incr>
                                   Add <incr> to LMA, VMA and start addresses
    {--change-section-address|--adjust-section-vma} <name>{=|+|-}<val>
                                   Change LMA and VMA of section <name> by <val>
     --change-section-lma <name>{=|+|-}<val>
                                   Change the LMA of section <name> by <val>
     --change-section-vma <name>{=|+|-}<val>
                                   Change the VMA of section <name> by <val>
    {--[no-]change-warnings|--[no-]adjust-warnings}
                                   Warn if a named section does not exist
     --set-section-flags <name>=<flags>
                                   Set section <name>'s properties to <flags>
     --add-section <name>=<file>   Add section <name> found in <file> to output
     --rename-section <old>=<new>[,<flags>] Rename section <old> to <new>
     --long-section-names {enable|disable|keep}
                                   Handle long section names in Coff objects.
     --change-leading-char         Force output format's leading character style
     --remove-leading-char         Remove leading character from global symbols
     --reverse-bytes=<num>         Reverse <num> bytes at a time, in output sections with content
     --redefine-sym <old>=<new>    Redefine symbol name <old> to <new>
     --redefine-syms <file>        --redefine-sym for all symbol pairs 
                                     listed in <file>
     --srec-len <number>           Restrict the length of generated Srecords
     --srec-forceS3                Restrict the type of generated Srecords to S3
     --strip-symbols <file>        -N for all symbols listed in <file>
     --strip-unneeded-symbols <file>
                                   --strip-unneeded-symbol for all symbols listed
                                     in <file>
     --keep-symbols <file>         -K for all symbols listed in <file>
     --localize-symbols <file>     -L for all symbols listed in <file>
     --globalize-symbols <file>    --globalize-symbol for all in <file>
     --keep-global-symbols <file>  -G for all symbols listed in <file>
     --weaken-symbols <file>       -W for all symbols listed in <file>
     --alt-machine-code <index>    Use the target's <index>'th alternative machine
     --writable-text               Mark the output text as writable
     --readonly-text               Make the output text write protected
     --pure                        Mark the output file as demand paged
     --impure                      Mark the output file as impure
     --prefix-symbols <prefix>     Add <prefix> to start of every symbol name
     --prefix-sections <prefix>    Add <prefix> to start of every section name
     --prefix-alloc-sections <prefix>
                                   Add <prefix> to start of every allocatable
                                     section name
     --file-alignment <num>        Set PE file alignment to <num>
     --heap <reserve>[,<commit>]   Set PE reserve/commit heap to <reserve>/
                                   <commit>
     --image-base <address>        Set PE image base to <address>
     --section-alignment <num>     Set PE section alignment to <num>
     --stack <reserve>[,<commit>]  Set PE reserve/commit stack to <reserve>/
                                   <commit>
     --subsystem <name>[:<version>]
                                   Set PE subsystem to <name> [& <version>]
     --compress-debug-sections     Compress DWARF debug sections using zlib
     --decompress-debug-sections   Decompress DWARF debug sections using zlib
  -v --verbose                     List all object files modified
  @<file>                          Read options from <file>
  -V --version                     Display this program's version number
  -h --help                        Display this output
     --info                        List object formats & architectures supported
arm-none-eabi-objcopy: supported targets: elf32-littlearm elf32-bigarm elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
make: *** [vex/mkrules.mk:23: build/11-06-19] Error 1
[error]: make process closed with exit code : 2
Main.cpp code
// VEX V5 C++ Project
#include "vex.h"
#include <algorithm>
#include <cmath>
// ---- START VEXCODE CONFIGURED DEVICES ----
// ---- END VEXCODE CONFIGURED DEVICES ----

using namespace vex;
#include "functions.h"
// A global instance of competition
competition Competition;
//#region config_globals
vex::motor back_right_motor(vex::PORT1, vex::gearSetting::ratio18_1, true);
vex::motor back_left_motor(vex::PORT10, vex::gearSetting::ratio18_1, false);
vex::motor front_right_motor(vex::PORT11, vex::gearSetting::ratio18_1, true);
vex::motor front_left_motor(vex::PORT20, vex::gearSetting::ratio18_1, false);
vex::motor intake_arm_mover(vex::PORT5, vex::gearSetting::ratio36_1, false);
vex::motor intake_left(vex::PORT12, vex::gearSetting::ratio36_1, false);
vex::motor intake_right(vex::PORT19, vex::gearSetting::ratio36_1, false);
vex::motor tray_mover(vex::PORT16, vex::gearSetting::ratio36_1, false);
vex::controller con(vex::controllerType::primary);
//#endregion config_globals

// define your global instances of motors and other devices here
  int maxSpeedPCT = 99;
  int HighTowerMacroPCT = 99;
  int inc = 0;
  int mode = 0;
motor_group   leftDrive( front_left_motor, back_left_motor );
motor_group   RightDrive( front_right_motor, back_right_motor );
motor_group   AllDrive( front_left_motor, front_right_motor, back_left_motor, back_right_motor);
motor_group   Intakes (intake_left, intake_right);
/*---------------------------------------------------------------------------*/
/*                          Pre-Autonomous Functions                         */
/*                                                                           */
/*  You may want to perform some actions before the competition starts.      */
/*  Do them in the following function.  You must return from this function   */
/*  or the autonomous and 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 activities that occur before the competition starts
  // Example: clearing encoders, setting servo positions, ...
}

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

void autonomous(void) {
  // front_left_motor.spin(fwd);
  tray_mover.spin(directionType::fwd, maxSpeedPCT, velocityUnits::pct);
  wait(1000, msec);
  tray_mover.stop(brakeType::brake);
  intake_left.spin(directionType::rev, maxSpeedPCT, velocityUnits::pct);
  intake_right.spin(directionType::rev, maxSpeedPCT, velocityUnits::pct);
  tray_mover.spin(directionType::rev, maxSpeedPCT, velocityUnits::pct);
  wait(1000,msec);
  Intakes.stop(brakeType::brake);
  tray_mover.stop(brakeType::brake);
 /* back_left_motor.spin(fwd); // forward);
  front_right_motor.spin(fwd);
  front_left_motor.spin(fwd);
  back_right_motor.spin(fwd);
  wait(2, seconds);
  back_left_motor.spin(reverse);
  front_right_motor.spin(reverse);
  front_left_motor.spin(reverse);
  back_right_motor.spin(reverse);
  wait(3, seconds); 
  back_left_motor.stop();
  front_left_motor.stop();
  back_right_motor.stop();
  front_right_motor.stop();
  */
  /* 
  tray_mover.spin(fwd);
  wait(0.5, seconds);
  intake_left.spin(reverse);
  intake_right.spin(reverse);
  tray_mover.spin(fwd);
  wait(1, seconds);
  tray_mover.spin(reverse);
  wait(2, seconds);
  */
}

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

void HighTower()
  {
    intake_arm_mover.setVelocity(40, percent);
    intake_arm_mover.spinToPosition(HighTowerMacroPCT, (rotationUnits)35,false);
    intake_arm_mover.setBrake(brakeType::hold);
  }
// R1 button script
void R1Script()
{
tray_mover.spin(fwd);
intake_arm_mover.spin(fwd);
}

void usercontrol(void) {
  // User control code here, inside the loop
  while (1) {

    // Setting the speed of the intake rollers and the arms holding the intake
    // rollers

    while (true) {
      int intakeleftSpeedPCT = 200;
      int intakerightSpeedPCT = 200;
      int intakearmSpeedPCT = 75;
      int traymoverSpeedPCT = 25;
      int traymover2speedPCT = 75;

      // respond to the R2 button pressing
      if (con.ButtonR2.pressing())
      {
        //con.Screen.clearScreen();
        con.Screen.print("test = %d",inc);
        con.Screen.newLine();
        Brain.Screen.print("%d",inc);
        Brain.Screen.newLine();
        inc++; 
        mode = 1;

        tray_mover.spin(directionType::rev, traymover2speedPCT, velocityUnits::pct);
        intake_arm_mover.spin(directionType::rev, intakearmSpeedPCT, velocityUnits::pct);
        wait(500, msec); // Sleep the task for a short amount of time
        tray_mover.stop(brakeType::brake);
        wait(1000, msec); // Sleep the task for a short amount of time
        intake_arm_mover.stop(brakeType::brake);
      }
      else
      {
        mode = 0;
      }

      if (mode==0)
      {
        // intake left control
        if (con.ButtonL1.pressing()) 
        {
          intake_left.spin(directionType::fwd, intakeleftSpeedPCT, velocityUnits::pct);
        } 
        else if (con.ButtonL2.pressing()) 
        {
          intake_left.spin(directionType::rev, intakeleftSpeedPCT, velocityUnits::pct);
        } 
        else 
        {
          intake_left.stop(brakeType::brake);
        }

        //intake right control
        if (con.ButtonL1.pressing()) 
        {
          intake_right.spin(directionType::rev, intakerightSpeedPCT, velocityUnits::pct);
        } 
        else if (con.ButtonL2.pressing()) 
        {
          intake_right.spin(directionType::fwd, intakerightSpeedPCT, velocityUnits::pct);
        } 
        else 
        {
          intake_right.stop(brakeType::brake);
        }

        // intake arm mover control
        if (con.ButtonUp.pressing()) 
        {
          intake_arm_mover.spin(directionType::fwd, intakearmSpeedPCT, velocityUnits::pct);
        } 
        else if (con.ButtonDown.pressing()) 
        {
          intake_arm_mover.spin(directionType::rev, intakearmSpeedPCT, velocityUnits::pct);
        } 
        else 
        {
          intake_arm_mover.stop(brakeType::brake);
        }

        // tray mover control
        if (con.ButtonLeft.pressing()) 
        {
          tray_mover.spin(directionType::fwd, traymover2speedPCT, velocityUnits::pct);
        } 
        else if (con.ButtonRight.pressing()) 
        {
          tray_mover.spin(directionType::rev, traymoverSpeedPCT, velocityUnits::pct);
        } 
        else 
        {
          tray_mover.stop(brakeType::brake);
        }
        
      
        // Get the raw sums of the X and Y joystick axes
        double front_left =
            (double)(con.Axis3.position(pct) + con.Axis4.position(pct));
        double back_left =
            (double)(con.Axis3.position(pct) - con.Axis4.position(pct));
        double front_right =
            (double)(con.Axis3.position(pct) - con.Axis4.position(pct));
        double back_right =
            (double)(con.Axis3.position(pct) + con.Axis4.position(pct));

        // Find the largest possible sum of X and Y
        double max_raw_sum =
            (double)(abs(con.Axis3.position(pct)) + abs(con.Axis4.position(pct)));

        // Find the largest joystick value
        double max_XYstick_value = (double)(std::max(
            abs(con.Axis3.position(pct)), abs(con.Axis4.position(pct))));

        // The largest sum will be scaled down to the largest joystick value, and
        // the others will be scaled by the same amount to preserve directionality
        if (max_raw_sum != 0) {
          front_left = front_left / max_raw_sum * max_XYstick_value;
          back_left = back_left / max_raw_sum * max_XYstick_value;
          front_right = front_right / max_raw_sum * max_XYstick_value;
          back_right = back_right / max_raw_sum * max_XYstick_value;
        }

        // Now to consider rotation
        // Naively add the rotational axis
        front_left = front_left + con.Axis1.position(pct);
        back_left = back_left + con.Axis1.position(pct);
        front_right = front_right - con.Axis1.position(pct);
        back_right = back_right - con.Axis1.position(pct);

        // What is the largest sum, or is 100 larger?
        max_raw_sum =
            std::max(std::abs(front_left),
                    std::max(std::abs(back_left),
                              std::max(std::abs(front_right),
                                      std::max(std::abs(back_right), 100.0))));

        // Scale everything down by the factor that makes the largest only 100, if
        // it was over
        front_left = front_left / max_raw_sum * 100.0;
        back_left = back_left / max_raw_sum * 100.0;
        front_right = front_right / max_raw_sum * 100.0;
        back_right = back_right / max_raw_sum * 100.0;

        // Write the manipulated values out to the motors
        front_left_motor.spin(fwd, front_left, velocityUnits::pct);
        back_left_motor.spin(fwd, back_left, velocityUnits::pct);
        front_right_motor.spin(fwd, front_right, velocityUnits::pct);
        back_right_motor.spin(fwd, back_right, velocityUnits::pct);
      }
    }
  }

  // This is the main execution loop for the user control program.
  // Each time through the loop your program should 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 resources.
}

//
// Main will set up the competition functions and callbacks.
//
int main() {
  // Run the pre-autonomous function.
  pre_auton();

  // Set up callbacks for autonomous and driver control periods.
  Competition.autonomous(autonomous);
  Competition.drivercontrol(usercontrol);

  // autonomous();
  // Prevent main from exiting with an infinite loop.
  while (true) {
    wait(100, msec);
  }
}

Also, there is no error on any of the includes or any of the src. @jpearman would you know anything about this?

You are missing a large chunk of the competition template (the int main() part)

int main() {
  Competition.autonomous(autonomous);
  Competition.drivercontrol(usercontrol);
  pre_auton();
  while (true) {
    wait(100, msec);
  }
}
1 Like

it’s here image

Oh I see, my mistake I didn’t copy everything over correctly. Try removing #include “functions.h” and see if it builds.

For me when I remove it the program builds correctly (but that’s also because I dont have the functions.h file)

If it doesn’t work you’ll probably need to upload the .zip file for your project

1 Like

Alright, i transferred code to another thing, and the software error isnt here, but this is. Do you know why?image The int main bracket is an error bc “function definition isn’t allowed here”.

I don’t know any software stuff, it would probably be best if jpearman could explain what the error meant. Maybe there was something in the functions.h file or something corrupted. (Again, I have no idea)

Double end bracket, you are defining a function in a function

1 Like

Ok, thanks!

wait well this error is new…

src/main.cpp:264:9: warning: empty parentheses interpreted as a function declaration [-Wvexing-parse]
int main(); // Run the pre-autonomous function.
        ^~
src/main.cpp:264:9: note: replace parentheses with an initializer to declare a variable
int main(); // Run the pre-autonomous function.
        ^~
         = 0
1 warning generated.
"CXX src/robot-config.cpp"
"LINK build/MyProject112.elf"
C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5\libv5rt.a(v5_startup.c.obj): In function `vexMain':
(.text.vexMain+0xa0): undefined reference to `main'
C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5\libv5rt.a(vex_competition.cpp.obj): In function `vex::competition::competition()':
(.text._ZN3vex11competitionC2Ev+0x134): undefined reference to `main'
C:\Program Files (x86)\VEX Robotics\VEXcode V5 Text\sdk/vexv5\libv5rt.a(vex_task.cpp.obj): In function `vex::task::_stopAll()':
(.text._ZN3vex4task8_stopAllEv+0x34): undefined reference to `main'
make: *** [vex/mkrules.mk:18: build/MyProject112.elf] Error 1
[error]: make process closed with exit code : 2

You probably deleted the wrong curly bracket. There shouldn’t be a ; after int main(). Delete the curly bracket at the very end of the program. Could you upload your new code?

Looks like you are trying to call main somewhere, that’s not right. Notice it’s on a line with ‘run pre-autonomous’ comment

Nvm got confused by the comment

code for main.cpp
// VEX V5 C++ Project
#include "vex.h"
#include "robot-config.h"
#include <algorithm>
#include <cmath>
// ---- START VEXCODE CONFIGURED DEVICES ----
// ---- END VEXCODE CONFIGURED DEVICES ----

using namespace vex;

// A global instance of competition
competition Competition;
vex::brain Brain;
vex::motor back_right_motor(vex::PORT1, vex::gearSetting::ratio18_1, true);
vex::motor back_left_motor(vex::PORT10, vex::gearSetting::ratio18_1, false);
vex::motor front_right_motor(vex::PORT11, vex::gearSetting::ratio18_1, true);
vex::motor front_left_motor(vex::PORT20, vex::gearSetting::ratio18_1, false);
vex::motor intake_arm_mover(vex::PORT5, vex::gearSetting::ratio36_1, false);
vex::motor intake_left(vex::PORT12, vex::gearSetting::ratio36_1, false);
vex::motor intake_right(vex::PORT19, vex::gearSetting::ratio36_1, false);
vex::motor tray_mover(vex::PORT16, vex::gearSetting::ratio36_1, false);
vex::controller con(vex::controllerType::primary);

int HighTowerMacroPCT = 99;
int inc = 0;
int mode = 0;


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

/*---------------------------------------------------------------------------*/
/*                          Pre-Autonomous Functions                         */
/*                                                                           */
/*  You may want to perform some actions before the competition starts.      */
/*  Do them in the following function.  You must return from this function   */
/*  or the autonomous and 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 activities that occur before the competition starts
  // Example: clearing encoders, setting servo positions, ...
}

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

void autonomous(void) {
  // front_left_motor.spin(fwd);
  back_left_motor.spin(fwd); // forward);
  front_right_motor.spin(fwd);
  front_left_motor.spin(fwd);
  back_right_motor.spin(fwd);
  wait(2, seconds);
  back_left_motor.spin(reverse);
  front_right_motor.spin(reverse);
  front_left_motor.spin(reverse);
  back_right_motor.spin(reverse);
  wait(3, seconds); 
  back_left_motor.stop();
  front_left_motor.stop();
  back_right_motor.stop();
  front_right_motor.stop();
  /*
  tray_mover.spin(fwd);
  wait(0.5, seconds);
  intake_left.spin(reverse);
  intake_right.spin(reverse);
  tray_mover.spin(fwd);
  wait(1, seconds);
  tray_mover.spin(reverse);
  wait(2, seconds);
  */
}

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


// R1 button script
void R1Script()
{
tray_mover.spin(fwd);
intake_arm_mover.spin(fwd);
}

void usercontrol(void) {
  // User control code here, inside the loop
  while (1) {

    // Setting the speed of the intake rollers and the arms holding the intake
    // rollers

    while (true) {
      int intakeleftSpeedPCT = 200;
      int intakerightSpeedPCT = 200;
      int intakearmSpeedPCT = 75;
      int traymoverSpeedPCT = 25;
      int traymover2speedPCT = 99;
       // respond to the R2 button pressing
      if (con.ButtonR2.pressing())
      {
        //con.Screen.clearScreen();
        con.Screen.print("test = %d",inc);
        con.Screen.newLine();
        Brain.Screen.print("%d",inc);
        Brain.Screen.newLine();
        inc++; 
        mode = 1;

        tray_mover.spin(directionType::rev, traymover2speedPCT, velocityUnits::pct);
        intake_arm_mover.spin(directionType::rev, intakearmSpeedPCT, velocityUnits::pct);
        wait(500, msec); // Sleep the task for a short amount of time
        tray_mover.stop(brakeType::brake);
        wait(1000, msec); // Sleep the task for a short amount of time
        intake_arm_mover.stop(brakeType::brake);
      }
      else
      {
        mode = 0;
      }

      if (mode==0)
      {

      // intake left control
      if (con.ButtonL1.pressing()) 
      {
        intake_left.spin(directionType::fwd, intakeleftSpeedPCT, velocityUnits::pct);
      } 
      else if (con.ButtonL2.pressing()) 
      {
        intake_left.spin(directionType::rev, intakeleftSpeedPCT, velocityUnits::pct);
      } 
      else 
      {
        intake_left.stop(brakeType::brake);
      }
  
    

      //intake right control
      if (con.ButtonL1.pressing()) 
      {
        intake_right.spin(directionType::rev, intakerightSpeedPCT, velocityUnits::pct);
      } 
      else if (con.ButtonL2.pressing()) 
      {
        intake_right.spin(directionType::fwd, intakerightSpeedPCT, velocityUnits::pct);
      } 
      else 
      {
        intake_right.stop(brakeType::brake);
      }

      // intake arm mover control
      if (con.ButtonUp.pressing()) 
      {
        intake_arm_mover.spin(directionType::fwd, intakearmSpeedPCT, velocityUnits::pct);
      } 
      else if (con.ButtonDown.pressing()) 
      {
        intake_arm_mover.spin(directionType::rev, intakearmSpeedPCT, velocityUnits::pct);
      } 
      else 
      {
        intake_arm_mover.stop(brakeType::brake);
      }

      // tray mover control
      if (con.ButtonLeft.pressing()) 
      {
        tray_mover.spin(directionType::fwd, traymover2speedPCT, velocityUnits::pct);
      } 
      else if (con.ButtonRight.pressing()) 
      {
        tray_mover.spin(directionType::rev, traymoverSpeedPCT, velocityUnits::pct);
      } 
      else 
      {
        tray_mover.stop(brakeType::brake);
      }
      
     
      // Get the raw sums of the X and Y joystick axes
      double front_left =
          (double)(con.Axis3.position(pct) + con.Axis4.position(pct));
      double back_left =
          (double)(con.Axis3.position(pct) - con.Axis4.position(pct));
      double front_right =
          (double)(con.Axis3.position(pct) - con.Axis4.position(pct));
      double back_right =
          (double)(con.Axis3.position(pct) + con.Axis4.position(pct));

      // Find the largest possible sum of X and Y
      double max_raw_sum =
          (double)(abs(con.Axis3.position(pct)) + abs(con.Axis4.position(pct)));

      // Find the largest joystick value
      double max_XYstick_value = (double)(std::max(
          abs(con.Axis3.position(pct)), abs(con.Axis4.position(pct))));

      // The largest sum will be scaled down to the largest joystick value, and
      // the others will be scaled by the same amount to preserve directionality
      if (max_raw_sum != 0) {
        front_left = front_left / max_raw_sum * max_XYstick_value;
        back_left = back_left / max_raw_sum * max_XYstick_value;
        front_right = front_right / max_raw_sum * max_XYstick_value;
        back_right = back_right / max_raw_sum * max_XYstick_value;
      }

      // Now to consider rotation
      // Naively add the rotational axis
      front_left = front_left + con.Axis1.position(pct);
      back_left = back_left + con.Axis1.position(pct);
      front_right = front_right - con.Axis1.position(pct);
      back_right = back_right - con.Axis1.position(pct);

      // What is the largest sum, or is 100 larger?
      max_raw_sum =
          std::max(std::abs(front_left),
                   std::max(std::abs(back_left),
                            std::max(std::abs(front_right),
                                     std::max(std::abs(back_right), 100.0))));

      // Scale everything down by the factor that makes the largest only 100, if
      // it was over
      front_left = front_left / max_raw_sum * 100.0;
      back_left = back_left / max_raw_sum * 100.0;
      front_right = front_right / max_raw_sum * 100.0;
      back_right = back_right / max_raw_sum * 100.0;

      // Write the manipulated values out to the motors
      front_left_motor.spin(fwd, front_left, velocityUnits::pct);
      back_left_motor.spin(fwd, back_left, velocityUnits::pct);
      front_right_motor.spin(fwd, front_right, velocityUnits::pct);
      back_right_motor.spin(fwd, back_right, velocityUnits::pct);
    }
  }

  // This is the main execution loop for the user control program.
  // Each time through the loop your program should 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 resources.
}

//
// Main will set up the competition functions and callbacks.
//
int main ();
 // Run the pre-autonomous function.
  pre_auton();

  // Set up callbacks for autonomous and driver control periods.
  Competition.autonomous(autonomous);
  Competition.drivercontrol(usercontrol);

  // autonomous();
  // Prevent main from exiting with an infinite loop.
  while (true) {
    wait(100, msec);
  }
}

Replace the semicolon after int main() with a curly bracket

image

Previously the mistake was that there were two end brackets, leading me to believe that main was defined inside another function. That end bracket ( } ) has to go wherever the other function ends (probably usercontrol?)

you created (or probably edited) an illegal project name, remove the spaces from

11-06-19 macro hightower
6 Likes

thank fricking god for @jpearman. What would we do w/o you. This worked.

2 Likes

if you remove the “while(1){” line from usercontrol it builds fine for me. You only need 1 while loop for user control

Lol well that’s kind of critical to the program.

Solution is to end bracket wherever you want the while loop to end

1 Like