CuberSz
December 1, 2022, 7:32pm
#1
I am fairly new to text coding and I’m working on a mecanum drive using arcade controls for the right side and I attempted to compile the code and i got this error ’ unix build for platform vexv5
CXX src/main.cpp
LINK build/Mecanum.elf
arm-none-eabi-ld: /home/ubuntu/cloudcompiler/Tools/sdk/vexv5/20220726_10_00_00/libv5rt.a(v5_startup.c.obj): in function `vexMain’:
(.text.vexMain+0xa0): undefined reference to `main’
make: *** [vex/mkrules.mk:18: build/Mecanum.elf] Error 1
make process closed with exit code : 2’
I’m not sure what to do
Could you send your full code so that we can help you better?
CuberSz
December 1, 2022, 7:48pm
#3
'#pragma region VEXcode Generated Robot Configuration
// Make sure all required headers are included.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <string.h>
#include "vex.h"
using namespace vex;
// Brain should be defined by default
brain Brain;
// START V5 MACROS
#define waitUntil(condition) \
do { \
wait(5, msec); \
} while (!(condition))
#define repeat(iterations) \
for (int iterator = 0; iterator < iterations; iterator++)
// END V5 MACROS
// Robot configuration code.
controller Controller1 = controller(primary);
motor Claw = motor(PORT5, ratio18_1, false);
motor Arm = motor(PORT6, ratio18_1, false);
motor Back_left = motor(PORT7, ratio18_1, false);
motor Back_Right = motor(PORT8, ratio18_1, true);
motor Front_left = motor(PORT11, ratio18_1, false);
motor Front_right = motor(PORT20, ratio18_1, true);
// define variable for remote controller enable/disable
bool RemoteControlCodeEnabled = true;
#pragma endregion VEXcode Generated Robot Configuration
// Include the V5 Library
#include "vex.h"
// Allows for easier use of the VEX Library
using namespace vex;
float myVariable;
int whenStarted1() {
//deadzone
while (true) {
int threshold = 10;
int a = Controller1.Axis1.value();
int b = Controller1.Axis2.value();
int c = Controller1.Axis3.value();
int d = Controller1.Axis4.value();
if(abs(a)<threshold){
a=0;
}
if(abs(b)<threshold){
b=0;
}
if(abs(c)<threshold){
c=0;
}
if(abs(d)<threshold){
d=0;
}
//Foward
Back_left.setVelocity((Controller1.Axis2.position() + Controller1.Axis1.position()), percent);
Back_Right.setVelocity((Controller1.Axis2.position() + Controller1.Axis1.position()), percent);
Front_left.setVelocity((Controller1.Axis2.position() + Controller1.Axis1.position()), percent);
Front_right.setVelocity((Controller1.Axis2.position() + Controller1.Axis1.position()), percent);
Back_left.spin(forward);
Back_Right.spin(forward);
Front_left.spin(forward);
Front_right.spin(forward);
//Backwards
Back_left.setVelocity((Controller1.Axis2.position() - Controller1.Axis1.position()), percent);
Back_Right.setVelocity((Controller1.Axis2.position() - Controller1.Axis1.position()), percent);
Front_left.setVelocity((Controller1.Axis2.position() - Controller1.Axis1.position()), percent);
Front_right.setVelocity((Controller1.Axis2.position() - Controller1.Axis1.position()), percent);
Back_left.spin(reverse);
Back_Right.spin(reverse);
Front_left.spin(reverse);
Front_right.spin(reverse);
//Left
Back_left.setVelocity((Controller1.Axis1.position() - Controller1.Axis2.position() ), percent);
Back_Right.setVelocity((Controller1.Axis1.position() - Controller1.Axis2.position() ), percent);
Front_left.setVelocity((Controller1.Axis1.position() - Controller1.Axis2.position() ), percent);
Front_right.setVelocity((Controller1.Axis1.position() - Controller1.Axis2.position() ), percent);
Back_left.spin(reverse);
Back_Right.spin(forward);
Front_left.spin(forward);
Front_right.spin(reverse);
wait(5, msec);
}
return 0;
}
'
Also any tips on how to write this better would also be greatly appreciated