How to important libraries on vex vs

I’m getting errors for using abs “to few arguments in function call” and that’s only for when abs is in it for example, bool isTurning = (abs(Controller1.Axis1.value()) > turningThreshold);
and i have that in my vex.h

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "v5.h"
#include "v5_vcs.h"

#include <cmath>
#include "iostream"
#include "chrono"


#define waitUntil(condition)                                                   \
  do {                                                                         \
    wait(5, msec);                                                             \
  } while (!(condition))

#define repeat(iterations)                                                     \
  for (int iterator = 0; iterator < iterations; iterator++)

Welcome to vexforum! Thank you for posting your code, it makes it way easier to help you!

Make sure that you put #include “vex.h” in the cpp file that your line producing the error is in.

Also, if you want to use the abs( function from cmath, you will have to call it as std::abs( because it is part of the std namespace.

First of all if you are having trouble with abs you can make your own function :

int absInt(int x){
if (x < 0){
return -x
}
return x
}

Also in the offical api .value() is not a memeber of the Controller.Axis1. API : (VEX Help) .So, try .position instead and see if that works better so revised code:

bool isTurning = (abs(Controller1.Axis1.position(percent)) > turningThreshold);

and if you use absInt

int absInt(int x){
if (x < 0){
return -x
}
return x
}
bool isTurning = (absInt(Controller1.Axis1.position(percent)) > turningThreshold);

See if that works better for you, right now im not at a place that I can test code so if there is still some issues with it, let me know.

It actually is, it may have been edited out of that (now outdated) help site for simplicity.

position() returns numbers in the range +/- 100 whereas value() returns in the range +/- 127 which much of the legacy (think RobotC) programming environments used to do.

/**
 * @brief Gets the value of the joystick axis on a scale from -127 to 127.
 * @return Returns an integer that represents the value of the joystick axis.
*/
int32_t  value( void ) const;

Oh, my bad I usually when I reply have my computer open looking at the properties to make sure that im correct when responding. Thank you (Also just realized I use .value too).

Now, I think that its something to do with how they use or include abs.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.