Util
Functions
is_reversed()
Checks whether a smart port is reversed.
- Prototype
- Prototype_2
- Example
bool is_reversed(double input);
bool is_reversed(int input);
#define INTAKER_PORT
bool port_is_reversed = is_reversed(INTAKER_PORT);
if(port_is_reversed){
}
Parameters | |
---|---|
input | A number. |
Returns: true
if the port it is reversed. Or ``false` if the port it not reversed.
smooth_Joystick_Output()
Applies a smoothing function to joystick input values.
This function smooths the joystick input based on a specified exponent and maximum value. The smoothing function adjusts the joystick value to create a more gradual response.
- Prototype
- Example
float smooth_Joystick_Output(int joystick_value, int exponent, int max_value);
void opcontrol(){
while(1){
raw_joystick_x = control.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_X); //raw joystick value
raw_joystick_y = control.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y); //raw joystick value
power = util::smooth_Joystick_Output(raw_joystick_y,n_y); //smooth joystick value
turn= util::smooth_Joystick_Output(raw_joystick_x, n_x); //smooth joystick value
left_side.move(power+turn);
right_side.move(powe-turn);
pros::delay(10);
}
}
Parameters | |
---|---|
joystick_value | Analog joystick value. |
exponent | The exponent value; a higher exponent provides more smoothing. |
max_value | The maximum value of the joystick. Default value is 127. |