So I updated Vexcode Text 0.9 to 1.0. and upgraded my code. I tried migrating my code and running it, but it creates an error (specific error: make process closed with exit code : 2).
Please post your code (wrapped in [code]…[/code] tags), otherwise it’s quite difficult to figure out what’s wrong with it.
Continuing the discussion from [Code problems](https://www.vexforum.com/t/code-problems/67573):
<code> // To complete the VEXcode V5 Text project upgrade process, please follow the
// steps below.
//
// 1. You can use the Robot Configuration window to recreate your V5 devices
// - including any motors, sensors, 3-wire devices, and controllers.
//
// 2. All previous code located in main.cpp has now been commented out. You
// will need to migrate this code to the new "int main" structure created
// below and keep in mind any new device names you may have set from the
// Robot Configuration window.
//
// If you would like to go back to your original project, a complete backup
// of your original (pre-upgraded) project was created in a backup folder
// inside of this project's folder.
// ---- START VEXCODE CONFIGURED DEVICES ----
// ---- END VEXCODE CONFIGURED DEVICES ----
#include "vex.h"
using namespace vex;
const double pi = atan(1)*4; bool auton = true;
bool tile = false;
// A global instance of vex::brain used for printing to the V5 brain screen
brain Brain;
// A global instance of vex::competition
competition Competition;
//define your global instances of motors and other devices here
motor L(PORT19, true); // Left wheels
motor R(PORT11); //right wheels
motor Stackrelease(PORT12); // pushes stacked blocks forward
motor Rintake(PORT13); //intake motors motor
motor Lintake(PORT10);
motor Lift1(PORT20); //lift motors
motor Lift2(PORT14, true);
//motor Lfront(PORT1); //possible bar mechamism to release blocks smoothly
vision Visionsensor(PORT5);
controller Controller = controller();
//don't remember any other motors
//functions
//converts inches to rotations
double convert(double inches){
return (inches*4)/(11*pi);
};
void yeet(bool sea, bool see){
while(1){
Rintake.spin(directionType(true));
Lintake.spin(directionType(false));
}
if (sea == true){
// red tile 1
if (see == true){
// moves forward 54 inches(can change)
L.rotateTo(convert(54), rotationUnits(rev), false);
R.rotateTo(convert(54), rotationUnits(rev), true);
L.stop();
//turn right 90 degrees
L.rotateTo(-700, rotationUnits(deg), false);
R.rotateTo(700, rotationUnits(deg));
//moves forward 72 inches
L.rotateTo(convert(72), rotationUnits(rev), false);
R.rotateTo(convert(72), rotationUnits(rev), true);
//turns right 90 degrees
L.rotateTo(-700, rotationUnits(deg), false);
R.rotateTo(700, rotationUnits(deg));
//move forward 22 inches
L.rotateTo(convert(22), rotationUnits(rev), false);
R.rotateTo(convert(22), rotationUnits(rev), true);
//turn left 45 degrees
L.rotateTo(-350, rotationUnits(deg), false);
R.rotateTo(350, rotationUnits(deg));
//drive forward 16 inches
L.rotateTo(convert(30), rotationUnits(rev), false);
R.rotateTo(convert(30), rotationUnits(rev), true);
Rintake.spin(directionType(false));
Lintake.spin(directionType(true));
task::sleep(3000);
Rintake.stop();
Lintake.stop();
}
//red tile 2
else if (see == false){
Rintake.spin(directionType(true));
Lintake.spin(directionType(false));
//moves forward 54 inches(can change)
L.rotateTo(convert(54), rotationUnits(rev), false);
R.rotateTo(convert(54), rotationUnits(rev), true);
L.stop();
//turn 90 degrees
L.rotateTo(700, rotationUnits(deg), false);
R.rotateTo(-700, rotationUnits(deg));
//moves forward 72 inches
L.rotateTo(convert(72), rotationUnits(rev), false);
R.rotateTo(convert(72), rotationUnits(rev), true);
//turns left 45 degrees
L.rotateTo(360, rotationUnits(deg), false);
R.rotateTo(-360, rotationUnits(deg));
//move forward 24 inches
L.rotateTo(convert(24), rotationUnits(rev), false);
R.rotateTo(convert(24), rotationUnits(rev), true);
Rintake.spin(directionType(false));
Lintake.spin(directionType(true));
Rintake.stop();
Lintake.stop();
}
}
else if (sea == false){
//blue tile 1
if (see == true){
Rintake.spin(directionType(true));
Lintake.spin(directionType(false));
//moves forward 54 inches(can change)
L.rotateTo(convert(54), rotationUnits(rev), false);
R.rotateTo(convert(54), rotationUnits(rev), true);
L.stop();
//turn 90 degrees
L.rotateTo(700, rotationUnits(deg), false);
R.rotateTo(-700, rotationUnits(deg));
//moves forward 72 inches
L.rotateTo(convert(72), rotationUnits(rev), false);
R.rotateTo(convert(72), rotationUnits(rev), true);
//turns left 90 degrees
L.rotateTo(700, rotationUnits(deg), false);
R.rotateTo(-700, rotationUnits(deg));
//move forward 22 inches
L.rotateTo(convert(22), rotationUnits(rev), false);
R.rotateTo(convert(22), rotationUnits(rev), true);
//turn right 45 degrees
L.rotateTo(-350, rotationUnits(deg), false);
R.rotateTo(350, rotationUnits(deg));
//drive forward 16 inches
L.rotateTo(convert(30), rotationUnits(rev), false);
R.rotateTo(convert(30), rotationUnits(rev), true);
Rintake.spin(directionType(false));
Lintake.spin(directionType(true));
Rintake.stop();
Lintake.stop();
}
//blue tile 2 option 1
else if (see == false){
Rintake.spin(directionType(true));
Lintake.spin(directionType(false));
//moves forward 54 inches(can change)
L.rotateTo(convert(54), rotationUnits(rev), false);
R.rotateTo(convert(54), rotationUnits(rev), true);
L.stop();
//turn 270 degrees
L.rotateTo(700, rotationUnits(deg), false);
R.rotateTo(-700, rotationUnits(deg));
//moves forward 72 inches
L.rotateTo(convert(72), rotationUnits(rev), false);
R.rotateTo(convert(72), rotationUnits(rev), true);
//turns right 45 degrees
L.rotateTo(-360, rotationUnits(deg), false);
R.rotateTo(360, rotationUnits(deg));
//move forward 24 inches
L.rotateTo(convert(24), rotationUnits(rev), false);
R.rotateTo(convert(24), rotationUnits(rev), true);
Rintake.spin(directionType(false));
Lintake.spin(directionType(true));
Rintake.stop();
Lintake.stop();
}
}
};
/*---------------------------------------------------------------------------*/
/* 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 cortex has been powered on and */
/* not every time that the robot is disabled. */
/*---------------------------------------------------------------------------*/
void pre_auton( void ) {
//All activities that occur before the competition starts
//Example: clearing encoders, setting servo positions, ...
Lift1.rotateTo(30, rotationUnits(deg), false);
Lift2.rotateTo(30, rotationUnits(deg), true);
}
/*---------------------------------------------------------------------------*/
/* */
/* 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 ) {
/*..........................................................................
Insert autonomous user code here.
..........................................................................*/
yeet(auton, tile);
}
/*---------------------------------------------------------------------------*/
/* */
/* 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 usercontrol( void ) {
//User control code here, inside the loop
while (1) {
/*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.
........................................................................*/
vex::task::sleep(20); //Sleep the task for a short amount of time to prevent wasted resources.
}
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
Competition.autonomous(autonomous);
Competition.drivercontrol(usercontrol);
vexcodeInit();
pre_auton();
while(1){
wait(100, msec);
}
}
</code>
Sorry for the failed posts! I don’t know how to post code on vex forum. (I am a noob)
Edit your post, highlight all the code, then click the </> button
Thanks for the instructions!
I copied your code and tried to compile it, and this was the complete terminal output that resulted from doing that:
unix build for platform vexv5
CXX src/main.cpp
CXX src/robot-config.cpp
LINK build/test2.elf
build/src/robot-config.o:(.bss.Brain+0x0): multiple definition of `Brain'
build/src/main.o:(.bss.Brain+0x0): first defined here
make: *** [build/test2.elf] Error 1
[error]: make process closed with exit code : 2
The error you quoted (“make process closed with exit code : 2”) just means that something went wrong, and your code didn’t compile as a result. To determine what that is, we need to look further up in the compiler output, specifically at these lines:
build/src/robot-config.o:(.bss.Brain+0x0): multiple definition of `Brain'
build/src/main.o:(.bss.Brain+0x0): first defined here
“Multiple definition” means that you’re initializing an object with the same name (in this case “Brain”) in two different places: once in main.cpp, the other time in robot_config.h.
I took a look at the default robot_config.h (by right-clicking on #include "vex.h"
, and clicking “Go to Definition”, then doing the same on #include "robot_config.h"
to view that file), which VEXcode helpfully told me was “Auto-generated by Graphical Device Configuration”. Here’s what the file looked like on a new project, with no robot connected and having done no configuration:
using namespace vex;
extern brain Brain;
/**
* Used to initialize code/tasks/devices added using tools in VEXcode Text.
*
* This should be called at the start of your int main function.
*/
void vexcodeInit(void);
Sure enough, there’s an instantiation of an object called Brain
. Seems like the auto-configurator is initializing that object behind the scenes for you, so it’s no longer necessary to declare it in main.cpp
like previous versions did. Removing the declaration of Brain
in main.cpp
allowed the code to compile.
(As an aside, writing a function with two variables called see
and sea
is not a great thing to do from a readability standpoint.)
Thank You very much, the change in code worked. I used the variables because I really couldn’t think of any specific names for their function in the program.
Looks to me like sea
indicates which color you’re on (red when true, blue when false), and see
indicates which routine you want to do on that side of the field. So more descriptive names for them might be something like redAlliance
and auton1
respectively.
Or, if later you want to write additional routines for each color, then swap the second boolean for an int, then you could call it something like whichRoutine
.